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
27#include <pgm_base.h>
28#include <kiface_base.h>
31#include <confirm.h>
32#include <gestfich.h>
33#include <eda_dde.h>
35#include "eeschema_helpers.h"
36#include <eeschema_settings.h>
37#include <sch_edit_frame.h>
39#include <symbol_edit_frame.h>
40#include <symbol_viewer_frame.h>
46#include <kiway.h>
47#include <project_sch.h>
48#include <richio.h>
51#include <sexpr/sexpr.h>
52#include <sexpr/sexpr_parser.h>
53#include <string_utils.h>
54#include <trace_helpers.h>
55#include <thread_pool.h>
56#include <kiface_ids.h>
57#include <widgets/kistatusbar.h>
59#include <wx/ffile.h>
60#include <wx/tokenzr.h>
62
63#include <schematic.h>
64#include <connection_graph.h>
75#include <sim/simulator_frame.h>
76
78#include <toolbars_sch_editor.h>
80
81#include <wx/crt.h>
82
83// The main sheet of the project
85
86
87namespace SCH {
88
89
90// TODO: This should move out of this file
91static std::unique_ptr<SCHEMATIC> readSchematicFromFile( const std::string& aFilename )
92{
93 SCH_IO* pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD );
94 std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>( nullptr );
95
97
98 wxFileName pro( aFilename );
100 pro.MakeAbsolute();
101 wxString projectPath = pro.GetFullPath();
102
103 PROJECT* project = manager.GetProject( projectPath );
104
105 if( !project )
106 {
107 if( wxFileExists( projectPath ) )
108 {
109 // cli
110 manager.LoadProject( projectPath, true );
111 project = manager.GetProject( projectPath );
112 }
113 else
114 {
115 manager.LoadProject( "" );
116 }
117 }
118
119 schematic->Reset();
120 schematic->SetProject( project );
121 SCH_SHEET* rootSheet = pi->LoadSchematicFile( aFilename, schematic.get() );
122
123 if( !rootSheet )
124 return nullptr;
125
126 schematic->SetTopLevelSheets( { rootSheet } );
127
128 SCH_SCREENS screens( schematic->Root() );
129
130 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
131 screen->UpdateLocalLibSymbolLinks();
132
133 SCH_SHEET_LIST sheets = schematic->Hierarchy();
134
135 // Restore all of the loaded symbol instances from the root sheet screen.
136 sheets.UpdateSymbolInstanceData( schematic->RootScreen()->GetSymbolInstances() );
137
138 if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
139 {
140 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
141 screen->FixLegacyPowerSymbolMismatches();
142 }
143
144 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
145 screen->MigrateSimModels();
146
147 sheets.AnnotatePowerSymbols();
148
149 // NOTE: This is required for multi-unit symbols to be correct
150 for( SCH_SHEET_PATH& sheet : sheets )
151 sheet.UpdateAllScreenReferences();
152
153 // TODO: this must handle SchematicCleanup somehow. The original version didn't because
154 // it knew that QA test cases were saved in a clean state.
155
156 // TODO: does this need to handle PruneOrphanedSymbolInstances() and
157 // PruneOrphanedSheetInstances()?
158
159 schematic->ConnectionGraph()->Recalculate( sheets, true );
160
161 return schematic;
162}
163
164
165// TODO: This should move out of this file
166bool generateSchematicNetlist( const wxString& aFilename, std::string& aNetlist )
167{
168 std::unique_ptr<SCHEMATIC> schematic = readSchematicFromFile( aFilename.ToStdString() );
169 NETLIST_EXPORTER_KICAD exporter( schematic.get() );
170 STRING_FORMATTER formatter;
171
172 exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
173 aNetlist = formatter.GetString();
174
175 return true;
176}
177
178
179static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
180{
181 // Of course all are virtual overloads, implementations of the KIFACE.
182
183 IFACE( const char* aName, KIWAY::FACE_T aType ) :
184 KIFACE_BASE( aName, aType ),
187 {}
188
189 bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) override;
190
191 void Reset() override;
192
193 void OnKifaceEnd() override;
194
195 wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
196 {
197 switch( aClassId )
198 {
199 case FRAME_SCH:
200 {
201 SCH_EDIT_FRAME* frame = new SCH_EDIT_FRAME( aKiway, aParent );
202
204
205 if( Kiface().IsSingle() )
206 {
207 // only run this under single_top, not under a project manager.
209 }
210
211 return frame;
212 }
213
215 return new SYMBOL_EDIT_FRAME( aKiway, aParent );
216
217 case FRAME_SIMULATOR:
218 {
219 try
220 {
221 SIMULATOR_FRAME* frame = new SIMULATOR_FRAME( aKiway, aParent );
222 return frame;
223 }
224 catch( const SIMULATOR_INIT_ERR& )
225 {
226 // catch the init err exception as we don't want it to bubble up
227 // its going to be some ngspice install issue but we don't want to log that
228 return nullptr;
229 }
230 }
231
232 case FRAME_SCH_VIEWER:
233 return new SYMBOL_VIEWER_FRAME( aKiway, aParent );
234
236 {
237 bool cancelled = false;
238 SYMBOL_CHOOSER_FRAME* chooser = new SYMBOL_CHOOSER_FRAME( aKiway, aParent, cancelled );
239
240 if( cancelled )
241 {
242 chooser->Destroy();
243 return nullptr;
244 }
246 return chooser;
248
250 InvokeSchEditSymbolLibTable( aKiway, aParent );
251 // Dialog has completed; nothing to return.
252 return nullptr;
253
256 // Dialog has completed; nothing to return.
257 return nullptr;
260 return new PANEL_SYM_DISPLAY_OPTIONS( aParent, GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" ) );
261
263 {
265 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
266
267 if( !frame )
268 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
269
270 if( !frame )
271 frame = aKiway->Player( FRAME_SCH, false );
272
273 if( frame )
274 SetUserUnits( frame->GetUserUnits() );
275
276 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH_SYMBOL_EDITOR );
277 }
278
280 {
281 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
282
283 if( !frame )
284 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
285
286 if( !frame )
287 frame = aKiway->Player( FRAME_SCH, false );
288
289 if( frame )
290 SetUserUnits( frame->GetUserUnits() );
291
292 return new PANEL_SYM_EDITING_OPTIONS( aParent, this, frame );
293 }
294
296 {
297 APP_SETTINGS_BASE* cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" );
298 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SYMBOL_EDIT_TOOLBAR_SETTINGS>( "symbol_editor-toolbars" );
299
300 std::vector<TOOL_ACTION*> actions;
301 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
302
303 for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
304 actions.push_back( action );
305
306 for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList( FRAME_SCH_SYMBOL_EDITOR ) )
307 controls.push_back( control );
308
309 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
310 }
311
312 case PANEL_SYM_COLORS:
313 return new PANEL_SYM_COLOR_SETTINGS( aParent );
314
316 return new PANEL_EESCHEMA_DISPLAY_OPTIONS( aParent, GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) );
317
318 case PANEL_SCH_GRIDS:
319 {
320 EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
321 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
322
323 if( !frame )
324 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
325
326 if( !frame )
327 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
328
329 if( frame )
330 SetUserUnits( frame->GetUserUnits() );
331
332 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH );
333 }
334
336 {
337 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
338
339 if( !frame )
340 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
341
342 if( !frame )
343 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
344
345 if( frame )
346 SetUserUnits( frame->GetUserUnits() );
347
348 return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, this, frame );
349 }
350
352 {
353 APP_SETTINGS_BASE* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
354 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SCH_EDIT_TOOLBAR_SETTINGS>( "eeschema-toolbars" );
355
356 std::vector<TOOL_ACTION*> actions;
357 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
358
359 for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
360 actions.push_back( action );
361
362 for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList( FRAME_SCH ) )
363 controls.push_back( control );
364
365 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
366 }
367
368 case PANEL_SCH_COLORS:
369 return new PANEL_EESCHEMA_COLOR_SETTINGS( aParent );
370
372 return new PANEL_TEMPLATE_FIELDNAMES( aParent, nullptr );
373
375 {
376 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
377
378 if( !frame )
379 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
380
381 if( !frame )
382 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
383
384 return new class PANEL_SCH_DATA_SOURCES( aParent, frame );
385 }
386
388 return new PANEL_SIMULATOR_PREFERENCES( aParent );
389
390 default:
391 return nullptr;
392 }
393 }
394
405 void* IfaceOrAddress( int aDataId ) override
406 {
407 switch( aDataId )
408 {
410 return (void*) generateSchematicNetlist;
411 }
412
413 return nullptr;
414 }
415
421 void SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
422 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
423 const wxString& aSrcFilePath, wxString& aErrors ) override;
424
425
426 int HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter ) override;
427
428 bool HandleJobConfig( JOB* aJob, wxWindow* aParent ) override;
429
430 void PreloadLibraries( KIWAY* aKiway ) override;
431 void CancelPreload( bool aBlock = true ) override;
432 void ProjectChanged() override;
433
434private:
435 std::unique_ptr<EESCHEMA_JOBS_HANDLER> m_jobHandler;
436 std::shared_ptr<BACKGROUND_JOB> m_libraryPreloadBackgroundJob;
437 std::future<void> m_libraryPreloadReturn;
439 std::atomic_bool m_libraryPreloadAbort;
440
441} kiface( "eeschema", KIWAY::FACE_SCH );
442
443} // namespace
444
445using namespace SCH;
446
447
449
450
451// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
452// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
453KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
454{
455 return &kiface;
456}
457
458
459bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
460{
461 // This is process-level-initialization, not project-level-initialization of the DSO.
462 // Do nothing in here pertinent to a project!
464
465 // Register the symbol editor settings as well because they share a KiFACE and need to be
466 // loaded prior to use to avoid threading deadlocks
468 aProgram->GetSettingsManager().RegisterSettings( symSettings ); // manager takes ownership
469
470 // We intentionally register KifaceSettings after SYMBOL_EDITOR_SETTINGS
471 // In legacy configs, many settings were in a single editor config nd the migration routine
472 // for the main editor file will try and call into the now separate settings stores
473 // to move the settings into them
475
476 start_common( aCtlBits );
477
478 m_jobHandler = std::make_unique<EESCHEMA_JOBS_HANDLER>( aKiway );
479
481 {
482 m_jobHandler->SetReporter( &CLI_REPORTER::GetInstance() );
483 m_jobHandler->SetProgressReporter( &CLI_PROGRESS_REPORTER::GetInstance() );
484 }
485
486 return true;
487}
488
489
491{
492}
493
494
496{
497 constexpr static int interval = 150;
498 constexpr static int timeLimit = 120000;
499
500 wxCHECK( aKiway, /* void */ );
501
502 // Use compare_exchange to atomically check and set the flag to prevent race conditions
503 // when PreloadLibraries is called multiple times concurrently (e.g., from project manager
504 // and schematic editor both scheduling via CallAfter)
505 bool expected = false;
506
507 if( !m_libraryPreloadInProgress.compare_exchange_strong( expected, true ) )
508 return;
509
511
513 Pgm().GetBackgroundJobMonitor().Create( _( "Loading Symbol Libraries" ) );
514
515 auto preload =
516 [this, aKiway]() -> void
517 {
518 std::shared_ptr<BACKGROUND_JOB_REPORTER> reporter =
520
522
523 int elapsed = 0;
524
525 reporter->Report( _( "Loading Symbol Libraries" ) );
526 adapter->AsyncLoad();
527
528 while( true )
529 {
530 if( m_libraryPreloadAbort.load() )
531 {
532 m_libraryPreloadAbort.store( false );
533 break;
534 }
535
536 std::this_thread::sleep_for( std::chrono::milliseconds( interval ) );
537
538 if( std::optional<float> loadStatus = adapter->AsyncLoadProgress() )
539 {
540 float progress = *loadStatus;
541 reporter->SetCurrentProgress( progress );
542
543 if( progress >= 1 )
544 break;
545 }
546 else
547 {
548 reporter->SetCurrentProgress( 1 );
549 break;
550 }
551
552 elapsed += interval;
553
554 if( elapsed > timeLimit )
555 break;
556 }
557
558 adapter->BlockUntilLoaded();
559
560 // Collect library load errors for async reporting
561 wxString errors = adapter->GetLibraryLoadErrors();
562
563 wxLogTrace( traceLibraries, "eeschema PreloadLibraries: errors.IsEmpty()=%d, length=%zu",
564 errors.IsEmpty(), errors.length() );
565
566 std::vector<LOAD_MESSAGE> messages =
568
569 if( !messages.empty() )
570 {
571 wxLogTrace( traceLibraries, " -> collected %zu messages, calling AddLibraryLoadMessages",
572 messages.size() );
573 Pgm().AddLibraryLoadMessages( messages );
574 }
575 else
576 {
577 wxLogTrace( traceLibraries, " -> no errors from symbol libraries" );
578 }
579
582 m_libraryPreloadInProgress.store( false );
583
584 std::string payload = "";
585 aKiway->ExpressMail( FRAME_SCH, MAIL_RELOAD_LIB, payload, nullptr, true );
586 aKiway->ExpressMail( FRAME_SCH_SYMBOL_EDITOR, MAIL_RELOAD_LIB, payload, nullptr, true );
587 aKiway->ExpressMail( FRAME_SCH_VIEWER, MAIL_RELOAD_LIB, payload, nullptr, true );
588 };
589
591 m_libraryPreloadReturn = tp.submit_task( preload );
592}
593
594
595void IFACE::CancelPreload( bool aBlock )
596{
597 if( m_libraryPreloadInProgress.load() )
598 {
599 m_libraryPreloadAbort.store( true );
600
601 if( aBlock )
603 }
604}
605
606
608{
609 if( m_libraryPreloadInProgress.load() )
610 m_libraryPreloadAbort.store( true );
611}
612
613
615{
616 end_common();
617}
618
619
620void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
621 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
622 const wxString& aSrcFilePath, wxString& aErrors )
623{
624 wxFileName destFile( aSrcFilePath );
625 wxString destPath = destFile.GetPathWithSep();
626 wxUniChar pathSep = wxFileName::GetPathSeparator();
627 wxString ext = destFile.GetExt();
628
629 if( destPath.StartsWith( aProjectBasePath + pathSep ) )
630 destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
631
632 destFile.SetPath( destPath );
633
638 {
639 if( destFile.GetName() == aProjectName )
640 {
641 destFile.SetName( aNewProjectName );
642 }
643 else if( destFile.GetName() == aNewProjectName )
644 {
645 wxString msg;
646
647 if( !aErrors.empty() )
648 aErrors += wxS( "\n" );
649
650 msg.Printf( _( "Cannot copy file '%s' as it will be overwritten by the new root "
651 "sheet file." ), destFile.GetFullPath() );
652 aErrors += msg;
653 return;
654 }
655
656 CopySexprFile( aSrcFilePath, destFile.GetFullPath(),
657 [&]( const std::string& token, wxString& value ) -> bool
658 {
659 if( token == "project" && value == aProjectName )
660 {
661 value = aNewProjectName;
662 return true;
663 }
664
665 return false;
666 },
667 aErrors );
668 }
670 {
671 // Symbols are not project-specific. Keep their source names.
672 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
673 }
677 {
678 if( destFile.GetName() == aProjectName + wxS( "-cache" ) )
679 destFile.SetName( aNewProjectName + wxS( "-cache" ) );
680
681 if( destFile.GetName() == aProjectName + wxS( "-rescue" ) )
682 destFile.SetName( aNewProjectName + wxS( "-rescue" ) );
683
684 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
685 }
686 else if( ext == FILEEXT::NetlistFileExtension )
687 {
688 if( destFile.GetName() == aProjectName )
689 destFile.SetName( aNewProjectName );
690
691 CopySexprFile( aSrcFilePath, destFile.GetFullPath(),
692 [&]( const std::string& token, wxString& value ) -> bool
693 {
694 if( token == "source" )
695 {
696 for( const wxString& extension : { wxString( wxT( ".sch" ) ), wxString( wxT( ".kicad_sch" ) ) } )
697 {
698 if( value == aProjectName + extension )
699 {
700 value = aNewProjectName + extension;
701 return true;
702 }
703 else if( value == aProjectBasePath + "/" + aProjectName + extension )
704 {
705 value = aNewProjectBasePath + "/" + aNewProjectName + extension;
706 return true;
707 }
708 else if( value.StartsWith( aProjectBasePath ) )
709 {
710 value.Replace( aProjectBasePath, aNewProjectBasePath, false );
711 return true;
712 }
713 }
714 }
715
716 return false;
717 },
718 aErrors );
719 }
720 else if( destFile.GetName() == FILEEXT::SymbolLibraryTableFileName )
721 {
722 wxFileName libTableFn( aSrcFilePath );
723 LIBRARY_TABLE libTable( libTableFn, LIBRARY_TABLE_SCOPE::PROJECT );
724 libTable.SetPath( destFile.GetFullPath() );
725 libTable.SetType( LIBRARY_TABLE_TYPE::SYMBOL );
726
727 for( LIBRARY_TABLE_ROW& row : libTable.Rows() )
728 {
729 wxString uri = row.URI();
730
731 uri.Replace( wxS( "/" ) + aProjectName + wxS( "-cache.lib" ),
732 wxS( "/" ) + aNewProjectName + wxS( "-cache.lib" ) );
733 uri.Replace( wxS( "/" ) + aProjectName + wxS( "-rescue.lib" ),
734 wxS( "/" ) + aNewProjectName + wxS( "-rescue.lib" ) );
735 uri.Replace( wxS( "/" ) + aProjectName + wxS( ".lib" ),
736 wxS( "/" ) + aNewProjectName + wxS( ".lib" ) );
737
738 row.SetURI( uri );
739 }
740
741 libTable.Save().map_error(
742 [&]( const LIBRARY_ERROR& aError )
743 {
744 wxString msg;
745
746 if( !aErrors.empty() )
747 aErrors += wxT( "\n" );
748
749 msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
750 aErrors += msg;
751 } );
752 }
753 else
754 {
755 wxFAIL_MSG( wxS( "Unexpected filetype for Eeschema::SaveFileAs()" ) );
756 }
757}
758
759
760int IFACE::HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter )
761{
762 return m_jobHandler->RunJob( aJob, aReporter, aProgressReporter );
763}
764
765
766bool IFACE::HandleJobConfig( JOB* aJob, wxWindow* aParent )
767{
768 return m_jobHandler->HandleJobConfig( aJob, aParent );
769}
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(FRAME_T aContext)
Get the list of custom controls that could be used on a particular frame type.
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 CLI_PROGRESS_REPORTER & GetInstance()
static CLI_REPORTER & GetInstance()
Definition reporter.cpp:134
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:184
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)
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:295
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:407
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:505
FACE_T
Known KIFACE implementations.
Definition kiway.h:301
@ FACE_SCH
eeschema DSO
Definition kiway.h:302
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition kiway.cpp:207
std::optional< float > AsyncLoadProgress() const
Returns async load progress between 0.0 and 1.0, or nullopt if load is not in progress.
wxString GetLibraryLoadErrors() const
Returns all library load errors as newline-separated strings for display.
void AsyncLoad()
Loads all available libraries for this adapter type in the background.
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:109
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
Definition pgm_base.h:137
void ClearLibraryLoadMessages()
Clear library load messages from all registered status bars.
void AddLibraryLoadMessages(const std::vector< LOAD_MESSAGE > &aMessages)
Add library load messages to all registered status bars.
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:131
A progress reporter interface for use in multi-threaded environments.
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
Container for project specific data.
Definition project.h:65
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:749
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:48
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 * GetProject(const wxString &aFullPath) const
Retrieve a loaded project by name.
The SIMULATOR_FRAME holds the main user-interface for running simulations.
Simple error container for failure to init the simulation engine and ultimately abort the frame const...
Implement an OUTPUTFORMATTER to a memory buffer.
Definition richio.h:422
const std::string & GetString()
Definition richio.h:445
The symbol library editor main window.
An interface to the global shared library manager that is schematic-specific and linked to one projec...
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:84
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition eeschema.cpp:448
@ 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:125
@ PANEL_SCH_DATA_SOURCES
Definition frame_type.h:85
@ 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:124
@ FRAME_SYMBOL_CHOOSER
Definition frame_type.h:37
void CopySexprFile(const wxString &aSrcPath, const wxString &aDestPath, std::function< bool(const std::string &token, wxString &value)> aCallback, wxString &aErrors)
Definition gestfich.cpp:320
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
Definition gestfich.cpp:293
static const std::string LegacySchematicFileExtension
static const std::string NetlistFileExtension
static const std::string SymbolLibraryTableFileName
static const std::string ProjectFileExtension
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 traceLibraries
Flag to enable library table and library manager tracing.
#define KIFACE_API
@ KIFACE_NETLIST_SCHEMATIC
Definition kiface_ids.h:42
#define KFCTL_CLI
Running as CLI app.
Definition kiway.h:165
#define KIFACE_GETTER
Definition kiway.h:111
@ MAIL_RELOAD_LIB
Definition mail_type.h:57
static std::unique_ptr< SCHEMATIC > readSchematicFromFile(const std::string &aFilename)
Definition eeschema.cpp:91
SCH::IFACE KIFACE_BASE, UNITS_PROVIDER kiface("eeschema", KIWAY::FACE_SCH)
bool generateSchematicNetlist(const wxString &aFilename, std::string &aNetlist)
Definition eeschema.cpp:166
#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.
see class PGM_BASE
@ RPT_SEVERITY_ERROR
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
std::vector< LOAD_MESSAGE > ExtractLibraryLoadErrors(const wxString &aErrorString, int aSeverity)
Parse library load error messages, extracting user-facing information while stripping internal code l...
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:156
std::future< void > m_libraryPreloadReturn
Definition eeschema.cpp:437
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
Definition eeschema.cpp:459
std::shared_ptr< BACKGROUND_JOB > m_libraryPreloadBackgroundJob
Definition eeschema.cpp:436
void PreloadLibraries(KIWAY *aKiway) override
Definition eeschema.cpp:495
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:620
void ProjectChanged() override
Definition eeschema.cpp:607
void CancelPreload(bool aBlock=true) override
Definition eeschema.cpp:595
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
Definition eeschema.cpp:195
std::atomic_bool m_libraryPreloadAbort
Definition eeschema.cpp:439
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition eeschema.cpp:183
void Reset() override
Reloads global state.
Definition eeschema.cpp:490
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
Definition eeschema.cpp:405
int HandleJob(JOB *aJob, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter) override
Definition eeschema.cpp:760
std::unique_ptr< EESCHEMA_JOBS_HANDLER > m_jobHandler
Definition eeschema.cpp:435
std::atomic_bool m_libraryPreloadInProgress
Definition eeschema.cpp:438
bool HandleJobConfig(JOB *aJob, wxWindow *aParent) override
Definition eeschema.cpp:766
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
Definition eeschema.cpp:614
VECTOR3I expected(15, 30, 45)
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
static thread_pool * tp
BS::priority_thread_pool thread_pool
Definition thread_pool.h:31
wxLogTrace helper definitions.
Definition of file extensions used in Kicad.