KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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>
29#include <math/vector2wx.h>
31#include <tool/tool_manager.h>
32#include <project_sch.h>
33#include <sch_edit_frame.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>
42#include <tool/actions.h>
43
44#include <wx/clipbrd.h>
45#include <wx/dcmemory.h>
46#include <wx/log.h>
47
48
50{
51 wxASSERT( aSheet && aHierarchy );
52
53 wxString msg;
54 SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // The full schematic sheet hierarchy.
55 SCH_SHEET_LIST sheetHierarchy( aSheet ); // This is the hierarchy of the loaded file.
56
57 wxFileName destFile = aHierarchy->LastScreen()->GetFileName();
58
59 // SCH_SCREEN object file paths are expected to be absolute. If this assert fires,
60 // something is seriously broken.
61 wxASSERT( destFile.IsAbsolute() );
62
63 if( hierarchy.TestForRecursion( sheetHierarchy, destFile.GetFullPath() ) )
64 {
65 msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
66 "has the sheet '%s' or one of its subsheets as a parent somewhere in the "
67 "schematic hierarchy." ),
68 destFile.GetFullPath() );
69 DisplayError( this, msg );
70 return true;
71 }
72
73 return false;
74}
75
76
78{
79 wxASSERT( aSheet && aSheet->GetScreen() );
80
81 wxString msg;
82 SCH_SCREENS newScreens( aSheet );
83
84 if( newScreens.HasNoFullyDefinedLibIds() )
85 {
86 msg.Printf( _( "The schematic '%s' has not had its symbol library links remapped "
87 "to the symbol library table. The project this schematic belongs to "
88 "must first be remapped before it can be imported into the current "
89 "project." ),
90 aSheet->GetScreen()->GetFileName() );
91 DisplayInfoMessage( this, msg );
92 return true;
93 }
94
95 return false;
96}
97
98
99void SCH_EDIT_FRAME::InitSheet( SCH_SHEET* aSheet, const wxString& aNewFilename )
100{
101 aSheet->SetScreen( new SCH_SCREEN( &Schematic() ) );
102 aSheet->GetScreen()->SetContentModified();
103 aSheet->GetScreen()->SetFileName( aNewFilename );
104}
105
106
108 const wxString& aFileName )
109{
110 wxASSERT( aSheet && aHierarchy );
111
112 wxString msg;
113 wxFileName currentSheetFileName;
114 bool libTableChanged = false;
115
116 SCH_IO_MGR::SCH_FILE_T schFileType = SCH_IO_MGR::GuessPluginTypeFromSchPath( aFileName );
117
118 if( schFileType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
119 schFileType = SCH_IO_MGR::SCH_KICAD;
120
121 SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( schFileType ) );
122 std::unique_ptr< SCH_SHEET> tmpSheet = std::make_unique<SCH_SHEET>( &Schematic() );
123
124 // This will cause the sheet UUID to be set to the UUID of the aSheet argument. This is
125 // required to ensure all of the sheet paths in any sub-sheets are correctly generated when
126 // using the temporary SCH_SHEET object that the file is loaded into..
127 const_cast<KIID&>( tmpSheet->m_Uuid ) = aSheet->m_Uuid;
128
129 wxFileName fileName( aFileName );
130
131 if( !fileName.IsAbsolute() && !fileName.MakeAbsolute() )
132 {
133 wxFAIL_MSG( wxString::Format( "Cannot make file name '%s' path absolute.", aFileName ) );
134 return false;
135 }
136
137 wxString fullFilename = fileName.GetFullPath();
138
139 try
140 {
141 if( aSheet->GetScreen() != nullptr )
142 {
143 tmpSheet.reset( pi->LoadSchematicFile( fullFilename, &Schematic() ) );
144 }
145 else
146 {
147 tmpSheet->SetFileName( fullFilename );
148 pi->LoadSchematicFile( fullFilename, &Schematic(), tmpSheet.get() );
149 }
150
151 if( !pi->GetError().IsEmpty() )
152 {
153 msg = _( "The entire schematic could not be loaded. Errors occurred attempting "
154 "to load hierarchical sheet schematics." );
155
156 wxMessageDialog msgDlg1( this, msg, _( "Schematic Load Error" ),
157 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
158 wxCENTER | wxICON_QUESTION );
159 msgDlg1.SetOKLabel( wxMessageDialog::ButtonLabel( _( "Use partial schematic" ) ) );
160 msgDlg1.SetExtendedMessage( pi->GetError() );
161
162 if( msgDlg1.ShowModal() == wxID_CANCEL )
163 return false;
164 }
165 }
166 catch( const IO_ERROR& ioe )
167 {
168 msg.Printf( _( "Error loading schematic '%s'." ), fullFilename );
169 DisplayErrorMessage( this, msg, ioe.What() );
170
171 msg.Printf( _( "Failed to load '%s'." ), fullFilename );
172 SetMsgPanel( wxEmptyString, msg );
173
174 return false;
175 }
176
177 // If the loaded schematic is in a different folder from the current project and
178 // it contains hierarchical sheets, the hierarchical sheet paths need to be updated.
179 if( fileName.GetPathWithSep() != Prj().GetProjectPath() && tmpSheet->CountSheets() )
180 {
181 SCH_SHEET_LIST loadedSheets( tmpSheet.get() );
182
183 for( const SCH_SHEET_PATH& sheetPath : loadedSheets )
184 {
185 // Skip the loaded sheet since the user already determined if the file path should
186 // be relative or absolute.
187 if( sheetPath.size() == 1 )
188 continue;
189
190 wxString lastSheetPath = fileName.GetPathWithSep();
191
192 for( unsigned i = 1; i < sheetPath.size(); i++ )
193 {
194 SCH_SHEET* sheet = sheetPath.at( i );
195 wxCHECK2( sheet, continue );
196
197 SCH_SCREEN* screen = sheet->GetScreen();
198 wxCHECK2( screen, continue );
199
200 // Use the screen file name which should always be absolute.
201 wxFileName loadedSheetFileName = screen->GetFileName();
202 wxCHECK2( loadedSheetFileName.IsAbsolute(), continue );
203
204 wxFileName tmp = loadedSheetFileName;
205 wxString sheetFileName;
206
207 if( tmp.MakeRelativeTo( lastSheetPath ) )
208 sheetFileName = tmp.GetFullPath();
209 else
210 sheetFileName = loadedSheetFileName.GetFullPath();
211
212 sheetFileName.Replace( wxT( "\\" ), wxT( "/" ) );
213 sheet->SetFileName( sheetFileName );
214 lastSheetPath = loadedSheetFileName.GetPath();
215 }
216 }
217 }
218
219 SCH_SHEET_LIST sheetHierarchy( tmpSheet.get() ); // This is the hierarchy of the loaded file.
220 SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // This is the schematic sheet hierarchy.
221
222 // Make sure any new sheet changes do not cause any recursion issues.
223 if( CheckSheetForRecursion( tmpSheet.get(), aHierarchy )
224 || checkForNoFullyDefinedLibIds( tmpSheet.get() ) )
225 {
226 return false;
227 }
228
229 // Make a valiant attempt to warn the user of all possible scenarios where there could
230 // be broken symbol library links.
231 wxArrayString names;
232 wxArrayString newLibNames;
233 SCH_SCREENS newScreens( tmpSheet.get() ); // All screens associated with the import.
234 SCH_SCREENS prjScreens( &Schematic().Root() );
235
236 newScreens.GetLibNicknames( names );
237
238 wxMessageDialog::ButtonLabel okButtonLabel( _( "Continue Load" ) );
239 wxMessageDialog::ButtonLabel cancelButtonLabel( _( "Cancel Load" ) );
240
241 // Prior to schematic file format 20221002, all symbol instance data was saved in the root
242 // sheet so loading a hierarchical sheet that is not the root sheet will have no symbol
243 // instance data. Give the user a chance to go back and save the project that contains this
244 // hierarchical sheet so the symbol instance data will be correct on load.
245 if( ( tmpSheet->GetScreen()->GetFileFormatVersionAtLoad() < 20221002 )
246 && tmpSheet->GetScreen()->GetSymbolInstances().empty() )
247 {
248 msg = _( "There are hierarchical sheets in the loaded schematic file from an older "
249 "file version resulting in missing symbol instance data. This will "
250 "result in all of the symbols in the loaded schematic to use either the "
251 "default instance setting or fall back to the library symbol settings. "
252 "Loading the project that uses this schematic file and saving to the "
253 "lastest file version will resolve this issue.\n\n"
254 "Do you wish to continue?" );
255 wxMessageDialog msgDlg7( this, msg, _( "Continue Load Schematic" ),
256 wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER | wxICON_QUESTION );
257 msgDlg7.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
258
259 if( msgDlg7.ShowModal() == wxID_CANCEL )
260 return false;
261 }
262
263 if( !prjScreens.HasSchematic( fullFilename ) )
264 {
265 if( fileName.GetPathWithSep() == Prj().GetProjectPath() )
266 {
267 // A schematic in the current project path that isn't part of the current project.
268 // It's possible the user copied this schematic from another project so the library
269 // links may not be available. Even this is check is no guarantee that all symbol
270 // library links are valid but it's better than nothing.
271 for( const wxString& name : names )
272 {
273 if( !PROJECT_SCH::SchSymbolLibTable( &Prj() )->HasLibrary( name ) )
274 newLibNames.Add( name );
275 }
276
277 if( !newLibNames.IsEmpty() )
278 {
279 msg = _( "There are library names in the selected schematic that are missing "
280 "from the current project library table. This may result in broken "
281 "symbol library references for the loaded schematic.\n\n"
282 "Do you wish to continue?" );
283 wxMessageDialog msgDlg3( this, msg, _( "Continue Load Schematic" ),
284 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
285 wxCENTER | wxICON_QUESTION );
286 msgDlg3.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
287
288 if( msgDlg3.ShowModal() == wxID_CANCEL )
289 return false;
290 }
291 }
292 else if( fileName.GetPathWithSep() != Prj().GetProjectPath() )
293 {
294 // A schematic loaded from a path other than the current project path.
295
296 // If there are symbol libraries in the imported schematic that are not in the
297 // symbol library table of this project, there could be a lot of broken symbol
298 // library links. Attempt to add the missing libraries to the project symbol
299 // library table.
300 wxArrayString duplicateLibNames;
301
302 for( const wxString& name : names )
303 {
304 if( !PROJECT_SCH::SchSymbolLibTable( &Prj() )->HasLibrary( name ) )
305 newLibNames.Add( name );
306 else
307 duplicateLibNames.Add( name );
308 }
309
310 SYMBOL_LIB_TABLE table;
311 wxFileName symLibTableFn( fileName.GetPath(),
313
314 // If there are any new or duplicate libraries, check to see if it's possible that
315 // there could be any missing libraries that would cause broken symbol library links.
316 if( !newLibNames.IsEmpty() || !duplicateLibNames.IsEmpty() )
317 {
318 if( !symLibTableFn.Exists() || !symLibTableFn.IsFileReadable() )
319 {
320 msg = _( "The selected file was created as part of a different project. "
321 "Linking the file to this project may result in missing or "
322 "incorrect symbol library references.\n\n"
323 "Do you wish to continue?" );
324 wxMessageDialog msgDlg4( this, msg, _( "Continue Load Schematic" ),
325 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
326 wxCENTER | wxICON_QUESTION );
327 msgDlg4.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
328
329 if( msgDlg4.ShowModal() == wxID_CANCEL )
330 return false;
331 }
332 else
333 {
334 try
335 {
336 table.Load( symLibTableFn.GetFullPath() );
337 }
338 catch( const IO_ERROR& ioe )
339 {
340 msg.Printf( _( "Error loading the symbol library table '%s'." ),
341 symLibTableFn.GetFullPath() );
342 DisplayErrorMessage( nullptr, msg, ioe.What() );
343 return false;
344 }
345 }
346 }
347
348 // Check to see if any of the symbol libraries found in the appended schematic do
349 // not exist in the current project are missing from the appended project symbol
350 // library table.
351 if( !newLibNames.IsEmpty() )
352 {
353 bool missingLibNames = table.IsEmpty();
354
355 if( !missingLibNames )
356 {
357 for( const wxString& newLibName : newLibNames )
358 {
359 if( !table.HasLibrary( newLibName ) )
360 {
361 missingLibNames = true;
362 break;
363 }
364 }
365 }
366
367 if( missingLibNames )
368 {
369 msg = _( "There are symbol library names in the selected schematic that "
370 "are missing from the selected schematic project library table. "
371 "This may result in broken symbol library references.\n\n"
372 "Do you wish to continue?" );
373 wxMessageDialog msgDlg5( this, msg, _( "Continue Load Schematic" ),
374 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
375 wxCENTER | wxICON_QUESTION );
376 msgDlg5.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
377
378 if( msgDlg5.ShowModal() == wxID_CANCEL )
379 return false;
380 }
381 }
382
383 // The library name already exists in the current project. Check to see if the
384 // duplicate name is the same library in the current project. If it's not, it's
385 // most likely that the symbol library links will be broken.
386 if( !duplicateLibNames.IsEmpty() && !table.IsEmpty() )
387 {
388 bool libNameConflict = false;
389
390 for( const wxString& duplicateLibName : duplicateLibNames )
391 {
392 const SYMBOL_LIB_TABLE_ROW* thisRow = nullptr;
393 const SYMBOL_LIB_TABLE_ROW* otherRow = nullptr;
394
395 if( PROJECT_SCH::SchSymbolLibTable( &Prj() )->HasLibrary( duplicateLibName ) )
396 thisRow = PROJECT_SCH::SchSymbolLibTable( &Prj() )->FindRow( duplicateLibName );
397
398 if( table.HasLibrary( duplicateLibName ) )
399 otherRow = table.FindRow( duplicateLibName );
400
401 // It's in the global library table so there is no conflict.
402 if( thisRow && !otherRow )
403 continue;
404
405 if( !thisRow || !otherRow )
406 continue;
407
408 wxFileName otherUriFileName;
409 wxString thisURI = thisRow->GetFullURI( true );
410 wxString otherURI = otherRow->GetFullURI( false);
411
412 if( otherURI.Contains( "${KIPRJMOD}" ) || otherURI.Contains( "$(KIPRJMOD)" ) )
413 {
414 // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
415 // not expand to a valid symbol library path.
416 otherUriFileName.SetPath( fileName.GetPath() );
417 otherUriFileName.SetFullName( otherURI.AfterLast( '}' ) );
418 otherURI = otherUriFileName.GetFullPath();
419 }
420
421 if( thisURI != otherURI )
422 {
423 libNameConflict = true;
424 break;
425 }
426 }
427
428 if( libNameConflict )
429 {
430 msg = _( "A duplicate library name that references a different library exists "
431 "in the current library table. This conflict cannot be resolved and "
432 "may result in broken symbol library references.\n\n"
433 "Do you wish to continue?" );
434 wxMessageDialog msgDlg6( this, msg, _( "Continue Load Schematic" ),
435 wxOK | wxCANCEL | wxCANCEL_DEFAULT |
436 wxCENTER | wxICON_QUESTION );
437 msgDlg6.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
438
439 if( msgDlg6.ShowModal() == wxID_CANCEL )
440 return false;
441 }
442 }
443
444 // All (most?) of the possible broken symbol library link cases are covered. Map the
445 // new appended schematic project symbol library table entries to the current project
446 // symbol library table.
447 if( !newLibNames.IsEmpty() && !table.IsEmpty() )
448 {
449 for( const wxString& libName : newLibNames )
450 {
451 if( !table.HasLibrary( libName )
452 || PROJECT_SCH::SchSymbolLibTable( &Prj() )->HasLibrary( libName ) )
453 {
454 continue;
455 }
456
457 // Don't expand environment variable because KIPRJMOD will not be correct
458 // for a different project.
459 wxString uri = table.GetFullURI( libName, false );
460 wxFileName newLib;
461
462 if( uri.Contains( "${KIPRJMOD}" ) || uri.Contains( "$(KIPRJMOD)" ) )
463 {
464 // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
465 // not expand to a valid symbol library path.
466 newLib.SetPath( fileName.GetPath() );
467 newLib.SetFullName( uri.AfterLast( '}' ) );
468 uri = newLib.GetFullPath();
469 }
470 else
471 {
472 uri = table.GetFullURI( libName );
473 }
474
475 // Add the library from the imported project to the current project
476 // symbol library table.
477 const SYMBOL_LIB_TABLE_ROW* row = table.FindRow( libName );
478
479 wxCHECK( row, false );
480
481 SYMBOL_LIB_TABLE_ROW* newRow = new SYMBOL_LIB_TABLE_ROW( libName, uri,
482 row->GetType(),
483 row->GetOptions(),
484 row->GetDescr() );
485
487 libTableChanged = true;
488 }
489 }
490 }
491 }
492
493 SCH_SCREEN* newScreen = tmpSheet->GetScreen();
494 wxCHECK_MSG( newScreen, false, "No screen defined for sheet." );
495
496 if( libTableChanged )
497 {
498 PROJECT_SCH::SchSymbolLibTable( &Prj() )->Save( Prj().GetProjectPath() +
500 }
501
502 // Make the best attempt to set the symbol instance data for the loaded scheamtic.
503 if( newScreen->GetFileFormatVersionAtLoad() < 20221002 )
504 {
505 if( !newScreen->GetSymbolInstances().empty() )
506 {
507 // If the loaded schematic is a root sheet for another project, update the symbol
508 // instances.
509 sheetHierarchy.UpdateSymbolInstanceData( newScreen->GetSymbolInstances());
510 }
511 }
512
513 newScreen->MigrateSimModels();
514
515 // Attempt to create new symbol instances using the instance data loaded above.
516 sheetHierarchy.AddNewSymbolInstances( *aHierarchy );
517
518 // Add new sheet instance data.
519 sheetHierarchy.AddNewSheetInstances( *aHierarchy, hierarchy.GetLastVirtualPageNumber() );
520
521 // It is finally safe to add or append the imported schematic.
522 if( aSheet->GetScreen() == nullptr )
523 aSheet->SetScreen( newScreen );
524 else
525 aSheet->GetScreen()->Append( newScreen );
526
527 SCH_SCREENS allLoadedScreens( aSheet );
528 allLoadedScreens.ReplaceDuplicateTimeStamps();
529
530 return true;
531}
532
533
535 bool* aClearAnnotationNewItems )
536{
537 if( aSheet == nullptr || aHierarchy == nullptr )
538 return false;
539
540 // Get the new texts
541 DIALOG_SHEET_PROPERTIES dlg( this, aSheet, aClearAnnotationNewItems );
542
543 if( dlg.ShowModal() == wxID_CANCEL )
544 return false;
545
546 return true;
547}
548
549
551{
552 wxRect drawArea;
553 BASE_SCREEN* screen = GetScreen();
554
555 drawArea.SetSize( ToWxSize( GetPageSizeIU() ) );
556
557 // Calculate a reasonable dc size, in pixels, and the dc scale to fit
558 // the drawings into the dc size
559 // scale is the ratio resolution (in PPI) / internal units
560 double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
561 double inch2Iu = 1000.0 * schIUScale.IU_PER_MILS;
562 double scale = ppi / inch2Iu;
563
564 wxSize dcsize = drawArea.GetSize();
565
566 int maxdim = std::max( dcsize.x, dcsize.y );
567
568 // the max size in pixels of the bitmap used to build the sheet copy
569 const int maxbitmapsize = 5600;
570
571 while( int( maxdim * scale ) > maxbitmapsize )
572 {
573 ppi = ppi / 1.5;
574 scale = ppi / inch2Iu;
575 }
576
577 dcsize.x *= scale;
578 dcsize.y *= scale;
579
580 // Set draw offset, zoom... to values needed to draw in the memory DC
581 // after saving initial values:
582 VECTOR2I tmp_startvisu = screen->m_StartVisu;
583 VECTOR2I old_org = screen->m_DrawOrg;
584 screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
585 screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
586
587 wxMemoryDC dc;
588 wxBitmap image( dcsize );
589 dc.SelectObject( image );
590 dc.Clear();
591
592 GRResetPenAndBrush( &dc );
593 GRForceBlackPen( false );
594 dc.SetUserScale( scale, scale );
595
597
598 cfg->SetPrintDC( &dc );
599
600 // Init the color of the layer actually used to print the drawing sheet:
602
603 cfg->SetDefaultFont( eeconfig()->m_Appearance.default_font );
604
605 PrintPage( cfg );
606
607 // Deselect Bitmap from DC before using the bitmap
608 dc.SelectObject( wxNullBitmap );
609
610 {
611 wxLogNull doNotLog; // disable logging of failed clipboard actions
612
613 if( wxTheClipboard->Open() )
614 {
615 // This data objects are held by the clipboard, so do not delete them in the app.
616 wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
617 wxTheClipboard->SetData( clipbrd_data );
618 wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
619 wxTheClipboard->Close();
620 }
621 }
622
623 GRForceBlackPen( false );
624
625 screen->m_StartVisu = tmp_startvisu;
626 screen->m_DrawOrg = old_org;
627}
628
629
630bool SCH_EDIT_FRAME::AllowCaseSensitiveFileNameClashes( const wxString& aSchematicFileName )
631{
632 wxString msg;
633 SCH_SCREENS screens( Schematic().Root() );
634 wxFileName fn = aSchematicFileName;
635
636 wxCHECK( fn.IsAbsolute(), false );
637
638 if( eeconfig()->m_Appearance.show_sheet_filename_case_sensitivity_dialog
639 && screens.CanCauseCaseSensitivityIssue( aSchematicFileName ) )
640 {
641 msg.Printf( _( "The file name '%s' can cause issues with an existing file name\n"
642 "already defined in the schematic on systems that support case\n"
643 "insensitive file names. This will cause issues if you copy this\n"
644 "project to an operating system that supports case insensitive file\n"
645 "names.\n\nDo you wish to continue?" ),
646 fn.GetName() );
647
648 wxRichMessageDialog dlg( this, msg, _( "Warning" ),
649 wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION );
650 dlg.ShowCheckBox( _( "Do not show this message again." ) );
651 dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Create New Sheet" ) ),
652 wxMessageDialog::ButtonLabel( _( "Discard New Sheet" ) ) );
653
654 if( dlg.ShowModal() == wxID_NO )
655 return false;
656
658 !dlg.IsCheckBoxChecked();
659 }
660
661 return true;
662}
const char * name
Definition: DXF_plotter.cpp:57
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:482
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:49
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.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
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.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:100
const VECTOR2I 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:107
bool AllowCaseSensitiveFileNameClashes(const wxString &aSchematicFileName)
Check aSchematicFileName for a potential file name case sensitivity clashes.
Definition: sheet.cpp:630
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:99
bool CheckSheetForRecursion(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
Verify that aSheet will not cause a recursion error in aHierarchy.
Definition: sheet.cpp:49
SCHEMATIC & Schematic() const
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:550
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:77
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:534
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, int aCtl=0)
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:530
virtual const wxString & GetError() const
Return an error string to the caller.
Definition: sch_plugin.cpp:214
virtual SCH_SHEET * LoadSchematicFile(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:124
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:673
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.
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:152
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:117
const std::vector< SCH_SYMBOL_INSTANCE > & GetSymbolInstances() const
Definition: sch_screen.h:515
int GetFileFormatVersionAtLoad() const
Definition: sch_screen.h:129
void MigrateSimModels()
Migrate any symbols having V6 simulation models to their V7 equivalents.
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:318
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:110
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:161
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:332
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:305
This file is part of the common library.
#define _(s)
void GRForceBlackPen(bool flagforce)
Definition: gr_basic.cpp:159
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:73
PROJECT & Prj()
Definition: kicad.cpp:571
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:218
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:388
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
wxSize ToWxSize(const VECTOR2I &aSize)
Definition: vector2wx.h:55
Definition of file extensions used in Kicad.