KiCad PCB EDA Suite
Loading...
Searching...
No Matches
design_block_utils.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) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <pgm_base.h>
25#include <kiway.h>
26#include <design_block.h>
28#include <design_block_pane.h>
29#include <sch_edit_frame.h>
30#include <wx/choicdlg.h>
31#include <wx/msgdlg.h>
32#include <wx/textdlg.h>
34#include <paths.h>
35#include <env_paths.h>
36#include <common.h>
37#include <kidialog.h>
38#include <confirm.h>
39#include <tool/tool_manager.h>
40#include <ee_selection_tool.h>
42#include <nlohmann/json.hpp>
43
44
45bool checkOverwrite( SCH_EDIT_FRAME* aFrame, wxString& libname, wxString& newName )
46{
47 wxString msg = wxString::Format( _( "Design block '%s' already exists in library '%s'." ),
48 newName.GetData(), libname.GetData() );
49
50 if( OKOrCancelDialog( aFrame, _( "Confirmation" ), msg, _( "Overwrite existing design block?" ),
51 _( "Overwrite" ) )
52 != wxID_OK )
53 {
54 return false;
55 }
56
57 return true;
58}
59
60
62{
63 // If no project is loaded, always work with the global table
64 if( Prj().IsNullProject() )
65 {
67
68 if( aOptional )
69 {
70 wxMessageDialog dlg( this, _( "Add the library to the global library table?" ),
71 _( "Add To Global Library Table" ), wxYES_NO );
72
73 if( dlg.ShowModal() != wxID_OK )
74 ret = nullptr;
75 }
76
77 return ret;
78 }
79
80 wxArrayString libTableNames;
81 libTableNames.Add( _( "Global" ) );
82 libTableNames.Add( _( "Project" ) );
83
84 wxSingleChoiceDialog dlg( this, _( "Choose the Library Table to add the library to:" ),
85 _( "Add To Library Table" ), libTableNames );
86
87 if( aOptional )
88 {
89 dlg.FindWindow( wxID_CANCEL )->SetLabel( _( "Skip" ) );
90 dlg.FindWindow( wxID_OK )->SetLabel( _( "Add" ) );
91 }
92
93 if( dlg.ShowModal() != wxID_OK )
94 return nullptr;
95
96 switch( dlg.GetSelection() )
97 {
99 case 1: return Prj().DesignBlockLibs();
100 default: return nullptr;
101 }
102}
103
104
105wxString SCH_EDIT_FRAME::CreateNewDesignBlockLibrary( const wxString& aLibName,
106 const wxString& aProposedName )
107{
108 return createNewDesignBlockLibrary( aLibName, aProposedName, selectDesignBlockLibTable() );
109}
110
111
112wxString SCH_EDIT_FRAME::createNewDesignBlockLibrary( const wxString& aLibName,
113 const wxString& aProposedName,
114 DESIGN_BLOCK_LIB_TABLE* aTable )
115{
116 if( aTable == nullptr )
117 return wxEmptyString;
118
119 wxFileName fn;
120 bool doAdd = false;
121 bool isGlobal = ( aTable == &DESIGN_BLOCK_LIB_TABLE::GetGlobalLibTable() );
122 wxString initialPath = aProposedName;
123
124 if( initialPath.IsEmpty() )
125 initialPath = isGlobal ? PATHS::GetDefaultUserDesignBlocksPath() : Prj().GetProjectPath();
126
127 if( aLibName.IsEmpty() )
128 {
129 fn = initialPath;
130
133 initialPath ) )
134 {
135 return wxEmptyString;
136 }
137
138 doAdd = true;
139 }
140 else
141 {
143
144 if( !fn.IsAbsolute() )
145 {
146 fn.SetName( aLibName );
147 fn.MakeAbsolute( initialPath );
148 }
149 }
150
151 // We can save libs only using DESIGN_BLOCK_IO_MGR::KICAD_SEXP format (.pretty libraries)
153 wxString libPath = fn.GetFullPath();
154
155 try
156 {
158
159 bool writable = false;
160 bool exists = false;
161
162 try
163 {
164 writable = pi->IsLibraryWritable( libPath );
165 exists = fn.Exists();
166 }
167 catch( const IO_ERROR& )
168 {
169 // best efforts....
170 }
171
172 if( exists )
173 {
174 if( !writable )
175 {
176 wxString msg = wxString::Format( _( "Library %s is read only." ), libPath );
177 ShowInfoBarError( msg );
178 return wxEmptyString;
179 }
180 else
181 {
182 wxString msg = wxString::Format( _( "Library %s already exists." ), libPath );
183 KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
184 dlg.SetOKLabel( _( "Overwrite" ) );
185 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
186
187 if( dlg.ShowModal() == wxID_CANCEL )
188 return wxEmptyString;
189
190 pi->DeleteLibrary( libPath );
191 }
192 }
193
194 pi->CreateLibrary( libPath );
195 }
196 catch( const IO_ERROR& ioe )
197 {
198 DisplayError( this, ioe.What() );
199 return wxEmptyString;
200 }
201
202 if( doAdd )
203 AddDesignBlockLibrary( libPath, aTable );
204
205 return libPath;
206}
207
208
209bool SCH_EDIT_FRAME::AddDesignBlockLibrary( const wxString& aFilename,
210 DESIGN_BLOCK_LIB_TABLE* aTable )
211{
212 if( aTable == nullptr )
213 aTable = selectDesignBlockLibTable();
214
215 if( aTable == nullptr )
216 return wxEmptyString;
217
218 bool isGlobal = ( aTable == &DESIGN_BLOCK_LIB_TABLE::GetGlobalLibTable() );
219
220 wxFileName fn( aFilename );
221
222 if( aFilename.IsEmpty() )
223 {
227 {
228 return false;
229 }
230 }
231
232 wxString libPath = fn.GetFullPath();
233 wxString libName = fn.GetName();
234
235 if( libName.IsEmpty() )
236 return false;
237
238 // Open a dialog to ask for a description
239 wxString description = wxGetTextFromUser( _( "Enter a description for the library:" ),
240 _( "Library Description" ), wxEmptyString, this );
241
244
247
248 wxString type = DESIGN_BLOCK_IO_MGR::ShowType( lib_type );
249
250 // KiCad lib is our default guess. So it might not have the .blocks extension
251 // In this case, the extension is part of the library name
252 if( lib_type == DESIGN_BLOCK_IO_MGR::KICAD_SEXP
254 libName = fn.GetFullName();
255
256 // try to use path normalized to an environmental variable or project path
257 wxString normalizedPath = NormalizePath( libPath, &Pgm().GetLocalEnvVariables(), &Prj() );
258
259 try
260 {
262 libName, normalizedPath, type, wxEmptyString, description );
263 aTable->InsertRow( row );
264
265 if( isGlobal )
268 else
269 Prj().DesignBlockLibs()->Save( Prj().DesignBlockLibTblName() );
270 }
271 catch( const IO_ERROR& ioe )
272 {
273 DisplayError( this, ioe.What() );
274 return false;
275 }
276
277 LIB_ID libID( libName, wxEmptyString );
280
281 return true;
282}
283
284
285void SCH_EDIT_FRAME::SaveSheetAsDesignBlock( const wxString& aLibraryName,
286 SCH_SHEET_PATH& aSheetPath )
287{
288 // Make sure the user has selected a library to save into
290 {
291 DisplayError( this, _( "Please select a library to save the design block to." ) );
292 return;
293 }
294
295 // Just block all attempts to create design blocks with nested sheets at this point
296 std::vector<SCH_ITEM*> sheets;
297 aSheetPath.LastScreen()->GetSheets( &sheets );
298
299 if( !sheets.empty() )
300 {
301 DisplayError( this, _( "Design blocks with nested sheets are not supported." ) );
302 return;
303 }
304
305 DESIGN_BLOCK blk;
306 wxFileName fn = wxFileNameFromPath( aSheetPath.Last()->GetName() );
307
308 blk.SetLibId( LIB_ID( aLibraryName, fn.GetName() ) );
309
310 // Copy all fields from the sheet to the design block
311 std::vector<SCH_FIELD>& shFields = aSheetPath.Last()->GetFields();
312 nlohmann::ordered_map<wxString, wxString> dbFields;
313
314 for( int i = 0; i < (int) shFields.size(); i++ )
315 {
316 if( i == SHEETNAME || i == SHEETFILENAME )
317 continue;
318
319 dbFields[shFields[i].GetCanonicalName()] = shFields[i].GetText();
320 }
321
322 blk.SetFields( dbFields );
323
324 DIALOG_DESIGN_BLOCK_PROPERTIES dlg( this, &blk );
325
326 if( dlg.ShowModal() != wxID_OK )
327 return;
328
329 // Save a temporary copy of the schematic file, as the plugin is just going to move it
330 wxString tempFile = wxFileName::CreateTempFileName( "design_block" );
331 if( !saveSchematicFile( aSheetPath.Last(), tempFile ) )
332 {
333 DisplayError( this, _( "Error saving temporary schematic file to create design block." ) );
334 wxRemoveFile( tempFile );
335 return;
336 }
337
338 blk.SetSchematicFile( tempFile );
339
340 try
341 {
342 wxString libName = blk.GetLibId().GetLibNickname();
343 wxString newName = blk.GetLibId().GetLibItemName();
344
345 if( Prj().DesignBlockLibs()->DesignBlockExists( libName, newName ) )
346 if( !checkOverwrite( this, libName, newName ) )
347 return;
348
349 Prj().DesignBlockLibs()->DesignBlockSave( aLibraryName, &blk );
350 }
351 catch( const IO_ERROR& ioe )
352 {
353 DisplayError( this, ioe.What() );
354 }
355
356 // Clean up the temporary file
357 wxRemoveFile( tempFile );
358
361}
362
363
364void SCH_EDIT_FRAME::SaveSelectionAsDesignBlock( const wxString& aLibraryName )
365{
366 // Make sure the user has selected a library to save into
368 {
369 DisplayError( this, _( "Please select a library to save the design block to." ) );
370 return;
371 }
372
373 // Get all selected items
374 EE_SELECTION selection = m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
375
376 if( selection.Empty() )
377 {
378 DisplayError( this, _( "Please select some items to save as a design block." ) );
379 return;
380 }
381
382 // Just block all attempts to create design blocks with nested sheets at this point
383 if( selection.HasType( SCH_SHEET_T ) )
384 {
385 if( selection.Size() == 1 )
386 {
387 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( selection.Front() );
389
390 curPath.push_back( sheet );
391 SaveSheetAsDesignBlock( aLibraryName, curPath );
392 }
393 else
394 DisplayError( this, _( "Design blocks with nested sheets are not supported." ) );
395
396 return;
397 }
398
399 DESIGN_BLOCK blk;
400 wxFileName fn = wxFileNameFromPath( GetScreen()->GetFileName() );
401
402 blk.SetLibId( LIB_ID( aLibraryName, fn.GetName() ) );
403
404 DIALOG_DESIGN_BLOCK_PROPERTIES dlg( this, &blk );
405
406 if( dlg.ShowModal() != wxID_OK )
407 return;
408
409 // Create a temporary screen
410 SCH_SCREEN* tempScreen = new SCH_SCREEN( m_schematic );
411
412 // Copy the selected items to the temporary screen
413 for( EDA_ITEM* item : selection )
414 {
415 EDA_ITEM* copy = item->Clone();
416 tempScreen->Append( static_cast<SCH_ITEM*>( copy ) );
417 }
418
419 // Create a sheet for the temporary screen
420 SCH_SHEET* tempSheet = new SCH_SHEET( m_schematic );
421 tempSheet->SetScreen( tempScreen );
422
423 // Save a temporary copy of the schematic file, as the plugin is just going to move it
424 wxString tempFile = wxFileName::CreateTempFileName( "design_block" );
425 if( !saveSchematicFile( tempSheet, tempFile ) )
426 {
427 DisplayError( this, _( "Error saving temporary schematic file to create design block." ) );
428 wxRemoveFile( tempFile );
429 return;
430 }
431
432 blk.SetSchematicFile( tempFile );
433
434 try
435 {
436 wxString libName = blk.GetLibId().GetLibNickname();
437 wxString newName = blk.GetLibId().GetLibItemName();
438
439 if( Prj().DesignBlockLibs()->DesignBlockExists( libName, newName ) )
440 if( !checkOverwrite( this, libName, newName ) )
441 return;
442
443 Prj().DesignBlockLibs()->DesignBlockSave( aLibraryName, &blk );
444 }
445 catch( const IO_ERROR& ioe )
446 {
447 DisplayError( this, ioe.What() );
448 }
449
450 // Clean up the temporaries
451 wxRemoveFile( tempFile );
452 // This will also delete the screen
453 delete tempSheet;
454
457}
458
459
460bool SCH_EDIT_FRAME::DeleteDesignBlockLibrary( const wxString& aLibName, bool aConfirm )
461{
462 if( aLibName.IsEmpty() )
463 {
464 DisplayError( this, _( "Please select a library to delete." ) );
465 return false;
466 }
467
468 if( !Prj().DesignBlockLibs()->IsDesignBlockLibWritable( aLibName ) )
469 {
470 wxString msg = wxString::Format( _( "Library '%s' is read only." ), aLibName );
471 ShowInfoBarError( msg );
472 return false;
473 }
474
475 // Confirmation
476 wxString msg = wxString::Format( _( "Delete design block library '%s' from disk? This will "
477 "delete all design blocks within the library." ),
478 aLibName.GetData() );
479
480 if( aConfirm && !IsOK( this, msg ) )
481 return false;
482
483 try
484 {
486 }
487 catch( const IO_ERROR& ioe )
488 {
489 DisplayError( this, ioe.What() );
490 return false;
491 }
492
493 msg.Printf( _( "Design block library '%s' deleted" ), aLibName.GetData() );
494 SetStatusText( msg );
495
497
498 return true;
499}
500
501
502bool SCH_EDIT_FRAME::DeleteDesignBlockFromLibrary( const LIB_ID& aLibId, bool aConfirm )
503{
504 if( !aLibId.IsValid() )
505 return false;
506
507 wxString libname = aLibId.GetLibNickname();
508 wxString dbname = aLibId.GetLibItemName();
509
510 if( !Prj().DesignBlockLibs()->IsDesignBlockLibWritable( libname ) )
511 {
512 wxString msg = wxString::Format( _( "Library '%s' is read only." ), libname );
513 ShowInfoBarError( msg );
514 return false;
515 }
516
517 // Confirmation
518 wxString msg = wxString::Format( _( "Delete design block '%s' in library '%s' from disk?" ),
519 dbname.GetData(), libname.GetData() );
520
521 if( aConfirm && !IsOK( this, msg ) )
522 return false;
523
524 try
525 {
526 Prj().DesignBlockLibs()->DesignBlockDelete( libname, dbname );
527 }
528 catch( const IO_ERROR& ioe )
529 {
530 DisplayError( this, ioe.What() );
531 return false;
532 }
533
534 msg.Printf( _( "Design block '%s' deleted from library '%s'" ), dbname.GetData(),
535 libname.GetData() );
536
537 SetStatusText( msg );
538
540
541 return true;
542}
543
544
546{
547 if( !aLibId.IsValid() )
548 return false;
549
550 wxString libname = aLibId.GetLibNickname();
551 wxString dbname = aLibId.GetLibItemName();
552
553 if( !Prj().DesignBlockLibs()->IsDesignBlockLibWritable( libname ) )
554 {
555 wxString msg = wxString::Format( _( "Library '%s' is read only." ), libname );
556 ShowInfoBarError( msg );
557 return false;
558 }
559
560 DESIGN_BLOCK* designBlock = GetDesignBlock( aLibId, true, true );
561
562 if( !designBlock )
563 return false;
564
565 wxString originalName = designBlock->GetLibId().GetLibItemName();
566 DIALOG_DESIGN_BLOCK_PROPERTIES dlg( this, designBlock );
567
568 if( dlg.ShowModal() != wxID_OK )
569 return false;
570
571 wxString newName = designBlock->GetLibId().GetLibItemName();
572
573 try
574 {
575 if( originalName != newName )
576 {
577 if( Prj().DesignBlockLibs()->DesignBlockExists( libname, newName ) )
578 if( !checkOverwrite( this, libname, newName ) )
579 return false;
580
581 Prj().DesignBlockLibs()->DesignBlockSave( libname, designBlock );
582 Prj().DesignBlockLibs()->DesignBlockDelete( libname, originalName );
583 }
584 else
585 Prj().DesignBlockLibs()->DesignBlockSave( libname, designBlock );
586 }
587 catch( const IO_ERROR& ioe )
588 {
589 DisplayError( this, ioe.What() );
590 return false;
591 }
592
594 m_designBlocksPane->SelectLibId( designBlock->GetLibId() );
595
596 return true;
597}
598
599
601 wxWindow* aParent, bool aShowErrorMsg )
602{
603 wxCHECK_MSG( aLibTable, nullptr, wxS( "Invalid design block library table." ) );
604
605 DESIGN_BLOCK* designBlock = nullptr;
606
607 try
608 {
609 designBlock = aLibTable->DesignBlockLoadWithOptionalNickname( aLibId, true );
610 }
611 catch( const IO_ERROR& ioe )
612 {
613 if( aShowErrorMsg )
614 {
615 wxString msg = wxString::Format( _( "Error loading designblock %s from library '%s'." ),
616 aLibId.GetLibItemName().wx_str(),
617 aLibId.GetLibNickname().wx_str() );
618 DisplayErrorMessage( aParent, msg, ioe.What() );
619 }
620 }
621
622 return designBlock;
623}
624
625
626DESIGN_BLOCK* SCH_EDIT_FRAME::GetDesignBlock( const LIB_ID& aLibId, bool aUseCacheLib,
627 bool aShowErrorMsg )
628{
629 return SchGetDesignBlock( aLibId, Prj().DesignBlockLibs(), this, aShowErrorMsg );
630}
631
632
634{
636}
@ KICAD_SEXP
S-expression KiCad file format.
static const wxString ShowType(DESIGN_BLOCK_FILE_T aFileType)
static DESIGN_BLOCK_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
static DESIGN_BLOCK_IO * FindPlugin(DESIGN_BLOCK_FILE_T aFileType)
Hold a record identifying a library accessed by the appropriate design block library #PLUGIN object i...
void DesignBlockLibDelete(const wxString &aNickname)
static wxString GetGlobalTableFileName()
void DesignBlockDelete(const wxString &aNickname, const wxString &aDesignBlockName)
Delete the aDesignBlockName from the library given by aNickname.
SAVE_T DesignBlockSave(const wxString &aNickname, const DESIGN_BLOCK *aDesignBlock, bool aOverwrite=true)
Write aDesignBlock to an existing library given by aNickname.
DESIGN_BLOCK * DesignBlockLoadWithOptionalNickname(const LIB_ID &aDesignBlockId, bool aKeepUUID=false)
Load a design block having aDesignBlockId with possibly an empty nickname.
static DESIGN_BLOCK_LIB_TABLE & GetGlobalLibTable()
void SelectLibId(const LIB_ID &aLibId)
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
void SetSchematicFile(const wxString &aFile)
Definition: design_block.h:42
void SetLibId(const LIB_ID &aName)
Definition: design_block.h:32
void SetFields(nlohmann::ordered_map< wxString, wxString > &aFields)
Definition: design_block.h:44
const LIB_ID & GetLibId() const
Definition: design_block.h:33
int ShowModal() override
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: kidialog.h:43
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Definition: kidialog.cpp:51
int ShowModal() override
Definition: kidialog.cpp:95
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:172
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
static wxString GetDefaultUserDesignBlocksPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:109
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:135
virtual DESIGN_BLOCK_LIB_TABLE * DesignBlockLibs()
Return the table of design block libraries.
Definition: project.cpp:418
Schematic editor (Eeschema) main window.
void SaveSelectionAsDesignBlock(const wxString &aLibraryName)
bool EditDesignBlockProperties(const LIB_ID &aLibId)
wxString createNewDesignBlockLibrary(const wxString &aLibName, const wxString &aProposedName, DESIGN_BLOCK_LIB_TABLE *aTable)
Create a new library in the given table (presumed to be either the global or project library table).
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SaveSheetAsDesignBlock(const wxString &aLibraryName, SCH_SHEET_PATH &aSheetPath)
bool DeleteDesignBlockFromLibrary(const LIB_ID &aLibId, bool aConfirm)
SCHEMATIC * m_schematic
The currently loaded schematic.
SCH_SHEET_PATH & GetCurrentSheet() const
bool saveSchematicFile(SCH_SHEET *aSheet, const wxString &aSavePath)
Save aSheet to a schematic file.
DESIGN_BLOCK * GetDesignBlock(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load design block from design block library table.
DESIGN_BLOCK_LIB_TABLE * selectDesignBlockLibTable(bool aOptional=false)
Prompts a user to select global or project library tables.
bool AddDesignBlockLibrary(const wxString &aFilename, DESIGN_BLOCK_LIB_TABLE *aTable)
Add an existing library to either the global or project library table.
wxString CreateNewDesignBlockLibrary(const wxString &aLibName=wxEmptyString, const wxString &aProposedName=wxEmptyString)
If a library name is given, creates a new design block library in the project folder with the given n...
DESIGN_BLOCK_PANE * m_designBlocksPane
void UpdateDesignBlockOptions()
Design block panel options have changed and the panel needs to be refreshed.
bool DeleteDesignBlockLibrary(const wxString &aLibName, bool aConfirm)
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:153
void GetSheets(std::vector< SCH_ITEM * > *aItems) const
Similar to Items().OfType( SCH_SHEET_T ), but return the sheets in a deterministic order (L-R,...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SCREEN * LastScreen()
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:93
wxString GetName() const
Definition: sch_sheet.h:107
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:173
EDA_ITEM * Front() const
Definition: selection.h:172
bool HasType(KICAD_T aType) const
Checks if there is at least one item of requested kind.
Definition: selection.cpp:145
int Size() const
Returns the number of selected parts.
Definition: selection.h:116
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:110
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
bool empty() const
Definition: utf8.h:104
wxString wx_str() const
Definition: utf8.cpp:45
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
Definition: common.cpp:422
The common library.
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
Definition: confirm.cpp:143
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:250
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:195
This file is part of the common library.
DESIGN_BLOCK * SchGetDesignBlock(const LIB_ID &aLibId, DESIGN_BLOCK_LIB_TABLE *aLibTable, wxWindow *aParent, bool aShowErrorMsg)
bool checkOverwrite(SCH_EDIT_FRAME *aFrame, wxString &libname, wxString &newName)
#define _(s)
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
Definition: env_paths.cpp:71
static const std::string KiCadDesignBlockLibPathExtension
static wxString KiCadDesignBlockLibPathWildcard()
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition: io_mgr.h:33
PROJECT & Prj()
Definition: kicad.cpp:595
This file is part of the common library.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
@ SHEETNAME
Definition: sch_sheet.h:45
@ SHEETFILENAME
Definition: sch_sheet.h:46
@ SCH_SHEET_T
Definition: typeinfo.h:174
Definition of file extensions used in Kicad.