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 <trace_helpers.h>
54#include <thread_pool.h>
55#include <kiface_ids.h>
57#include <wx/ffile.h>
59
60#include <schematic.h>
61#include <connection_graph.h>
72#include <sim/simulator_frame.h>
73
75#include <toolbars_sch_editor.h>
77
78#include <wx/crt.h>
79
80// The main sheet of the project
82
83
84namespace SCH {
85
86
87// TODO: This should move out of this file
88static std::unique_ptr<SCHEMATIC> readSchematicFromFile( const std::string& aFilename )
89{
90 SCH_IO* pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD );
91 std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>( nullptr );
92
94
95 // TODO: this must load the schematic's project, not a default project. At the very minimum
96 // variable resolution won't work without the project, but there might also be issues with
97 // netclasses, etc.
98 manager.LoadProject( "" );
99 schematic->Reset();
100 schematic->SetProject( &manager.Prj() );
101 schematic->SetRoot( pi->LoadSchematicFile( aFilename, schematic.get() ) );
102
103 // Set current sheet to the first top-level sheet, not the virtual root
104 std::vector<SCH_SHEET*> topLevelSheets = schematic->GetTopLevelSheets();
105
106 if( !topLevelSheets.empty() )
107 {
108 schematic->CurrentSheet().push_back( topLevelSheets[0] );
109 wxLogTrace( traceSchCurrentSheet,
110 "Set current sheet to first top-level sheet: %s, path: %s",
111 topLevelSheets[0]->GetName(),
112 schematic->CurrentSheet().Path().AsString() );
113 }
114 else
115 {
116 wxLogWarning( "No top-level sheets found after loading schematic!" );
117 }
118
119 SCH_SCREENS screens( schematic->Root() );
120
121 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
122 screen->UpdateLocalLibSymbolLinks();
123
124 SCH_SHEET_LIST sheets = schematic->Hierarchy();
125
126 // Restore all of the loaded symbol instances from the root sheet screen.
127 sheets.UpdateSymbolInstanceData( schematic->RootScreen()->GetSymbolInstances() );
128
129 if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
130 {
131 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
132 screen->FixLegacyPowerSymbolMismatches();
133 }
134
135 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
136 screen->MigrateSimModels();
137
138 sheets.AnnotatePowerSymbols();
139
140 // NOTE: This is required for multi-unit symbols to be correct
141 for( SCH_SHEET_PATH& sheet : sheets )
142 sheet.UpdateAllScreenReferences();
143
144 // TODO: this must handle SchematicCleanup somehow. The original version didn't because
145 // it knew that QA test cases were saved in a clean state.
146
147 // TODO: does this need to handle PruneOrphanedSymbolInstances() and
148 // PruneOrphanedSheetInstances()?
149
150 schematic->ConnectionGraph()->Recalculate( sheets, true );
151
152 return schematic;
153}
154
155
156// TODO: This should move out of this file
157bool generateSchematicNetlist( const wxString& aFilename, std::string& aNetlist )
158{
159 std::unique_ptr<SCHEMATIC> schematic = readSchematicFromFile( aFilename.ToStdString() );
160 NETLIST_EXPORTER_KICAD exporter( schematic.get() );
161 STRING_FORMATTER formatter;
162
163 exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
164 aNetlist = formatter.GetString();
165
166 return true;
167}
168
169
170static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
171{
172 // Of course all are virtual overloads, implementations of the KIFACE.
173
174 IFACE( const char* aName, KIWAY::FACE_T aType ) :
175 KIFACE_BASE( aName, aType ),
178 {}
179
180 bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) override;
181
182 void Reset() override;
183
184 void OnKifaceEnd() override;
185
186 wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
187 {
188 switch( aClassId )
189 {
190 case FRAME_SCH:
191 {
192 SCH_EDIT_FRAME* frame = new SCH_EDIT_FRAME( aKiway, aParent );
193
195
196 if( Kiface().IsSingle() )
197 {
198 // only run this under single_top, not under a project manager.
200 }
201
202 return frame;
203 }
204
206 return new SYMBOL_EDIT_FRAME( aKiway, aParent );
207
208 case FRAME_SIMULATOR:
209 {
210 try
211 {
212 SIMULATOR_FRAME* frame = new SIMULATOR_FRAME( aKiway, aParent );
213 return frame;
214 }
215 catch( const SIMULATOR_INIT_ERR& )
216 {
217 // catch the init err exception as we don't want it to bubble up
218 // its going to be some ngspice install issue but we don't want to log that
219 return nullptr;
220 }
221 }
222
223 case FRAME_SCH_VIEWER:
224 return new SYMBOL_VIEWER_FRAME( aKiway, aParent );
225
227 {
228 bool cancelled = false;
229 SYMBOL_CHOOSER_FRAME* chooser = new SYMBOL_CHOOSER_FRAME( aKiway, aParent, cancelled );
230
231 if( cancelled )
232 {
233 chooser->Destroy();
234 return nullptr;
235 }
236
237 return chooser;
238 }
239
241 InvokeSchEditSymbolLibTable( aKiway, aParent );
242 // Dialog has completed; nothing to return.
243 return nullptr;
244
246 InvokeEditDesignBlockLibTable( aKiway, aParent );
247 // Dialog has completed; nothing to return.
248 return nullptr;
251 return new PANEL_SYM_DISPLAY_OPTIONS( aParent, GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" ) );
252
258 if( !frame )
259 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
260
261 if( !frame )
262 frame = aKiway->Player( FRAME_SCH, false );
263
264 if( frame )
265 SetUserUnits( frame->GetUserUnits() );
266
267 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH_SYMBOL_EDITOR );
268 }
269
271 {
272 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
273
274 if( !frame )
275 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
276
277 if( !frame )
278 frame = aKiway->Player( FRAME_SCH, false );
279
280 if( frame )
281 SetUserUnits( frame->GetUserUnits() );
282
283 return new PANEL_SYM_EDITING_OPTIONS( aParent, this, frame );
284 }
285
287 {
288 APP_SETTINGS_BASE* cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" );
289 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SYMBOL_EDIT_TOOLBAR_SETTINGS>( "symbol_editor-toolbars" );
290
291 std::vector<TOOL_ACTION*> actions;
292 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
293
294 for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
295 actions.push_back( action );
296
297 for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList() )
298 controls.push_back( control );
299
300 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
301 }
302
303 case PANEL_SYM_COLORS:
304 return new PANEL_SYM_COLOR_SETTINGS( aParent );
305
307 return new PANEL_EESCHEMA_DISPLAY_OPTIONS( aParent, GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) );
308
309 case PANEL_SCH_GRIDS:
310 {
311 EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
312 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
313
314 if( !frame )
315 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
316
317 if( !frame )
318 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
319
320 if( frame )
321 SetUserUnits( frame->GetUserUnits() );
322
323 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH );
324 }
325
327 {
328 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
329
330 if( !frame )
331 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
332
333 if( !frame )
334 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
335
336 if( frame )
337 SetUserUnits( frame->GetUserUnits() );
338
339 return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, this, frame );
340 }
341
343 {
344 APP_SETTINGS_BASE* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
345 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SCH_EDIT_TOOLBAR_SETTINGS>( "eeschema-toolbars" );
346
347 std::vector<TOOL_ACTION*> actions;
348 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
349
350 for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
351 actions.push_back( action );
352
353 for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList() )
354 controls.push_back( control );
355
356 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
357 }
358
359 case PANEL_SCH_COLORS:
360 return new PANEL_EESCHEMA_COLOR_SETTINGS( aParent );
361
363 return new PANEL_TEMPLATE_FIELDNAMES( aParent, nullptr );
364
366 {
367 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
368
369 if( !frame )
370 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
371
372 if( !frame )
373 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
374
375 return new class PANEL_SCH_DATA_SOURCES( aParent, frame );
376 }
377
379 return new PANEL_SIMULATOR_PREFERENCES( aParent );
380
381 default:
382 return nullptr;
383 }
384 }
385
396 void* IfaceOrAddress( int aDataId ) override
397 {
398 switch( aDataId )
399 {
401 return (void*) generateSchematicNetlist;
402 }
403
404 return nullptr;
405 }
406
412 void SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
413 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
414 const wxString& aSrcFilePath, wxString& aErrors ) override;
415
416
417 int HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter ) override;
418
419 bool HandleJobConfig( JOB* aJob, wxWindow* aParent ) override;
420
421 void PreloadLibraries( KIWAY* aKiway ) override;
422 void ProjectChanged() override;
423
424private:
425 std::unique_ptr<EESCHEMA_JOBS_HANDLER> m_jobHandler;
426 std::shared_ptr<BACKGROUND_JOB> m_libraryPreloadBackgroundJob;
427 std::future<void> m_libraryPreloadReturn;
429 std::atomic_bool m_libraryPreloadAbort;
430
431} kiface( "eeschema", KIWAY::FACE_SCH );
432
433} // namespace
434
435using namespace SCH;
436
437
439
440
441// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
442// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
443KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
444{
445 return &kiface;
446}
447
448
449bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
450{
451 // This is process-level-initialization, not project-level-initialization of the DSO.
452 // Do nothing in here pertinent to a project!
454
455 // Register the symbol editor settings as well because they share a KiFACE and need to be
456 // loaded prior to use to avoid threading deadlocks
458 aProgram->GetSettingsManager().RegisterSettings( symSettings ); // manager takes ownership
459
460 // We intentionally register KifaceSettings after SYMBOL_EDITOR_SETTINGS
461 // In legacy configs, many settings were in a single editor config nd the migration routine
462 // for the main editor file will try and call into the now separate settings stores
463 // to move the settings into them
465
466 start_common( aCtlBits );
467
468 m_jobHandler = std::make_unique<EESCHEMA_JOBS_HANDLER>( aKiway );
469
471 {
472 m_jobHandler->SetReporter( &CLI_REPORTER::GetInstance() );
473 m_jobHandler->SetProgressReporter( &CLI_PROGRESS_REPORTER::GetInstance() );
474 }
475
476 return true;
477}
478
479
481{
482}
483
484
486{
487 constexpr static int interval = 150;
488 constexpr static int timeLimit = 120000;
489
490 wxCHECK( aKiway, /* void */ );
491
492 if( m_libraryPreloadInProgress.load() )
493 return;
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
545 m_libraryPreloadInProgress.store( false );
546
547 std::string payload = "";
548 aKiway->ExpressMail( FRAME_SCH, MAIL_RELOAD_LIB, payload, nullptr, true );
549 aKiway->ExpressMail( FRAME_SCH_SYMBOL_EDITOR, MAIL_RELOAD_LIB, payload, nullptr, true );
550 aKiway->ExpressMail( FRAME_SCH_VIEWER, MAIL_RELOAD_LIB, payload, nullptr, true );
551 };
552
554 m_libraryPreloadInProgress.store( true );
555 m_libraryPreloadReturn = tp.submit_task( preload );
556}
557
558
560{
561 if( m_libraryPreloadInProgress.load() )
562 m_libraryPreloadAbort.store( true );
563}
564
565
567{
568 end_common();
569}
570
571
572void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
573 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
574 const wxString& aSrcFilePath, wxString& aErrors )
575{
576 wxFileName destFile( aSrcFilePath );
577 wxString destPath = destFile.GetPathWithSep();
578 wxUniChar pathSep = wxFileName::GetPathSeparator();
579 wxString ext = destFile.GetExt();
580
581 if( destPath.StartsWith( aProjectBasePath + pathSep ) )
582 destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
583
584 destFile.SetPath( destPath );
585
590 {
591 if( destFile.GetName() == aProjectName )
592 {
593 destFile.SetName( aNewProjectName );
594 }
595 else if( destFile.GetName() == aNewProjectName )
596 {
597 wxString msg;
598
599 if( !aErrors.empty() )
600 aErrors += wxS( "\n" );
601
602 msg.Printf( _( "Cannot copy file '%s' as it will be overwritten by the new root "
603 "sheet file." ), destFile.GetFullPath() );
604 aErrors += msg;
605 return;
606 }
607
608 CopySexprFile( aSrcFilePath, destFile.GetFullPath(),
609 [&]( const std::string& token, wxString& value ) -> bool
610 {
611 if( token == "project" && value == aProjectName )
612 {
613 value = aNewProjectName;
614 return true;
615 }
616
617 return false;
618 },
619 aErrors );
620 }
622 {
623 // Symbols are not project-specific. Keep their source names.
624 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
625 }
629 {
630 if( destFile.GetName() == aProjectName + wxS( "-cache" ) )
631 destFile.SetName( aNewProjectName + wxS( "-cache" ) );
632
633 if( destFile.GetName() == aProjectName + wxS( "-rescue" ) )
634 destFile.SetName( aNewProjectName + wxS( "-rescue" ) );
635
636 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
637 }
638 else if( ext == FILEEXT::NetlistFileExtension )
639 {
640 if( destFile.GetName() == aProjectName )
641 destFile.SetName( aNewProjectName );
642
643 CopySexprFile( aSrcFilePath, destFile.GetFullPath(),
644 [&]( const std::string& token, wxString& value ) -> bool
645 {
646 if( token == "source" )
647 {
648 for( const wxString& extension : { wxString( wxT( ".sch" ) ), wxString( wxT( ".kicad_sch" ) ) } )
649 {
650 if( value == aProjectName + extension )
651 {
652 value = aNewProjectName + extension;
653 return true;
654 }
655 else if( value == aProjectBasePath + "/" + aProjectName + extension )
656 {
657 value = aNewProjectBasePath + "/" + aNewProjectName + extension;
658 return true;
659 }
660 else if( value.StartsWith( aProjectBasePath ) )
661 {
662 value.Replace( aProjectBasePath, aNewProjectBasePath, false );
663 return true;
664 }
665 }
666 }
667
668 return false;
669 },
670 aErrors );
671 }
672 else if( destFile.GetName() == FILEEXT::SymbolLibraryTableFileName )
673 {
674 wxFileName libTableFn( aSrcFilePath );
675 LIBRARY_TABLE libTable( libTableFn, LIBRARY_TABLE_SCOPE::PROJECT );
676 libTable.SetPath( destFile.GetFullPath() );
677 libTable.SetType( LIBRARY_TABLE_TYPE::SYMBOL );
678
679 for( LIBRARY_TABLE_ROW& row : libTable.Rows() )
680 {
681 wxString uri = row.URI();
682
683 uri.Replace( wxS( "/" ) + aProjectName + wxS( "-cache.lib" ),
684 wxS( "/" ) + aNewProjectName + wxS( "-cache.lib" ) );
685 uri.Replace( wxS( "/" ) + aProjectName + wxS( "-rescue.lib" ),
686 wxS( "/" ) + aNewProjectName + wxS( "-rescue.lib" ) );
687 uri.Replace( wxS( "/" ) + aProjectName + wxS( ".lib" ),
688 wxS( "/" ) + aNewProjectName + wxS( ".lib" ) );
689
690 row.SetURI( uri );
691 }
692
693 libTable.Save().map_error(
694 [&]( const LIBRARY_ERROR& aError )
695 {
696 wxString msg;
697
698 if( !aErrors.empty() )
699 aErrors += wxT( "\n" );
700
701 msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
702 aErrors += msg;
703 } );
704 }
705 else
706 {
707 wxFAIL_MSG( wxS( "Unexpected filetype for Eeschema::SaveFileAs()" ) );
708 }
709}
710
711
712int IFACE::HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter )
713{
714 return m_jobHandler->RunJob( aJob, aReporter, aProgressReporter );
715}
716
717
718bool IFACE::HandleJobConfig( JOB* aJob, wxWindow* aParent )
719{
720 return m_jobHandler->HandleJobConfig( aJob, aParent );
721}
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.
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:107
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
Definition pgm_base.h:135
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:129
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.
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...
void AsyncLoad() override
Loads all available libraries for this adapter type in the background.
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:81
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition eeschema.cpp:438
@ 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:124
@ 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:123
@ 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:319
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
Definition gestfich.cpp:292
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:43
#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:88
SCH::IFACE KIFACE_BASE, UNITS_PROVIDER kiface("eeschema", KIWAY::FACE_SCH)
bool generateSchematicNetlist(const wxString &aFilename, std::string &aNetlist)
Definition eeschema.cpp:157
#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)
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:427
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
Definition eeschema.cpp:449
std::shared_ptr< BACKGROUND_JOB > m_libraryPreloadBackgroundJob
Definition eeschema.cpp:426
void PreloadLibraries(KIWAY *aKiway) override
Definition eeschema.cpp:485
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:572
void ProjectChanged() override
Definition eeschema.cpp:559
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
Definition eeschema.cpp:186
std::atomic_bool m_libraryPreloadAbort
Definition eeschema.cpp:429
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition eeschema.cpp:174
void Reset() override
Reloads global state.
Definition eeschema.cpp:480
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
Definition eeschema.cpp:396
int HandleJob(JOB *aJob, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter) override
Definition eeschema.cpp:712
std::unique_ptr< EESCHEMA_JOBS_HANDLER > m_jobHandler
Definition eeschema.cpp:425
std::atomic_bool m_libraryPreloadInProgress
Definition eeschema.cpp:428
bool HandleJobConfig(JOB *aJob, wxWindow *aParent) override
Definition eeschema.cpp:718
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
Definition eeschema.cpp:566
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.