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-2022 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
97void 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( "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( "\\", "/" );
185
186 // Update the paths to the loaded sheets.
187 std::vector< SCH_ITEM* > sheetsInLoadedSchematic;
188
189 newSheet->GetScreen()->GetSheets( &sheetsInLoadedSchematic );
190
191 for( SCH_ITEM* item : sheetsInLoadedSchematic )
192 {
193 SCH_SHEET* sheet = static_cast< SCH_SHEET* >( item );
194
195 wxCHECK2( sheet, continue );
196
197 wxFileName loadedSheetFileName = sheet->GetFileName();
198 wxString newSheetFilePath = topLevelSheetPath + loadedSheetFileName.GetFullName();
199
200 sheet->SetFileName( newSheetFilePath );
201 }
202 }
203
204 SCH_SHEET_LIST sheetHierarchy( newSheet.get() ); // This is the hierarchy of the loaded file.
205 SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // This is the schematic sheet hierarchy.
206
207 // Make sure any new sheet changes do not cause any recursion issues.
208 if( CheckSheetForRecursion( newSheet.get(), aHierarchy )
209 || checkForNoFullyDefinedLibIds( newSheet.get() ) )
210 {
211 return false;
212 }
213
214 // Make a valiant attempt to warn the user of all possible scenarios where there could
215 // be broken symbol library links.
216 wxArrayString names;
217 wxArrayString newLibNames;
218 SCH_SCREENS newScreens( newSheet.get() ); // All screens associated with the import.
219 SCH_SCREENS prjScreens( &Schematic().Root() );
220
221 newScreens.GetLibNicknames( names );
222
223 wxMessageDialog::ButtonLabel okButtonLabel( _( "Continue Load" ) );
224 wxMessageDialog::ButtonLabel cancelButtonLabel( _( "Cancel Load" ) );
225
226 // Prior to schematic file format 20221002, all symbol instance data was saved in the root
227 // sheet so loading a hierarchical sheet that is not the root sheet will have no symbol
228 // instance data. Give the user a chance to go back and save the project that contains this
229 // hierarchical sheet so the symbol instance data will be correct on load.
230 if( ( newSheet->GetScreen()->GetFileFormatVersionAtLoad() < 20221002 )
231 && newSheet->GetScreen()->GetSymbolInstances().empty() )
232 {
233 msg = _( "There hierarchical sheets in the loaded schematic file from an older "
234 "file version resulting in missing symbol instance data. This will "
235 "result in all of the symbols in the loaded schematic to use either the "
236 "default instance setting or fall back to the library symbol settings. "
237 "Loading the project that uses this schematic file and saving to the "
238 "lastest file version will resolve this issue.\n\n"
239 "Do you wish to continue?" );
240 wxMessageDialog msgDlg7( this, msg, _( "Continue Load Schematic" ),
241 wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER | wxICON_QUESTION );
242 msgDlg7.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
243
244 if( msgDlg7.ShowModal() == wxID_CANCEL )
245 return false;
246 }
247
248 if( !prjScreens.HasSchematic( fullFilename ) )
249 {
250 if( fileName.GetPathWithSep() == Prj().GetProjectPath() )
251 {
252 // A schematic in the current project path that isn't part of the current project.
253 // It's possible the user copied this schematic from another project so the library
254 // links may not be available. Even this is check is no guarantee that all symbol
255 // library links are valid but it's better than nothing.
256 for( const wxString& name : names )
257 {
258 if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
259 newLibNames.Add( name );
260 }
261
262 if( !newLibNames.IsEmpty() )
263 {
264 msg = _( "There are library names in the selected schematic that are missing "
265 "from the current project library table. This may result in broken "
266 "symbol library references for the loaded schematic.\n\n"
267 "Do you wish to continue?" );
268 wxMessageDialog msgDlg3( this, msg, _( "Continue Load Schematic" ),
269 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
270 wxCENTER | wxICON_QUESTION );
271 msgDlg3.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
272
273 if( msgDlg3.ShowModal() == wxID_CANCEL )
274 return false;
275 }
276 }
277 else if( fileName.GetPathWithSep() != Prj().GetProjectPath() )
278 {
279 // A schematic loaded from a path other than the current project path.
280
281 // If there are symbol libraries in the imported schematic that are not in the
282 // symbol library table of this project, there could be a lot of broken symbol
283 // library links. Attempt to add the missing libraries to the project symbol
284 // library table.
285 wxArrayString duplicateLibNames;
286
287 for( const wxString& name : names )
288 {
289 if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
290 newLibNames.Add( name );
291 else
292 duplicateLibNames.Add( name );
293 }
294
295 SYMBOL_LIB_TABLE table;
296 wxFileName symLibTableFn( fileName.GetPath(),
298
299 // If there are any new or duplicate libraries, check to see if it's possible that
300 // there could be any missing libraries that would cause broken symbol library links.
301 if( !newLibNames.IsEmpty() || !duplicateLibNames.IsEmpty() )
302 {
303 if( !symLibTableFn.Exists() || !symLibTableFn.IsFileReadable() )
304 {
305 msg = _( "The selected file was created as part of a different project. "
306 "Linking the file to this project may result in missing or "
307 "incorrect symbol library references.\n\n"
308 "Do you wish to continue?" );
309 wxMessageDialog msgDlg4( this, msg, _( "Continue Load Schematic" ),
310 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
311 wxCENTER | wxICON_QUESTION );
312 msgDlg4.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
313
314 if( msgDlg4.ShowModal() == wxID_CANCEL )
315 return false;
316 }
317 else
318 {
319 try
320 {
321 table.Load( symLibTableFn.GetFullPath() );
322 }
323 catch( const IO_ERROR& ioe )
324 {
325 msg.Printf( _( "Error loading the symbol library table '%s'." ),
326 symLibTableFn.GetFullPath() );
327 DisplayErrorMessage( nullptr, msg, ioe.What() );
328 return false;
329 }
330 }
331 }
332
333 // Check to see if any of the symbol libraries found in the appended schematic do
334 // not exist in the current project are missing from the appended project symbol
335 // library table.
336 if( !newLibNames.IsEmpty() )
337 {
338 bool missingLibNames = table.IsEmpty();
339
340 if( !missingLibNames )
341 {
342 for( const wxString& newLibName : newLibNames )
343 {
344 if( !table.HasLibrary( newLibName ) )
345 {
346 missingLibNames = true;
347 break;
348 }
349 }
350 }
351
352 if( missingLibNames )
353 {
354 msg = _( "There are symbol library names in the selected schematic that "
355 "are missing from the selected schematic project library table. "
356 "This may result in broken symbol library references.\n\n"
357 "Do you wish to continue?" );
358 wxMessageDialog msgDlg5( this, msg, _( "Continue Load Schematic" ),
359 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
360 wxCENTER | wxICON_QUESTION );
361 msgDlg5.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
362
363 if( msgDlg5.ShowModal() == wxID_CANCEL )
364 return false;
365 }
366 }
367
368 // The library name already exists in the current project. Check to see if the
369 // duplicate name is the same library in the current project. If it's not, it's
370 // most likely that the symbol library links will be broken.
371 if( !duplicateLibNames.IsEmpty() && !table.IsEmpty() )
372 {
373 bool libNameConflict = false;
374
375 for( const wxString& duplicateLibName : duplicateLibNames )
376 {
377 const SYMBOL_LIB_TABLE_ROW* thisRow = nullptr;
378 const SYMBOL_LIB_TABLE_ROW* otherRow = nullptr;
379
380 if( Prj().SchSymbolLibTable()->HasLibrary( duplicateLibName ) )
381 thisRow = Prj().SchSymbolLibTable()->FindRow( duplicateLibName );
382
383 if( table.HasLibrary( duplicateLibName ) )
384 otherRow = table.FindRow( duplicateLibName );
385
386 // It's in the global library table so there is no conflict.
387 if( thisRow && !otherRow )
388 continue;
389
390 if( !thisRow || !otherRow )
391 continue;
392
393 wxFileName otherUriFileName;
394 wxString thisURI = thisRow->GetFullURI( true );
395 wxString otherURI = otherRow->GetFullURI( false);
396
397 if( otherURI.Contains( "${KIPRJMOD}" ) || otherURI.Contains( "$(KIPRJMOD)" ) )
398 {
399 // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
400 // not expand to a valid symbol library path.
401 otherUriFileName.SetPath( fileName.GetPath() );
402 otherUriFileName.SetFullName( otherURI.AfterLast( '}' ) );
403 otherURI = otherUriFileName.GetFullPath();
404 }
405
406 if( thisURI != otherURI )
407 {
408 libNameConflict = true;
409 break;
410 }
411 }
412
413 if( libNameConflict )
414 {
415 msg = _( "A duplicate library name that references a different library exists "
416 "in the current library table. This conflict cannot be resolved and "
417 "may result in broken symbol library references.\n\n"
418 "Do you wish to continue?" );
419 wxMessageDialog msgDlg6( this, msg, _( "Continue Load Schematic" ),
420 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
421 wxCENTER | wxICON_QUESTION );
422 msgDlg6.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
423
424 if( msgDlg6.ShowModal() == wxID_CANCEL )
425 return false;
426 }
427 }
428
429 // All (most?) of the possible broken symbol library link cases are covered. Map the
430 // new appended schematic project symbol library table entries to the current project
431 // symbol library table.
432 if( !newLibNames.IsEmpty() && !table.IsEmpty() )
433 {
434 for( const wxString& libName : newLibNames )
435 {
436 if( !table.HasLibrary( libName )
437 || Prj().SchSymbolLibTable()->HasLibrary( libName ) )
438 {
439 continue;
440 }
441
442 // Don't expand environment variable because KIPRJMOD will not be correct
443 // for a different project.
444 wxString uri = table.GetFullURI( libName, false );
445 wxFileName newLib;
446
447 if( uri.Contains( "${KIPRJMOD}" ) || uri.Contains( "$(KIPRJMOD)" ) )
448 {
449 // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
450 // not expand to a valid symbol library path.
451 newLib.SetPath( fileName.GetPath() );
452 newLib.SetFullName( uri.AfterLast( '}' ) );
453 uri = newLib.GetFullPath();
454 }
455 else
456 {
457 uri = table.GetFullURI( libName );
458 }
459
460 // Add the library from the imported project to the current project
461 // symbol library table.
462 const SYMBOL_LIB_TABLE_ROW* row = table.FindRow( libName );
463
464 wxCHECK( row, false );
465
466 SYMBOL_LIB_TABLE_ROW* newRow = new SYMBOL_LIB_TABLE_ROW( libName, uri,
467 row->GetType(),
468 row->GetOptions(),
469 row->GetDescr() );
470
471 Prj().SchSymbolLibTable()->InsertRow( newRow );
472 libTableChanged = true;
473 }
474 }
475 }
476 }
477
478 SCH_SCREEN* newScreen = newSheet->GetScreen();
479 wxCHECK_MSG( newScreen, false, "No screen defined for sheet." );
480
481 if( libTableChanged )
482 {
483 Prj().SchSymbolLibTable()->Save( Prj().GetProjectPath() +
485 }
486
487 // Make the best attempt to set the symbol instance data for the loaded scheamtic.
488 if( newScreen->GetFileFormatVersionAtLoad() < 20221002 )
489 {
490 if( !newScreen->GetSymbolInstances().empty() )
491 {
492 // If the loaded schematic is a root sheet for another project, update the symbol
493 // instances.
494 sheetHierarchy.UpdateSymbolInstances( newScreen->GetSymbolInstances() );
495 }
496 else
497 {
498 // Otherwise, fall back to the default instance data which still exists in this
499 // schematic file version.
500 newScreens.SetAllSymbolDefaultInstances();
501 }
502 }
503
504 // Attempt to create new symbol instances using the instance data loaded above.
505 sheetHierarchy.AddNewSymbolInstances( *aHierarchy );
506
507 // Add new sheet instance data.
508 sheetHierarchy.AddNewSheetInstances( *aHierarchy, hierarchy.GetLastVirtualPageNumber() );
509
510 // It is finally safe to add or append the imported schematic.
511 if( aSheet->GetScreen() == nullptr )
512 aSheet->SetScreen( newScreen );
513 else
514 aSheet->GetScreen()->Append( newScreen );
515
516 SCH_SCREENS allScreens( Schematic().Root() );
517 allScreens.ReplaceDuplicateTimeStamps();
518
519 return true;
520}
521
522
524 bool* aClearAnnotationNewItems )
525{
526 if( aSheet == nullptr || aHierarchy == nullptr )
527 return false;
528
529 // Get the new texts
530 DIALOG_SHEET_PROPERTIES dlg( this, aSheet, aClearAnnotationNewItems );
531
532 if( dlg.ShowModal() == wxID_CANCEL )
533 return false;
534
535 return true;
536}
537
538
540{
541 wxRect DrawArea;
542 BASE_SCREEN* screen = GetScreen();
543
544 DrawArea.SetSize( GetPageSizeIU() );
545
546 // Calculate a reasonable dc size, in pixels, and the dc scale to fit
547 // the drawings into the dc size
548 // scale is the ratio resolution (in PPI) / internal units
549 double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
550 double inch2Iu = 1000.0 * schIUScale.IU_PER_MILS;
551 double scale = ppi / inch2Iu;
552
553 wxSize dcsize = DrawArea.GetSize();
554
555 int maxdim = std::max( dcsize.x, dcsize.y );
556
557 // the max size in pixels of the bitmap used to build the sheet copy
558 const int maxbitmapsize = 5600;
559
560 while( int( maxdim * scale ) > maxbitmapsize )
561 {
562 ppi = ppi / 1.5;
563 scale = ppi / inch2Iu;
564 }
565
566 dcsize.x *= scale;
567 dcsize.y *= scale;
568
569 // Set draw offset, zoom... to values needed to draw in the memory DC
570 // after saving initial values:
571 VECTOR2I tmp_startvisu = screen->m_StartVisu;
572 VECTOR2I old_org = screen->m_DrawOrg;
573 screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
574 screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
575
576 wxMemoryDC dc;
577 wxBitmap image( dcsize );
578 dc.SelectObject( image );
579 dc.Clear();
580
581 GRResetPenAndBrush( &dc );
582 GRForceBlackPen( false );
583 dc.SetUserScale( scale, scale );
584
586 // Init the color of the layer actually used to print the drawing sheet:
589
591
592 {
593 wxLogNull doNotLog; // disable logging of failed clipboard actions
594
595 if( wxTheClipboard->Open() )
596 {
597 // This data objects are held by the clipboard, so do not delete them in the app.
598 wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
599 wxTheClipboard->SetData( clipbrd_data );
600 wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
601 wxTheClipboard->Close();
602 }
603 }
604
605 // Deselect Bitmap from DC in order to delete the MemoryDC
606 dc.SelectObject( wxNullBitmap );
607
608 GRForceBlackPen( false );
609
610 screen->m_StartVisu = tmp_startvisu;
611 screen->m_DrawOrg = old_org;
612}
613
614
615bool SCH_EDIT_FRAME::AllowCaseSensitiveFileNameClashes( const wxString& aSchematicFileName )
616{
617 wxString msg;
618 SCH_SCREENS screens( Schematic().Root() );
619 wxFileName fn = aSchematicFileName;
620
621 wxCHECK( fn.IsAbsolute(), false );
622
623 if( eeconfig()->m_Appearance.show_sheet_filename_case_sensitivity_dialog
624 && screens.CanCauseCaseSensitivityIssue( aSchematicFileName ) )
625 {
626 msg.Printf( _( "The file name '%s' can cause issues with an existing file name\n"
627 "already defined in the schematic on systems that support case\n"
628 "insensitive file names. This will cause issues if you copy this\n"
629 "project to an operating system that supports case insensitive file\n"
630 "names.\n\nDo you wish to continue?" ),
631 fn.GetName() );
632
633 wxRichMessageDialog dlg( this, msg, _( "Warning" ),
634 wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION );
635 dlg.ShowCheckBox( _( "Do not show this message again." ) );
636 dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Create New Sheet" ) ),
637 wxMessageDialog::ButtonLabel( _( "Discard New Sheet" ) ) );
638
639 if( dlg.ShowModal() == wxID_NO )
640 return false;
641
643 !dlg.IsCheckBoxChecked();
644 }
645
646 return true;
647}
const char * name
Definition: DXF_plotter.cpp:56
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
VECTOR2I m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:88
VECTOR2I m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device)
Definition: base_screen.h:93
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
void SetPrintDC(wxDC *aDC)
Definition: kiid.h:47
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
const wxString & GetOptions() const
Return the options string, which may hold a password or anything else needed to instantiate the under...
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...
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
wxString GetFullURI(const wxString &aLibNickname, bool aExpandEnvVars=true) const
Return the full URI of the library mapped to aLibNickname.
bool IsEmpty(bool aIncludeFallback=true)
Return true if the table is empty.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:85
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
EESCHEMA_SETTINGS * eeconfig() const
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Helper to retrieve a layer color from the global color settings.
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:615
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:97
bool CheckSheetForRecursion(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
Verify that aSheet will not cause a recursion error in aHierarchy.
Definition: sheet.cpp:47
SCHEMATIC & Schematic() const
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:539
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
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:523
virtual void PrintPage(const RENDER_SETTINGS *aSettings) override
Plot or print the current sheet to the clipboard.
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:174
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:535
virtual SCH_SHEET * Load(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const PROPERTIES *aProperties=nullptr)
Load information from some input file format that this SCH_PLUGIN implementation knows about,...
Definition: sch_plugin.cpp:51
virtual const wxString & GetError() const
Return an error string to the caller.
Definition: sch_plugin.cpp:177
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:613
void SetAllSymbolDefaultInstances()
Set symbol default instances to the first instance in the instance list.
bool CanCauseCaseSensitivityIssue(const wxString &aSchematicFileName) const
Check aSchematicFileName for a potential file name case sensitivity issue.
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
int ReplaceDuplicateTimeStamps()
Test all sheet and symbol objects in the schematic for duplicate time stamps and replaces them as nec...
bool HasSchematic(const wxString &aSchematicFileName)
Check if one of the schematics in the list of screens is aSchematicFileName.
size_t GetLibNicknames(wxArrayString &aLibNicknames)
Fetch all of the symbol library nicknames into aLibNicknames.
const wxString & GetFileName() const
Definition: sch_screen.h:143
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:106
int GetFileFormatVersionAtLoad() const
Definition: sch_screen.h:128
const std::vector< SYMBOL_INSTANCE_REFERENCE > & GetSymbolInstances() const
Definition: sch_screen.h:488
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:141
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void UpdateSymbolInstances(const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
int GetLastVirtualPageNumber() const
void AddNewSheetInstances(const SCH_SHEET_PATH &aPrefixSheetPath, int aLastVirtualPageNumber)
void AddNewSymbolInstances(const SCH_SHEET_PATH &aPrefixSheetPath)
Attempt to add new symbol instances for all symbols in this list of sheet paths prefixed with aPrefix...
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...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SCREEN * LastScreen()
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:55
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:305
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:299
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:162
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
const wxString GetType() const override
Return the type of symbol library table represented by this row.
static const wxString & GetSymbolLibTableFileName()
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...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:320
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:299
This file is part of the common library.
#define _(s)
void GRForceBlackPen(bool flagforce)
Definition: gr_basic.cpp:150
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:72
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:217
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:382
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
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
const int scale
const double IU_PER_MILS
Definition: base_units.h:78
Definition of file extensions used in Kicad.