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 wxFileName currentSheetFileName;
112 bool libTableChanged = false;
113 SCH_IO_MGR::SCH_FILE_T schFileType = SCH_IO_MGR::GuessPluginTypeFromSchPath( aFileName );
114 SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( schFileType ) );
115 std::unique_ptr< SCH_SHEET> tmpSheet = std::make_unique<SCH_SHEET>( &Schematic() );
116
117 // This will cause the sheet UUID to be set to the UUID of the aSheet argument. This is
118 // required to ensure all of the sheet paths in any sub-sheets are correctly generated when
119 // using the temporary SCH_SHEET object that the file is loaded into..
120 const_cast<KIID&>( tmpSheet->m_Uuid ) = aSheet->m_Uuid;
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 tmpSheet.reset( pi->Load( fullFilename, &Schematic() ) );
137 }
138 else
139 {
140 tmpSheet->SetFileName( fullFilename );
141 pi->Load( fullFilename, &Schematic(), tmpSheet.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 loading schematic '%s'." ), fullFilename );
162 DisplayErrorMessage( this, msg, ioe.What() );
163
164 msg.Printf( _( "Failed to load '%s'." ), fullFilename );
165 SetMsgPanel( wxEmptyString, msg );
166
167 return false;
168 }
169
170 // If the loaded schematic is in a different folder from the current project and
171 // it contains hierarchical sheets, the hierarchical sheet paths need to be updated.
172 if( fileName.GetPathWithSep() != Prj().GetProjectPath() && tmpSheet->CountSheets() )
173 {
174 SCH_SHEET_LIST loadedSheets( tmpSheet.get() );
175
176 for( const SCH_SHEET_PATH& sheetPath : loadedSheets )
177 {
178 // Skip the loaded sheet since the user already determined if the file path should
179 // be relative or absolute.
180 if( sheetPath.size() == 1 )
181 continue;
182
183 wxString lastSheetPath = fileName.GetPathWithSep();
184
185 for( unsigned i = 1; i < sheetPath.size(); i++ )
186 {
187 SCH_SHEET* sheet = sheetPath.at( i );
188 wxCHECK2( sheet, continue );
189
190 SCH_SCREEN* screen = sheet->GetScreen();
191 wxCHECK2( screen, continue );
192
193 // Use the screen file name which should always be absolute.
194 wxFileName loadedSheetFileName = screen->GetFileName();
195 wxCHECK2( loadedSheetFileName.IsAbsolute(), continue );
196
197 wxFileName tmp = loadedSheetFileName;
198 wxString sheetFileName;
199
200 if( tmp.MakeRelativeTo( lastSheetPath ) )
201 sheetFileName = tmp.GetFullPath();
202 else
203 sheetFileName = loadedSheetFileName.GetFullPath();
204
205 sheetFileName.Replace( wxT( "\\" ), wxT( "/" ) );
206 sheet->SetFileName( sheetFileName );
207 lastSheetPath = loadedSheetFileName.GetPath();
208 }
209 }
210 }
211
212 SCH_SHEET_LIST sheetHierarchy( tmpSheet.get() ); // This is the hierarchy of the loaded file.
213 SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // This is the schematic sheet hierarchy.
214
215 // Make sure any new sheet changes do not cause any recursion issues.
216 if( CheckSheetForRecursion( tmpSheet.get(), aHierarchy )
217 || checkForNoFullyDefinedLibIds( tmpSheet.get() ) )
218 {
219 return false;
220 }
221
222 // Make a valiant attempt to warn the user of all possible scenarios where there could
223 // be broken symbol library links.
224 wxArrayString names;
225 wxArrayString newLibNames;
226 SCH_SCREENS newScreens( tmpSheet.get() ); // All screens associated with the import.
227 SCH_SCREENS prjScreens( &Schematic().Root() );
228
229 newScreens.GetLibNicknames( names );
230
231 wxMessageDialog::ButtonLabel okButtonLabel( _( "Continue Load" ) );
232 wxMessageDialog::ButtonLabel cancelButtonLabel( _( "Cancel Load" ) );
233
234 // Prior to schematic file format 20221002, all symbol instance data was saved in the root
235 // sheet so loading a hierarchical sheet that is not the root sheet will have no symbol
236 // instance data. Give the user a chance to go back and save the project that contains this
237 // hierarchical sheet so the symbol instance data will be correct on load.
238 if( ( tmpSheet->GetScreen()->GetFileFormatVersionAtLoad() < 20221002 )
239 && tmpSheet->GetScreen()->GetSymbolInstances().empty() )
240 {
241 msg = _( "There are hierarchical sheets in the loaded schematic file from an older "
242 "file version resulting in missing symbol instance data. This will "
243 "result in all of the symbols in the loaded schematic to use either the "
244 "default instance setting or fall back to the library symbol settings. "
245 "Loading the project that uses this schematic file and saving to the "
246 "lastest file version will resolve this issue.\n\n"
247 "Do you wish to continue?" );
248 wxMessageDialog msgDlg7( this, msg, _( "Continue Load Schematic" ),
249 wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER | wxICON_QUESTION );
250 msgDlg7.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
251
252 if( msgDlg7.ShowModal() == wxID_CANCEL )
253 return false;
254 }
255
256 if( !prjScreens.HasSchematic( fullFilename ) )
257 {
258 if( fileName.GetPathWithSep() == Prj().GetProjectPath() )
259 {
260 // A schematic in the current project path that isn't part of the current project.
261 // It's possible the user copied this schematic from another project so the library
262 // links may not be available. Even this is check is no guarantee that all symbol
263 // library links are valid but it's better than nothing.
264 for( const wxString& name : names )
265 {
266 if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
267 newLibNames.Add( name );
268 }
269
270 if( !newLibNames.IsEmpty() )
271 {
272 msg = _( "There are library names in the selected schematic that are missing "
273 "from the current project library table. This may result in broken "
274 "symbol library references for the loaded schematic.\n\n"
275 "Do you wish to continue?" );
276 wxMessageDialog msgDlg3( this, msg, _( "Continue Load Schematic" ),
277 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
278 wxCENTER | wxICON_QUESTION );
279 msgDlg3.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
280
281 if( msgDlg3.ShowModal() == wxID_CANCEL )
282 return false;
283 }
284 }
285 else if( fileName.GetPathWithSep() != Prj().GetProjectPath() )
286 {
287 // A schematic loaded from a path other than the current project path.
288
289 // If there are symbol libraries in the imported schematic that are not in the
290 // symbol library table of this project, there could be a lot of broken symbol
291 // library links. Attempt to add the missing libraries to the project symbol
292 // library table.
293 wxArrayString duplicateLibNames;
294
295 for( const wxString& name : names )
296 {
297 if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
298 newLibNames.Add( name );
299 else
300 duplicateLibNames.Add( name );
301 }
302
303 SYMBOL_LIB_TABLE table;
304 wxFileName symLibTableFn( fileName.GetPath(),
306
307 // If there are any new or duplicate libraries, check to see if it's possible that
308 // there could be any missing libraries that would cause broken symbol library links.
309 if( !newLibNames.IsEmpty() || !duplicateLibNames.IsEmpty() )
310 {
311 if( !symLibTableFn.Exists() || !symLibTableFn.IsFileReadable() )
312 {
313 msg = _( "The selected file was created as part of a different project. "
314 "Linking the file to this project may result in missing or "
315 "incorrect symbol library references.\n\n"
316 "Do you wish to continue?" );
317 wxMessageDialog msgDlg4( this, msg, _( "Continue Load Schematic" ),
318 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
319 wxCENTER | wxICON_QUESTION );
320 msgDlg4.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
321
322 if( msgDlg4.ShowModal() == wxID_CANCEL )
323 return false;
324 }
325 else
326 {
327 try
328 {
329 table.Load( symLibTableFn.GetFullPath() );
330 }
331 catch( const IO_ERROR& ioe )
332 {
333 msg.Printf( _( "Error loading the symbol library table '%s'." ),
334 symLibTableFn.GetFullPath() );
335 DisplayErrorMessage( nullptr, msg, ioe.What() );
336 return false;
337 }
338 }
339 }
340
341 // Check to see if any of the symbol libraries found in the appended schematic do
342 // not exist in the current project are missing from the appended project symbol
343 // library table.
344 if( !newLibNames.IsEmpty() )
345 {
346 bool missingLibNames = table.IsEmpty();
347
348 if( !missingLibNames )
349 {
350 for( const wxString& newLibName : newLibNames )
351 {
352 if( !table.HasLibrary( newLibName ) )
353 {
354 missingLibNames = true;
355 break;
356 }
357 }
358 }
359
360 if( missingLibNames )
361 {
362 msg = _( "There are symbol library names in the selected schematic that "
363 "are missing from the selected schematic project library table. "
364 "This may result in broken symbol library references.\n\n"
365 "Do you wish to continue?" );
366 wxMessageDialog msgDlg5( this, msg, _( "Continue Load Schematic" ),
367 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
368 wxCENTER | wxICON_QUESTION );
369 msgDlg5.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
370
371 if( msgDlg5.ShowModal() == wxID_CANCEL )
372 return false;
373 }
374 }
375
376 // The library name already exists in the current project. Check to see if the
377 // duplicate name is the same library in the current project. If it's not, it's
378 // most likely that the symbol library links will be broken.
379 if( !duplicateLibNames.IsEmpty() && !table.IsEmpty() )
380 {
381 bool libNameConflict = false;
382
383 for( const wxString& duplicateLibName : duplicateLibNames )
384 {
385 const SYMBOL_LIB_TABLE_ROW* thisRow = nullptr;
386 const SYMBOL_LIB_TABLE_ROW* otherRow = nullptr;
387
388 if( Prj().SchSymbolLibTable()->HasLibrary( duplicateLibName ) )
389 thisRow = Prj().SchSymbolLibTable()->FindRow( duplicateLibName );
390
391 if( table.HasLibrary( duplicateLibName ) )
392 otherRow = table.FindRow( duplicateLibName );
393
394 // It's in the global library table so there is no conflict.
395 if( thisRow && !otherRow )
396 continue;
397
398 if( !thisRow || !otherRow )
399 continue;
400
401 wxFileName otherUriFileName;
402 wxString thisURI = thisRow->GetFullURI( true );
403 wxString otherURI = otherRow->GetFullURI( false);
404
405 if( otherURI.Contains( "${KIPRJMOD}" ) || otherURI.Contains( "$(KIPRJMOD)" ) )
406 {
407 // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
408 // not expand to a valid symbol library path.
409 otherUriFileName.SetPath( fileName.GetPath() );
410 otherUriFileName.SetFullName( otherURI.AfterLast( '}' ) );
411 otherURI = otherUriFileName.GetFullPath();
412 }
413
414 if( thisURI != otherURI )
415 {
416 libNameConflict = true;
417 break;
418 }
419 }
420
421 if( libNameConflict )
422 {
423 msg = _( "A duplicate library name that references a different library exists "
424 "in the current library table. This conflict cannot be resolved and "
425 "may result in broken symbol library references.\n\n"
426 "Do you wish to continue?" );
427 wxMessageDialog msgDlg6( this, msg, _( "Continue Load Schematic" ),
428 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
429 wxCENTER | wxICON_QUESTION );
430 msgDlg6.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
431
432 if( msgDlg6.ShowModal() == wxID_CANCEL )
433 return false;
434 }
435 }
436
437 // All (most?) of the possible broken symbol library link cases are covered. Map the
438 // new appended schematic project symbol library table entries to the current project
439 // symbol library table.
440 if( !newLibNames.IsEmpty() && !table.IsEmpty() )
441 {
442 for( const wxString& libName : newLibNames )
443 {
444 if( !table.HasLibrary( libName )
445 || Prj().SchSymbolLibTable()->HasLibrary( libName ) )
446 {
447 continue;
448 }
449
450 // Don't expand environment variable because KIPRJMOD will not be correct
451 // for a different project.
452 wxString uri = table.GetFullURI( libName, false );
453 wxFileName newLib;
454
455 if( uri.Contains( "${KIPRJMOD}" ) || uri.Contains( "$(KIPRJMOD)" ) )
456 {
457 // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
458 // not expand to a valid symbol library path.
459 newLib.SetPath( fileName.GetPath() );
460 newLib.SetFullName( uri.AfterLast( '}' ) );
461 uri = newLib.GetFullPath();
462 }
463 else
464 {
465 uri = table.GetFullURI( libName );
466 }
467
468 // Add the library from the imported project to the current project
469 // symbol library table.
470 const SYMBOL_LIB_TABLE_ROW* row = table.FindRow( libName );
471
472 wxCHECK( row, false );
473
474 SYMBOL_LIB_TABLE_ROW* newRow = new SYMBOL_LIB_TABLE_ROW( libName, uri,
475 row->GetType(),
476 row->GetOptions(),
477 row->GetDescr() );
478
479 Prj().SchSymbolLibTable()->InsertRow( newRow );
480 libTableChanged = true;
481 }
482 }
483 }
484 }
485
486 SCH_SCREEN* newScreen = tmpSheet->GetScreen();
487 wxCHECK_MSG( newScreen, false, "No screen defined for sheet." );
488
489 if( libTableChanged )
490 {
491 Prj().SchSymbolLibTable()->Save( Prj().GetProjectPath() +
493 }
494
495 // Make the best attempt to set the symbol instance data for the loaded scheamtic.
496 if( newScreen->GetFileFormatVersionAtLoad() < 20221002 )
497 {
498 if( !newScreen->GetSymbolInstances().empty() )
499 {
500 // If the loaded schematic is a root sheet for another project, update the symbol
501 // instances.
502 sheetHierarchy.UpdateSymbolInstanceData( newScreen->GetSymbolInstances());
503 }
504 }
505
506 newScreen->MigrateSimModels();
507
508 // Attempt to create new symbol instances using the instance data loaded above.
509 sheetHierarchy.AddNewSymbolInstances( *aHierarchy );
510
511 // Add new sheet instance data.
512 sheetHierarchy.AddNewSheetInstances( *aHierarchy, hierarchy.GetLastVirtualPageNumber() );
513
514 // It is finally safe to add or append the imported schematic.
515 if( aSheet->GetScreen() == nullptr )
516 aSheet->SetScreen( newScreen );
517 else
518 aSheet->GetScreen()->Append( newScreen );
519
520 SCH_SCREENS allLoadedScreens( aSheet );
521 allLoadedScreens.ReplaceDuplicateTimeStamps();
522
523 return true;
524}
525
526
528 bool* aClearAnnotationNewItems )
529{
530 if( aSheet == nullptr || aHierarchy == nullptr )
531 return false;
532
533 // Get the new texts
534 DIALOG_SHEET_PROPERTIES dlg( this, aSheet, aClearAnnotationNewItems );
535
536 if( dlg.ShowModal() == wxID_CANCEL )
537 return false;
538
539 return true;
540}
541
542
544{
545 wxRect DrawArea;
546 BASE_SCREEN* screen = GetScreen();
547
548 DrawArea.SetSize( GetPageSizeIU() );
549
550 // Calculate a reasonable dc size, in pixels, and the dc scale to fit
551 // the drawings into the dc size
552 // scale is the ratio resolution (in PPI) / internal units
553 double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
554 double inch2Iu = 1000.0 * schIUScale.IU_PER_MILS;
555 double scale = ppi / inch2Iu;
556
557 wxSize dcsize = DrawArea.GetSize();
558
559 int maxdim = std::max( dcsize.x, dcsize.y );
560
561 // the max size in pixels of the bitmap used to build the sheet copy
562 const int maxbitmapsize = 5600;
563
564 while( int( maxdim * scale ) > maxbitmapsize )
565 {
566 ppi = ppi / 1.5;
567 scale = ppi / inch2Iu;
568 }
569
570 dcsize.x *= scale;
571 dcsize.y *= scale;
572
573 // Set draw offset, zoom... to values needed to draw in the memory DC
574 // after saving initial values:
575 VECTOR2I tmp_startvisu = screen->m_StartVisu;
576 VECTOR2I old_org = screen->m_DrawOrg;
577 screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
578 screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
579
580 wxMemoryDC dc;
581 wxBitmap image( dcsize );
582 dc.SelectObject( image );
583 dc.Clear();
584
585 GRResetPenAndBrush( &dc );
586 GRForceBlackPen( false );
587 dc.SetUserScale( scale, scale );
588
590
591 cfg->SetPrintDC( &dc );
592
593 // Init the color of the layer actually used to print the drawing sheet:
595
596 cfg->SetDefaultFont( eeconfig()->m_Appearance.default_font );
597
598 PrintPage( cfg );
599
600 {
601 wxLogNull doNotLog; // disable logging of failed clipboard actions
602
603 if( wxTheClipboard->Open() )
604 {
605 // This data objects are held by the clipboard, so do not delete them in the app.
606 wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
607 wxTheClipboard->SetData( clipbrd_data );
608 wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
609 wxTheClipboard->Close();
610 }
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
623bool 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
631 if( eeconfig()->m_Appearance.show_sheet_filename_case_sensitivity_dialog
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}
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.
const KIID m_Uuid
Definition: eda_item.h:492
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 SetDefaultFont(const wxString &aFont)
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void SetPrintDC(wxDC *aDC)
Store schematic specific render settings.
Definition: sch_painter.h:71
Definition: kiid.h:48
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:86
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()
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:623
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:543
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:527
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
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 const wxString & GetError() const
Return an error string to the caller.
Definition: sch_plugin.cpp:177
virtual SCH_SHEET * Load(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const STRING_UTF8_MAP *aProperties=nullptr)
Load information from some input file format that this SCH_PLUGIN implementation knows about,...
Definition: sch_plugin.cpp:51
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:638
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:144
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:110
const std::vector< SCH_SYMBOL_INSTANCE > & GetSymbolInstances() const
Definition: sch_screen.h:513
int GetFileFormatVersionAtLoad() const
Definition: sch_screen.h:129
void MigrateSimModels()
Migrate any symbols having V6 simulation models to their V7 equivalents.
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:145
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
int GetLastVirtualPageNumber() const
void UpdateSymbolInstanceData(const std::vector< SCH_SYMBOL_INSTANCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
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:57
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:308
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:106
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:300
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:352
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:325
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.