KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eeschema.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) 2004 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <pgm_base.h>
27#include <kiface_base.h>
30#include <confirm.h>
31#include <gestfich.h>
32#include <eda_dde.h>
34#include "eeschema_helpers.h"
35#include <eeschema_settings.h>
36#include <sch_edit_frame.h>
38#include <symbol_edit_frame.h>
39#include <symbol_viewer_frame.h>
45#include <kiway.h>
46#include <project_sch.h>
47#include <richio.h>
50#include <sexpr/sexpr.h>
51#include <sexpr/sexpr_parser.h>
52#include <trace_helpers.h>
53#include <thread_pool.h>
54#include <kiface_ids.h>
56#include <wx/ffile.h>
58
59#include <schematic.h>
60#include <connection_graph.h>
70#include <sim/simulator_frame.h>
71
73#include <toolbars_sch_editor.h>
75
76#include <wx/crt.h>
77
78// The main sheet of the project
80
81
82namespace SCH {
83
84
85// TODO: This should move out of this file
86static std::unique_ptr<SCHEMATIC> readSchematicFromFile( const std::string& aFilename )
87{
88 SCH_IO* pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD );
89 std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>( nullptr );
90
92
93 // TODO: this must load the schematic's project, not a default project. At the very minimum
94 // variable resolution won't work without the project, but there might also be issues with
95 // netclasses, etc.
96 manager.LoadProject( "" );
97 schematic->Reset();
98 schematic->SetProject( &manager.Prj() );
99 schematic->SetRoot( pi->LoadSchematicFile( aFilename, schematic.get() ) );
100
101 // Set current sheet to the first top-level sheet, not the virtual root
102 std::vector<SCH_SHEET*> topLevelSheets = schematic->GetTopLevelSheets();
103
104 if( !topLevelSheets.empty() )
105 {
106 schematic->CurrentSheet().push_back( topLevelSheets[0] );
107 wxLogTrace( traceSchCurrentSheet,
108 "Set current sheet to first top-level sheet: %s, path: %s",
109 topLevelSheets[0]->GetName(),
110 schematic->CurrentSheet().Path().AsString() );
111 }
112 else
113 {
114 wxLogWarning( "No top-level sheets found after loading schematic!" );
115 }
116
117 SCH_SCREENS screens( schematic->Root() );
118
119 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
120 screen->UpdateLocalLibSymbolLinks();
121
122 SCH_SHEET_LIST sheets = schematic->Hierarchy();
123
124 // Restore all of the loaded symbol instances from the root sheet screen.
125 sheets.UpdateSymbolInstanceData( schematic->RootScreen()->GetSymbolInstances() );
126
127 if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
128 {
129 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
130 screen->FixLegacyPowerSymbolMismatches();
131 }
132
133 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
134 screen->MigrateSimModels();
135
136 sheets.AnnotatePowerSymbols();
137
138 // NOTE: This is required for multi-unit symbols to be correct
139 for( SCH_SHEET_PATH& sheet : sheets )
140 sheet.UpdateAllScreenReferences();
141
142 // TODO: this must handle SchematicCleanup somehow. The original version didn't because
143 // it knew that QA test cases were saved in a clean state.
144
145 // TODO: does this need to handle PruneOrphanedSymbolInstances() and
146 // PruneOrphanedSheetInstances()?
147
148 schematic->ConnectionGraph()->Recalculate( sheets, true );
149
150 return schematic;
151}
152
153
154// TODO: This should move out of this file
155bool generateSchematicNetlist( const wxString& aFilename, std::string& aNetlist )
156{
157 std::unique_ptr<SCHEMATIC> schematic = readSchematicFromFile( aFilename.ToStdString() );
158 NETLIST_EXPORTER_KICAD exporter( schematic.get() );
159 STRING_FORMATTER formatter;
160
161 exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
162 aNetlist = formatter.GetString();
163
164 return true;
165}
166
167
168static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
169{
170 // Of course all are virtual overloads, implementations of the KIFACE.
171
172 IFACE( const char* aName, KIWAY::FACE_T aType ) :
173 KIFACE_BASE( aName, aType ),
176 {}
177
178 bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) override;
179
180 void Reset() override;
181
182 void OnKifaceEnd() override;
183
184 wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
185 {
186 switch( aClassId )
187 {
188 case FRAME_SCH:
189 {
190 SCH_EDIT_FRAME* frame = new SCH_EDIT_FRAME( aKiway, aParent );
191
193
194 if( Kiface().IsSingle() )
195 {
196 // only run this under single_top, not under a project manager.
198 }
199
200 return frame;
201 }
202
204 return new SYMBOL_EDIT_FRAME( aKiway, aParent );
205
206 case FRAME_SIMULATOR:
207 {
208 try
209 {
210 SIMULATOR_FRAME* frame = new SIMULATOR_FRAME( aKiway, aParent );
211 return frame;
212 }
213 catch( const SIMULATOR_INIT_ERR& )
214 {
215 // catch the init err exception as we don't want it to bubble up
216 // its going to be some ngspice install issue but we don't want to log that
217 return nullptr;
218 }
219 }
220
221 case FRAME_SCH_VIEWER:
222 return new SYMBOL_VIEWER_FRAME( aKiway, aParent );
223
225 {
226 bool cancelled = false;
227 SYMBOL_CHOOSER_FRAME* chooser = new SYMBOL_CHOOSER_FRAME( aKiway, aParent, cancelled );
228
229 if( cancelled )
230 {
231 chooser->Destroy();
232 return nullptr;
233 }
235 return chooser;
239 InvokeSchEditSymbolLibTable( aKiway, aParent );
240 // Dialog has completed; nothing to return.
241 return nullptr;
245 // Dialog has completed; nothing to return.
246 return nullptr;
247
249 return new PANEL_SYM_DISPLAY_OPTIONS( aParent, GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" ) );
250
252 {
254 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
255
256 if( !frame )
257 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
258
259 if( !frame )
260 frame = aKiway->Player( FRAME_SCH, false );
261
262 if( frame )
263 SetUserUnits( frame->GetUserUnits() );
264
265 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH_SYMBOL_EDITOR );
266 }
267
269 {
270 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
271
272 if( !frame )
273 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
274
275 if( !frame )
276 frame = aKiway->Player( FRAME_SCH, false );
277
278 if( frame )
279 SetUserUnits( frame->GetUserUnits() );
280
281 return new PANEL_SYM_EDITING_OPTIONS( aParent, this, frame );
282 }
283
285 {
286 APP_SETTINGS_BASE* cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" );
287 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SYMBOL_EDIT_TOOLBAR_SETTINGS>( "symbol_editor-toolbars" );
288
289 std::vector<TOOL_ACTION*> actions;
290 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
291
292 for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
293 actions.push_back( action );
294
295 for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList() )
296 controls.push_back( control );
297
298 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
299 }
300
301 case PANEL_SYM_COLORS:
302 return new PANEL_SYM_COLOR_SETTINGS( aParent );
303
305 return new PANEL_EESCHEMA_DISPLAY_OPTIONS( aParent, GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) );
306
307 case PANEL_SCH_GRIDS:
308 {
309 EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
310 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
311
312 if( !frame )
313 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
314
315 if( !frame )
316 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
317
318 if( frame )
319 SetUserUnits( frame->GetUserUnits() );
320
321 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH );
322 }
323
325 {
326 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
327
328 if( !frame )
329 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
330
331 if( !frame )
332 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
333
334 if( frame )
335 SetUserUnits( frame->GetUserUnits() );
336
337 return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, this, frame );
338 }
339
341 {
342 APP_SETTINGS_BASE* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
343 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SCH_EDIT_TOOLBAR_SETTINGS>( "eeschema-toolbars" );
344
345 std::vector<TOOL_ACTION*> actions;
346 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
347
348 for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
349 actions.push_back( action );
350
351 for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList() )
352 controls.push_back( control );
353
354 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
355 }
356
357 case PANEL_SCH_COLORS:
358 return new PANEL_EESCHEMA_COLOR_SETTINGS( aParent );
359
361 return new PANEL_TEMPLATE_FIELDNAMES( aParent, nullptr );
362
364 return new PANEL_SIMULATOR_PREFERENCES( aParent );
365
366 default:
367 return nullptr;
368 }
369 }
370
381 void* IfaceOrAddress( int aDataId ) override
382 {
383 switch( aDataId )
384 {
386 return (void*) generateSchematicNetlist;
387 }
388
389 return nullptr;
390 }
391
397 void SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
398 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
399 const wxString& aSrcFilePath, wxString& aErrors ) override;
400
401
402 int HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter ) override;
403
404 bool HandleJobConfig( JOB* aJob, wxWindow* aParent ) override;
405
406 void PreloadLibraries( KIWAY* aKiway ) override;
407 void ProjectChanged() override;
408
409private:
410 std::unique_ptr<EESCHEMA_JOBS_HANDLER> m_jobHandler;
411 std::shared_ptr<BACKGROUND_JOB> m_libraryPreloadBackgroundJob;
412 std::future<void> m_libraryPreloadReturn;
414 std::atomic_bool m_libraryPreloadAbort;
415
416} kiface( "eeschema", KIWAY::FACE_SCH );
417
418} // namespace
419
420using namespace SCH;
421
422
424
425
426// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
427// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
428KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
429{
430 return &kiface;
431}
432
433
434bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
435{
436 // This is process-level-initialization, not project-level-initialization of the DSO.
437 // Do nothing in here pertinent to a project!
439
440 // Register the symbol editor settings as well because they share a KiFACE and need to be
441 // loaded prior to use to avoid threading deadlocks
443 aProgram->GetSettingsManager().RegisterSettings( symSettings ); // manager takes ownership
444
445 // We intentionally register KifaceSettings after SYMBOL_EDITOR_SETTINGS
446 // In legacy configs, many settings were in a single editor config nd the migration routine
447 // for the main editor file will try and call into the now separate settings stores
448 // to move the settings into them
450
451 start_common( aCtlBits );
452
453 m_jobHandler = std::make_unique<EESCHEMA_JOBS_HANDLER>( aKiway );
454
456 {
457 m_jobHandler->SetReporter( &CLI_REPORTER::GetInstance() );
458 m_jobHandler->SetProgressReporter( &CLI_PROGRESS_REPORTER::GetInstance() );
459 }
460
461 return true;
462}
463
464
466{
467}
468
469
471{
472 constexpr static int interval = 150;
473 constexpr static int timeLimit = 120000;
474
475 wxCHECK( aKiway, /* void */ );
476
477 if( m_libraryPreloadInProgress.load() )
478 return;
479
481 Pgm().GetBackgroundJobMonitor().Create( _( "Loading Symbol Libraries" ) );
482
483 auto preload =
484 [this, aKiway]() -> void
485 {
486 std::shared_ptr<BACKGROUND_JOB_REPORTER> reporter =
488
490
491 int elapsed = 0;
492
493 reporter->Report( _( "Loading Symbol Libraries" ) );
494 adapter->AsyncLoad();
495
496 while( true )
497 {
498 if( m_libraryPreloadAbort.load() )
499 {
500 m_libraryPreloadAbort.store( false );
501 break;
502 }
503
504 std::this_thread::sleep_for( std::chrono::milliseconds( interval ) );
505
506 if( std::optional<float> loadStatus = adapter->AsyncLoadProgress() )
507 {
508 float progress = *loadStatus;
509 reporter->SetCurrentProgress( progress );
510
511 if( progress >= 1 )
512 break;
513 }
514 else
515 {
516 reporter->SetCurrentProgress( 1 );
517 break;
518 }
519
520 elapsed += interval;
521
522 if( elapsed > timeLimit )
523 break;
524 }
525
526 adapter->BlockUntilLoaded();
527
530 m_libraryPreloadInProgress.store( false );
531
532 std::string payload = "";
533 aKiway->ExpressMail( FRAME_SCH, MAIL_RELOAD_LIB, payload, nullptr, true );
534 aKiway->ExpressMail( FRAME_SCH_SYMBOL_EDITOR, MAIL_RELOAD_LIB, payload, nullptr, true );
535 aKiway->ExpressMail( FRAME_SCH_VIEWER, MAIL_RELOAD_LIB, payload, nullptr, true );
536 };
537
539 m_libraryPreloadInProgress.store( true );
540 m_libraryPreloadReturn = tp.submit_task( preload );
541}
542
543
545{
546 if( m_libraryPreloadInProgress.load() )
547 m_libraryPreloadAbort.store( true );
548}
549
550
552{
553 end_common();
554}
555
556
557static void traverseSEXPR( SEXPR::SEXPR* aNode,
558 const std::function<void( SEXPR::SEXPR* )>& aVisitor )
559{
560 aVisitor( aNode );
561
562 if( aNode->IsList() )
563 {
564 for( unsigned i = 0; i < aNode->GetNumberOfChildren(); i++ )
565 traverseSEXPR( aNode->GetChild( i ), aVisitor );
566 }
567}
568
569
570void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
571 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
572 const wxString& aSrcFilePath, wxString& aErrors )
573{
574 wxFileName destFile( aSrcFilePath );
575 wxString destPath = destFile.GetPathWithSep();
576 wxUniChar pathSep = wxFileName::GetPathSeparator();
577 wxString ext = destFile.GetExt();
578
579 if( destPath.StartsWith( aProjectBasePath + pathSep ) )
580 destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
581
582 destFile.SetPath( destPath );
583
588 {
589 if( destFile.GetName() == aProjectName )
590 {
591 destFile.SetName( aNewProjectName );
592 }
593 else if( destFile.GetName() == aNewProjectName )
594 {
595 wxString msg;
596
597 if( !aErrors.empty() )
598 aErrors += wxS( "\n" );
599
600 msg.Printf( _( "Cannot copy file '%s' as it will be overwritten by the new root "
601 "sheet file." ), destFile.GetFullPath() );
602 aErrors += msg;
603 return;
604 }
605
606 // Sheet paths when auto-generated are relative to the root, so those will stay
607 // pointing to whatever they were pointing at.
608 // The author can create their own absolute and relative sheet paths. Absolute
609 // sheet paths aren't an issue, and relative ones will continue to work as long
610 // as the author didn't include any '..'s. If they did, it's still not clear
611 // whether they should be adjusted or not (as the author may be duplicating an
612 // entire tree with several projects within it), so we leave this as an exercise
613 // to the author.
614
615 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
616 }
618 {
619 // Symbols are not project-specific. Keep their source names.
620 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
621 }
625 {
626 if( destFile.GetName() == aProjectName + wxS( "-cache" ) )
627 destFile.SetName( aNewProjectName + wxS( "-cache" ) );
628
629 if( destFile.GetName() == aProjectName + wxS( "-rescue" ) )
630 destFile.SetName( aNewProjectName + wxS( "-rescue" ) );
631
632 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
633 }
634 else if( ext == FILEEXT::NetlistFileExtension )
635 {
636 bool success = false;
637
638 if( destFile.GetName() == aProjectName )
639 destFile.SetName( aNewProjectName );
640
641 try
642 {
643 SEXPR::PARSER parser;
644 std::unique_ptr<SEXPR::SEXPR> sexpr( parser.ParseFromFile( TO_UTF8( aSrcFilePath ) ) );
645
646 traverseSEXPR( sexpr.get(), [&]( SEXPR::SEXPR* node )
647 {
648 if( node->IsList() && node->GetNumberOfChildren() > 1
649 && node->GetChild( 0 )->IsSymbol()
650 && node->GetChild( 0 )->GetSymbol() == "source" )
651 {
652 auto pathNode = dynamic_cast<SEXPR::SEXPR_STRING*>( node->GetChild( 1 ) );
653 auto symNode = dynamic_cast<SEXPR::SEXPR_SYMBOL*>( node->GetChild( 1 ) );
654 wxString path;
655
656 if( pathNode )
657 path = pathNode->m_value;
658 else if( symNode )
659 path = symNode->m_value;
660
661 if( path == aProjectName + wxS( ".sch" ) )
662 path = aNewProjectName + wxS( ".sch" );
663 else if( path == aProjectBasePath + "/" + aProjectName + wxS( ".sch" ) )
664 path = aNewProjectBasePath + "/" + aNewProjectName + wxS( ".sch" );
665 else if( path.StartsWith( aProjectBasePath ) )
666 path.Replace( aProjectBasePath, aNewProjectBasePath, false );
667
668 if( pathNode )
669 pathNode->m_value = path;
670 else if( symNode )
671 symNode->m_value = path;
672 }
673 } );
674
675 wxFFile destNetList( destFile.GetFullPath(), "wb" );
676
677 if( destNetList.IsOpened() )
678 success = destNetList.Write( sexpr->AsString( 0 ) );
679
680 // wxFFile dtor will close the file
681 }
682 catch( ... )
683 {
684 success = false;
685 }
686
687 if( !success )
688 {
689 wxString msg;
690
691 if( !aErrors.empty() )
692 aErrors += wxS( "\n" );
693
694 msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
695 aErrors += msg;
696 }
697 }
698 // TODO(JE) library tables - does this feature even need to exist?
699#if 0
700 else if( destFile.GetName() == FILEEXT::SymbolLibraryTableFileName )
701 {
702 SYMBOL_LIB_TABLE symbolLibTable;
703 symbolLibTable.Load( aSrcFilePath );
704
705 for( unsigned i = 0; i < symbolLibTable.GetCount(); i++ )
706 {
707 LIB_TABLE_ROW& row = symbolLibTable.At( i );
708 wxString uri = row.GetFullURI();
709
710 uri.Replace( wxS( "/" ) + aProjectName + wxS( "-cache.lib" ),
711 wxS( "/" ) + aNewProjectName + wxS( "-cache.lib" ) );
712 uri.Replace( wxS( "/" ) + aProjectName + wxS( "-rescue.lib" ),
713 wxS( "/" ) + aNewProjectName + wxS( "-rescue.lib" ) );
714 uri.Replace( wxS( "/" ) + aProjectName + wxS( ".lib" ),
715 wxS( "/" ) + aNewProjectName + wxS( ".lib" ) );
716
717 row.SetFullURI( uri );
718 }
719
720 try
721 {
722 symbolLibTable.Save( destFile.GetFullPath() );
723 }
724 catch( ... )
725 {
726 wxString msg;
727
728 if( !aErrors.empty() )
729 aErrors += "\n";
730
731 msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
732 aErrors += msg;
733 }
734 }
735#endif
736 else
737 {
738 wxFAIL_MSG( wxS( "Unexpected filetype for Eeschema::SaveFileAs()" ) );
739 }
740}
741
742
743int IFACE::HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter )
744{
745 return m_jobHandler->RunJob( aJob, aReporter, aProgressReporter );
746}
747
748
749bool IFACE::HandleJobConfig( JOB* aJob, wxWindow* aParent )
750{
751 return m_jobHandler->HandleJobConfig( aJob, aParent );
752}
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:114
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static std::list< TOOL_ACTION * > & GetActionList()
Return list of TOOL_ACTIONs.
static std::list< ACTION_TOOLBAR_CONTROL * > & GetCustomControlList()
Get the list of custom controls that could be used on toolbars.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
std::shared_ptr< BACKGROUND_JOB > Create(const wxString &aName)
Creates a background job with the given name.
void Remove(std::shared_ptr< BACKGROUND_JOB > job)
Removes the given background job from any lists and frees it.
static PROGRESS_REPORTER & GetInstance()
static REPORTER & GetInstance()
Definition reporter.cpp:129
The base frame for deriving all KiCad main window classes.
static void SetSchEditFrame(SCH_EDIT_FRAME *aSchEditFrame)
An simple container class that lets us dispatch output jobs to kifaces.
Definition job.h:183
A KIFACE implementation.
Definition kiface_base.h:39
KIFACE_BASE(const char *aKifaceName, KIWAY::FACE_T aId)
Definition kiface_base.h:67
void InitSettings(APP_SETTINGS_BASE *aSettings)
Definition kiface_base.h:97
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:95
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
int m_start_flags
flags provided in OnKifaceStart()
bool IsSingle() const
Is this KIFACE running under single_top?
void CreateServer(int service, bool local=true)
Definition eda_dde.cpp:43
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:292
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:403
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr, bool aFromOtherThread=false)
Send aPayload to aDestination from aSource.
Definition kiway.cpp:507
FACE_T
Known KIFACE implementations.
Definition kiway.h:298
@ FACE_SCH
eeschema DSO
Definition kiway.h:299
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition kiway.cpp:200
std::optional< float > AsyncLoadProgress() const
Returns async load progress between 0.0 and 1.0, or nullopt if load is not in progress.
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
void SetFullURI(const wxString &aFullURI)
Change the full URI for the library.
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...
Generate the KiCad netlist format supported by Pcbnew.
void Format(OUTPUTFORMATTER *aOutputFormatter, int aCtl)
Output this s-expression netlist into aOutputFormatter.
Container for data for KiCad programs.
Definition pgm_base.h:106
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
Definition pgm_base.h:134
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:128
A progress reporter interface for use in multi-threaded environments.
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Schematic editor (Eeschema) main window.
Base class that schematic file and library loading and saving plugins should derive from.
Definition sch_io.h:59
virtual SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load information from some input file format that this SCH_IO implementation knows about,...
Definition sch_io.cpp:67
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition sch_screen.h:728
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void AnnotatePowerSymbols()
Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list.
void UpdateSymbolInstanceData(const std::vector< SCH_SYMBOL_INSTANCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:47
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Take ownership of the pointer passed in.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
std::unique_ptr< SEXPR > ParseFromFile(const std::string &aFilename)
size_t GetNumberOfChildren() const
Definition sexpr.cpp:71
bool IsList() const
Definition sexpr.h:49
SEXPR * GetChild(size_t aIndex) const
Definition sexpr.cpp:49
The SIMULATOR_FRAME holds the main user-interface for running simulations.
Implement an OUTPUTFORMATTER to a memory buffer.
Definition richio.h:450
const std::string & GetString()
Definition richio.h:473
Symbol library viewer main window.
The symbol library editor main window.
An interface to the global shared library manager that is schematic-specific and linked to one projec...
void AsyncLoad() override
Loads all available libraries for this adapter type in the background.
UNITS_PROVIDER(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits)
EDA_UNITS GetUserUnits() const
void SetUserUnits(EDA_UNITS aUnits)
This file is part of the common library.
#define _(s)
DDE server & client.
#define KICAD_SCH_PORT_SERVICE_NUMBER
Eeschema listens on this port for commands from Pcbnew.
Definition eda_dde.h:43
EDA_UNITS
Definition eda_units.h:48
SCH_SHEET * g_RootSheet
Definition eeschema.cpp:79
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition eeschema.cpp:423
static void traverseSEXPR(SEXPR::SEXPR *aNode, const std::function< void(SEXPR::SEXPR *)> &aVisitor)
Definition eeschema.cpp:557
@ PANEL_SYM_EDIT_GRIDS
Definition frame_type.h:73
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:35
@ PANEL_SCH_FIELD_NAME_TEMPLATES
Definition frame_type.h:83
@ PANEL_SCH_TOOLBARS
Definition frame_type.h:82
@ FRAME_SCH_VIEWER
Definition frame_type.h:36
@ PANEL_SCH_DISP_OPTIONS
Definition frame_type.h:78
@ PANEL_SCH_SIMULATOR
Definition frame_type.h:84
@ FRAME_SCH
Definition frame_type.h:34
@ PANEL_SYM_TOOLBARS
Definition frame_type.h:76
@ FRAME_SIMULATOR
Definition frame_type.h:38
@ PANEL_SYM_EDIT_OPTIONS
Definition frame_type.h:74
@ PANEL_SCH_EDIT_OPTIONS
Definition frame_type.h:80
@ PANEL_SYM_DISP_OPTIONS
Definition frame_type.h:72
@ DIALOG_SCH_LIBRARY_TABLE
Definition frame_type.h:123
@ PANEL_SYM_COLORS
Definition frame_type.h:75
@ PANEL_SCH_GRIDS
Definition frame_type.h:79
@ PANEL_SCH_COLORS
Definition frame_type.h:81
@ DIALOG_DESIGN_BLOCK_LIBRARY_TABLE
Definition frame_type.h:122
@ FRAME_SYMBOL_CHOOSER
Definition frame_type.h:37
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
Definition gestfich.cpp:290
static const std::string LegacySchematicFileExtension
static const std::string NetlistFileExtension
static const std::string SymbolLibraryTableFileName
static const std::string SchematicSymbolFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string LegacySymbolLibFileExtension
static const std::string KiCadSymbolLibFileExtension
static const std::string BackupFileSuffix
static const std::string LegacySymbolDocumentFileExtension
const wxChar *const traceSchCurrentSheet
Flag to enable debug output of current sheet tracking in the schematic editor.
#define KIFACE_API
@ KIFACE_NETLIST_SCHEMATIC
Definition kiface_ids.h:56
#define KFCTL_CLI
Running as CLI app.
Definition kiway.h:164
#define KIFACE_GETTER
Definition kiway.h:110
@ MAIL_RELOAD_LIB
Definition mail_type.h:57
static std::unique_ptr< SCHEMATIC > readSchematicFromFile(const std::string &aFilename)
Definition eeschema.cpp:86
SCH::IFACE KIFACE_BASE, UNITS_PROVIDER kiface("eeschema", KIWAY::FACE_SCH)
bool generateSchematicNetlist(const wxString &aFilename, std::string &aNetlist)
Definition eeschema.cpp:155
#define GNL_ALL
@ GNL_OPT_KICAD
void InvokeEditDesignBlockLibTable(KIWAY *aKiway, wxWindow *aParent)
void InvokeSchEditSymbolLibTable(KIWAY *aKiway, wxWindow *aParent)
PGM_BASE & Pgm()
The global program "get" accessor.
Definition pgm_base.cpp:946
see class PGM_BASE
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
Implement a participant in the KIWAY alchemy.
Definition kiway.h:155
std::future< void > m_libraryPreloadReturn
Definition eeschema.cpp:412
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
Definition eeschema.cpp:434
std::shared_ptr< BACKGROUND_JOB > m_libraryPreloadBackgroundJob
Definition eeschema.cpp:411
void PreloadLibraries(KIWAY *aKiway) override
Definition eeschema.cpp:470
void SaveFileAs(const wxString &aProjectBasePath, const wxString &aProjectName, const wxString &aNewProjectBasePath, const wxString &aNewProjectName, const wxString &aSrcFilePath, wxString &aErrors) override
Saving a file under a different name is delegated to the various KIFACEs because the project doesn't ...
Definition eeschema.cpp:570
void ProjectChanged() override
Definition eeschema.cpp:544
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
Definition eeschema.cpp:184
std::atomic_bool m_libraryPreloadAbort
Definition eeschema.cpp:414
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition eeschema.cpp:172
void Reset() override
Reloads global state.
Definition eeschema.cpp:465
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
Definition eeschema.cpp:381
int HandleJob(JOB *aJob, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter) override
Definition eeschema.cpp:743
std::unique_ptr< EESCHEMA_JOBS_HANDLER > m_jobHandler
Definition eeschema.cpp:410
std::atomic_bool m_libraryPreloadInProgress
Definition eeschema.cpp:413
bool HandleJobConfig(JOB *aJob, wxWindow *aParent) override
Definition eeschema.cpp:749
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
Definition eeschema.cpp:551
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
static thread_pool * tp
BS::thread_pool< 0 > thread_pool
Definition thread_pool.h:31
wxLogTrace helper definitions.
Definition of file extensions used in Kicad.