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 // TODO: this must load the schematic's project, not a default project. At the very minimum
99 // variable resolution won't work without the project, but there might also be issues with
100 // netclasses, etc.
101 manager.LoadProject( "" );
102 schematic->Reset();
103 schematic->SetProject( &manager.Prj() );
104 SCH_SHEET* rootSheet = pi->LoadSchematicFile( aFilename, schematic.get() );
105
106 if( !rootSheet )
107 return nullptr;
108
109 schematic->SetTopLevelSheets( { rootSheet } );
110
111 SCH_SCREENS screens( schematic->Root() );
112
113 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
114 screen->UpdateLocalLibSymbolLinks();
115
116 SCH_SHEET_LIST sheets = schematic->Hierarchy();
117
118 // Restore all of the loaded symbol instances from the root sheet screen.
119 sheets.UpdateSymbolInstanceData( schematic->RootScreen()->GetSymbolInstances() );
120
121 if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
122 {
123 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
124 screen->FixLegacyPowerSymbolMismatches();
125 }
126
127 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
128 screen->MigrateSimModels();
129
130 sheets.AnnotatePowerSymbols();
131
132 // NOTE: This is required for multi-unit symbols to be correct
133 for( SCH_SHEET_PATH& sheet : sheets )
134 sheet.UpdateAllScreenReferences();
135
136 // TODO: this must handle SchematicCleanup somehow. The original version didn't because
137 // it knew that QA test cases were saved in a clean state.
138
139 // TODO: does this need to handle PruneOrphanedSymbolInstances() and
140 // PruneOrphanedSheetInstances()?
141
142 schematic->ConnectionGraph()->Recalculate( sheets, true );
143
144 return schematic;
145}
146
147
148// TODO: This should move out of this file
149bool generateSchematicNetlist( const wxString& aFilename, std::string& aNetlist )
150{
151 std::unique_ptr<SCHEMATIC> schematic = readSchematicFromFile( aFilename.ToStdString() );
152 NETLIST_EXPORTER_KICAD exporter( schematic.get() );
153 STRING_FORMATTER formatter;
154
155 exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
156 aNetlist = formatter.GetString();
157
158 return true;
159}
160
161
162static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
163{
164 // Of course all are virtual overloads, implementations of the KIFACE.
165
166 IFACE( const char* aName, KIWAY::FACE_T aType ) :
167 KIFACE_BASE( aName, aType ),
170 {}
171
172 bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) override;
173
174 void Reset() override;
175
176 void OnKifaceEnd() override;
177
178 wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
179 {
180 switch( aClassId )
181 {
182 case FRAME_SCH:
183 {
184 SCH_EDIT_FRAME* frame = new SCH_EDIT_FRAME( aKiway, aParent );
185
187
188 if( Kiface().IsSingle() )
189 {
190 // only run this under single_top, not under a project manager.
192 }
193
194 return frame;
195 }
196
198 return new SYMBOL_EDIT_FRAME( aKiway, aParent );
199
200 case FRAME_SIMULATOR:
201 {
202 try
203 {
204 SIMULATOR_FRAME* frame = new SIMULATOR_FRAME( aKiway, aParent );
205 return frame;
206 }
207 catch( const SIMULATOR_INIT_ERR& )
208 {
209 // catch the init err exception as we don't want it to bubble up
210 // its going to be some ngspice install issue but we don't want to log that
211 return nullptr;
212 }
213 }
214
215 case FRAME_SCH_VIEWER:
216 return new SYMBOL_VIEWER_FRAME( aKiway, aParent );
217
219 {
220 bool cancelled = false;
221 SYMBOL_CHOOSER_FRAME* chooser = new SYMBOL_CHOOSER_FRAME( aKiway, aParent, cancelled );
222
223 if( cancelled )
225 chooser->Destroy();
226 return nullptr;
227 }
228
229 return chooser;
230 }
231
233 InvokeSchEditSymbolLibTable( aKiway, aParent );
234 // Dialog has completed; nothing to return.
235 return nullptr;
236
238 InvokeEditDesignBlockLibTable( aKiway, aParent );
239 // Dialog has completed; nothing to return.
240 return nullptr;
241
243 return new PANEL_SYM_DISPLAY_OPTIONS( aParent, GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" ) );
244
246 {
248 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
250 if( !frame )
251 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
252
253 if( !frame )
254 frame = aKiway->Player( FRAME_SCH, false );
256 if( frame )
259 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH_SYMBOL_EDITOR );
260 }
261
263 {
264 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
265
266 if( !frame )
267 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
268
269 if( !frame )
270 frame = aKiway->Player( FRAME_SCH, false );
271
272 if( frame )
273 SetUserUnits( frame->GetUserUnits() );
274
275 return new PANEL_SYM_EDITING_OPTIONS( aParent, this, frame );
276 }
277
279 {
280 APP_SETTINGS_BASE* cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" );
281 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SYMBOL_EDIT_TOOLBAR_SETTINGS>( "symbol_editor-toolbars" );
282
283 std::vector<TOOL_ACTION*> actions;
284 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
285
286 for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
287 actions.push_back( action );
288
289 for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList( FRAME_SCH_SYMBOL_EDITOR ) )
290 controls.push_back( control );
291
292 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
293 }
294
295 case PANEL_SYM_COLORS:
296 return new PANEL_SYM_COLOR_SETTINGS( aParent );
297
299 return new PANEL_EESCHEMA_DISPLAY_OPTIONS( aParent, GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) );
300
301 case PANEL_SCH_GRIDS:
302 {
303 EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
304 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
305
306 if( !frame )
307 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
308
309 if( !frame )
310 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
311
312 if( frame )
313 SetUserUnits( frame->GetUserUnits() );
314
315 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH );
316 }
317
319 {
320 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
321
322 if( !frame )
323 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
324
325 if( !frame )
326 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
327
328 if( frame )
329 SetUserUnits( frame->GetUserUnits() );
330
331 return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, this, frame );
332 }
333
335 {
336 APP_SETTINGS_BASE* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
337 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SCH_EDIT_TOOLBAR_SETTINGS>( "eeschema-toolbars" );
338
339 std::vector<TOOL_ACTION*> actions;
340 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
341
342 for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
343 actions.push_back( action );
344
345 for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList( FRAME_SCH ) )
346 controls.push_back( control );
347
348 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
349 }
350
351 case PANEL_SCH_COLORS:
352 return new PANEL_EESCHEMA_COLOR_SETTINGS( aParent );
353
355 return new PANEL_TEMPLATE_FIELDNAMES( aParent, nullptr );
356
358 {
359 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
360
361 if( !frame )
362 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
363
364 if( !frame )
365 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
366
367 return new class PANEL_SCH_DATA_SOURCES( aParent, frame );
368 }
369
371 return new PANEL_SIMULATOR_PREFERENCES( aParent );
372
373 default:
374 return nullptr;
375 }
376 }
377
388 void* IfaceOrAddress( int aDataId ) override
389 {
390 switch( aDataId )
391 {
393 return (void*) generateSchematicNetlist;
394 }
395
396 return nullptr;
397 }
398
404 void SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
405 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
406 const wxString& aSrcFilePath, wxString& aErrors ) override;
407
408
409 int HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter ) override;
410
411 bool HandleJobConfig( JOB* aJob, wxWindow* aParent ) override;
412
413 void PreloadLibraries( KIWAY* aKiway ) override;
414 void CancelPreload( bool aBlock = true ) override;
415 void ProjectChanged() override;
416
417private:
418 std::unique_ptr<EESCHEMA_JOBS_HANDLER> m_jobHandler;
419 std::shared_ptr<BACKGROUND_JOB> m_libraryPreloadBackgroundJob;
420 std::future<void> m_libraryPreloadReturn;
422 std::atomic_bool m_libraryPreloadAbort;
423
424} kiface( "eeschema", KIWAY::FACE_SCH );
425
426} // namespace
427
428using namespace SCH;
429
430
432
433
434// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
435// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
436KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
437{
438 return &kiface;
439}
440
441
442bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
443{
444 // This is process-level-initialization, not project-level-initialization of the DSO.
445 // Do nothing in here pertinent to a project!
447
448 // Register the symbol editor settings as well because they share a KiFACE and need to be
449 // loaded prior to use to avoid threading deadlocks
451 aProgram->GetSettingsManager().RegisterSettings( symSettings ); // manager takes ownership
452
453 // We intentionally register KifaceSettings after SYMBOL_EDITOR_SETTINGS
454 // In legacy configs, many settings were in a single editor config nd the migration routine
455 // for the main editor file will try and call into the now separate settings stores
456 // to move the settings into them
458
459 start_common( aCtlBits );
460
461 m_jobHandler = std::make_unique<EESCHEMA_JOBS_HANDLER>( aKiway );
462
464 {
465 m_jobHandler->SetReporter( &CLI_REPORTER::GetInstance() );
466 m_jobHandler->SetProgressReporter( &CLI_PROGRESS_REPORTER::GetInstance() );
467 }
468
469 return true;
470}
471
472
474{
475}
476
477
479{
480 constexpr static int interval = 150;
481 constexpr static int timeLimit = 120000;
482
483 wxCHECK( aKiway, /* void */ );
484
485 // Use compare_exchange to atomically check and set the flag to prevent race conditions
486 // when PreloadLibraries is called multiple times concurrently (e.g., from project manager
487 // and schematic editor both scheduling via CallAfter)
488 bool expected = false;
489
490 if( !m_libraryPreloadInProgress.compare_exchange_strong( expected, true ) )
491 return;
492
494
496 Pgm().GetBackgroundJobMonitor().Create( _( "Loading Symbol Libraries" ) );
497
498 auto preload =
499 [this, aKiway]() -> void
500 {
501 std::shared_ptr<BACKGROUND_JOB_REPORTER> reporter =
503
505
506 int elapsed = 0;
507
508 reporter->Report( _( "Loading Symbol Libraries" ) );
509 adapter->AsyncLoad();
510
511 while( true )
512 {
513 if( m_libraryPreloadAbort.load() )
514 {
515 m_libraryPreloadAbort.store( false );
516 break;
517 }
518
519 std::this_thread::sleep_for( std::chrono::milliseconds( interval ) );
520
521 if( std::optional<float> loadStatus = adapter->AsyncLoadProgress() )
522 {
523 float progress = *loadStatus;
524 reporter->SetCurrentProgress( progress );
525
526 if( progress >= 1 )
527 break;
528 }
529 else
530 {
531 reporter->SetCurrentProgress( 1 );
532 break;
533 }
534
535 elapsed += interval;
536
537 if( elapsed > timeLimit )
538 break;
539 }
540
541 adapter->BlockUntilLoaded();
542
543 // Collect library load errors for async reporting
544 wxString errors = adapter->GetLibraryLoadErrors();
545
546 wxLogTrace( traceLibraries, "eeschema PreloadLibraries: errors.IsEmpty()=%d, length=%zu",
547 errors.IsEmpty(), errors.length() );
548
549 std::vector<LOAD_MESSAGE> messages =
551
552 if( !messages.empty() )
553 {
554 wxLogTrace( traceLibraries, " -> collected %zu messages, calling AddLibraryLoadMessages",
555 messages.size() );
556 Pgm().AddLibraryLoadMessages( messages );
557 }
558 else
559 {
560 wxLogTrace( traceLibraries, " -> no errors from symbol libraries" );
561 }
562
565 m_libraryPreloadInProgress.store( false );
566
567 std::string payload = "";
568 aKiway->ExpressMail( FRAME_SCH, MAIL_RELOAD_LIB, payload, nullptr, true );
569 aKiway->ExpressMail( FRAME_SCH_SYMBOL_EDITOR, MAIL_RELOAD_LIB, payload, nullptr, true );
570 aKiway->ExpressMail( FRAME_SCH_VIEWER, MAIL_RELOAD_LIB, payload, nullptr, true );
571 };
572
574 m_libraryPreloadReturn = tp.submit_task( preload );
575}
576
577
578void IFACE::CancelPreload( bool aBlock )
579{
580 if( m_libraryPreloadInProgress.load() )
581 {
582 m_libraryPreloadAbort.store( true );
583
584 if( aBlock )
586 }
587}
588
589
591{
592 if( m_libraryPreloadInProgress.load() )
593 m_libraryPreloadAbort.store( true );
594}
595
596
598{
599 end_common();
600}
601
602
603void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
604 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
605 const wxString& aSrcFilePath, wxString& aErrors )
606{
607 wxFileName destFile( aSrcFilePath );
608 wxString destPath = destFile.GetPathWithSep();
609 wxUniChar pathSep = wxFileName::GetPathSeparator();
610 wxString ext = destFile.GetExt();
611
612 if( destPath.StartsWith( aProjectBasePath + pathSep ) )
613 destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
614
615 destFile.SetPath( destPath );
616
621 {
622 if( destFile.GetName() == aProjectName )
623 {
624 destFile.SetName( aNewProjectName );
625 }
626 else if( destFile.GetName() == aNewProjectName )
627 {
628 wxString msg;
629
630 if( !aErrors.empty() )
631 aErrors += wxS( "\n" );
632
633 msg.Printf( _( "Cannot copy file '%s' as it will be overwritten by the new root "
634 "sheet file." ), destFile.GetFullPath() );
635 aErrors += msg;
636 return;
637 }
638
639 CopySexprFile( aSrcFilePath, destFile.GetFullPath(),
640 [&]( const std::string& token, wxString& value ) -> bool
641 {
642 if( token == "project" && value == aProjectName )
643 {
644 value = aNewProjectName;
645 return true;
646 }
647
648 return false;
649 },
650 aErrors );
651 }
653 {
654 // Symbols are not project-specific. Keep their source names.
655 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
656 }
660 {
661 if( destFile.GetName() == aProjectName + wxS( "-cache" ) )
662 destFile.SetName( aNewProjectName + wxS( "-cache" ) );
663
664 if( destFile.GetName() == aProjectName + wxS( "-rescue" ) )
665 destFile.SetName( aNewProjectName + wxS( "-rescue" ) );
666
667 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
668 }
669 else if( ext == FILEEXT::NetlistFileExtension )
670 {
671 if( destFile.GetName() == aProjectName )
672 destFile.SetName( aNewProjectName );
673
674 CopySexprFile( aSrcFilePath, destFile.GetFullPath(),
675 [&]( const std::string& token, wxString& value ) -> bool
676 {
677 if( token == "source" )
678 {
679 for( const wxString& extension : { wxString( wxT( ".sch" ) ), wxString( wxT( ".kicad_sch" ) ) } )
680 {
681 if( value == aProjectName + extension )
682 {
683 value = aNewProjectName + extension;
684 return true;
685 }
686 else if( value == aProjectBasePath + "/" + aProjectName + extension )
687 {
688 value = aNewProjectBasePath + "/" + aNewProjectName + extension;
689 return true;
690 }
691 else if( value.StartsWith( aProjectBasePath ) )
692 {
693 value.Replace( aProjectBasePath, aNewProjectBasePath, false );
694 return true;
695 }
696 }
697 }
698
699 return false;
700 },
701 aErrors );
702 }
703 else if( destFile.GetName() == FILEEXT::SymbolLibraryTableFileName )
704 {
705 wxFileName libTableFn( aSrcFilePath );
706 LIBRARY_TABLE libTable( libTableFn, LIBRARY_TABLE_SCOPE::PROJECT );
707 libTable.SetPath( destFile.GetFullPath() );
708 libTable.SetType( LIBRARY_TABLE_TYPE::SYMBOL );
709
710 for( LIBRARY_TABLE_ROW& row : libTable.Rows() )
711 {
712 wxString uri = row.URI();
713
714 uri.Replace( wxS( "/" ) + aProjectName + wxS( "-cache.lib" ),
715 wxS( "/" ) + aNewProjectName + wxS( "-cache.lib" ) );
716 uri.Replace( wxS( "/" ) + aProjectName + wxS( "-rescue.lib" ),
717 wxS( "/" ) + aNewProjectName + wxS( "-rescue.lib" ) );
718 uri.Replace( wxS( "/" ) + aProjectName + wxS( ".lib" ),
719 wxS( "/" ) + aNewProjectName + wxS( ".lib" ) );
720
721 row.SetURI( uri );
722 }
723
724 libTable.Save().map_error(
725 [&]( const LIBRARY_ERROR& aError )
726 {
727 wxString msg;
728
729 if( !aErrors.empty() )
730 aErrors += wxT( "\n" );
731
732 msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
733 aErrors += msg;
734 } );
735 }
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(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: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:294
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:300
@ FACE_SCH
eeschema DSO
Definition kiway.h:301
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.
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:110
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
Definition pgm_base.h:138
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.
Definition pgm_base.cpp:988
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:132
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:747
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 & Prj() const
A helper while we are not MDI-capable – return the one and only project.
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
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...
Symbol library viewer main window.
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:431
@ 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 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: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:91
SCH::IFACE KIFACE_BASE, UNITS_PROVIDER kiface("eeschema", KIWAY::FACE_SCH)
bool generateSchematicNetlist(const wxString &aFilename, std::string &aNetlist)
Definition eeschema.cpp:149
#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:155
std::future< void > m_libraryPreloadReturn
Definition eeschema.cpp:420
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
Definition eeschema.cpp:442
std::shared_ptr< BACKGROUND_JOB > m_libraryPreloadBackgroundJob
Definition eeschema.cpp:419
void PreloadLibraries(KIWAY *aKiway) override
Definition eeschema.cpp:478
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:603
void ProjectChanged() override
Definition eeschema.cpp:590
void CancelPreload(bool aBlock=true) override
Definition eeschema.cpp:578
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
Definition eeschema.cpp:178
std::atomic_bool m_libraryPreloadAbort
Definition eeschema.cpp:422
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition eeschema.cpp:166
void Reset() override
Reloads global state.
Definition eeschema.cpp:473
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
Definition eeschema.cpp:388
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:418
std::atomic_bool m_libraryPreloadInProgress
Definition eeschema.cpp:421
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:597
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.