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 if( m_libraryPreloadInProgress.load() )
486 return;
487
489
491 Pgm().GetBackgroundJobMonitor().Create( _( "Loading Symbol Libraries" ) );
492
493 auto preload =
494 [this, aKiway]() -> void
495 {
496 std::shared_ptr<BACKGROUND_JOB_REPORTER> reporter =
498
500
501 int elapsed = 0;
502
503 reporter->Report( _( "Loading Symbol Libraries" ) );
504 adapter->AsyncLoad();
505
506 while( true )
507 {
508 if( m_libraryPreloadAbort.load() )
509 {
510 m_libraryPreloadAbort.store( false );
511 break;
512 }
513
514 std::this_thread::sleep_for( std::chrono::milliseconds( interval ) );
515
516 if( std::optional<float> loadStatus = adapter->AsyncLoadProgress() )
517 {
518 float progress = *loadStatus;
519 reporter->SetCurrentProgress( progress );
520
521 if( progress >= 1 )
522 break;
523 }
524 else
525 {
526 reporter->SetCurrentProgress( 1 );
527 break;
528 }
529
530 elapsed += interval;
531
532 if( elapsed > timeLimit )
533 break;
534 }
535
536 adapter->BlockUntilLoaded();
537
538 // Collect library load errors for async reporting
539 wxString errors = adapter->GetLibraryLoadErrors();
540
541 wxLogTrace( traceLibraries, "eeschema PreloadLibraries: errors.IsEmpty()=%d, length=%zu",
542 errors.IsEmpty(), errors.length() );
543
544 std::vector<LOAD_MESSAGE> messages =
546
547 if( !messages.empty() )
548 {
549 wxLogTrace( traceLibraries, " -> collected %zu messages, calling AddLibraryLoadMessages",
550 messages.size() );
551 Pgm().AddLibraryLoadMessages( messages );
552 }
553 else
554 {
555 wxLogTrace( traceLibraries, " -> no errors from symbol libraries" );
556 }
557
560 m_libraryPreloadInProgress.store( false );
561
562 std::string payload = "";
563 aKiway->ExpressMail( FRAME_SCH, MAIL_RELOAD_LIB, payload, nullptr, true );
564 aKiway->ExpressMail( FRAME_SCH_SYMBOL_EDITOR, MAIL_RELOAD_LIB, payload, nullptr, true );
565 aKiway->ExpressMail( FRAME_SCH_VIEWER, MAIL_RELOAD_LIB, payload, nullptr, true );
566 };
567
569 m_libraryPreloadInProgress.store( true );
570 m_libraryPreloadReturn = tp.submit_task( preload );
571}
572
573
574void IFACE::CancelPreload( bool aBlock )
575{
576 if( m_libraryPreloadInProgress.load() )
577 {
578 m_libraryPreloadAbort.store( true );
579
580 if( aBlock )
582 }
583}
584
585
587{
588 if( m_libraryPreloadInProgress.load() )
589 m_libraryPreloadAbort.store( true );
590}
591
592
594{
595 end_common();
596}
597
598
599void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
600 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
601 const wxString& aSrcFilePath, wxString& aErrors )
602{
603 wxFileName destFile( aSrcFilePath );
604 wxString destPath = destFile.GetPathWithSep();
605 wxUniChar pathSep = wxFileName::GetPathSeparator();
606 wxString ext = destFile.GetExt();
607
608 if( destPath.StartsWith( aProjectBasePath + pathSep ) )
609 destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
610
611 destFile.SetPath( destPath );
612
617 {
618 if( destFile.GetName() == aProjectName )
619 {
620 destFile.SetName( aNewProjectName );
621 }
622 else if( destFile.GetName() == aNewProjectName )
623 {
624 wxString msg;
625
626 if( !aErrors.empty() )
627 aErrors += wxS( "\n" );
628
629 msg.Printf( _( "Cannot copy file '%s' as it will be overwritten by the new root "
630 "sheet file." ), destFile.GetFullPath() );
631 aErrors += msg;
632 return;
633 }
634
635 CopySexprFile( aSrcFilePath, destFile.GetFullPath(),
636 [&]( const std::string& token, wxString& value ) -> bool
637 {
638 if( token == "project" && value == aProjectName )
639 {
640 value = aNewProjectName;
641 return true;
642 }
643
644 return false;
645 },
646 aErrors );
647 }
649 {
650 // Symbols are not project-specific. Keep their source names.
651 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
652 }
656 {
657 if( destFile.GetName() == aProjectName + wxS( "-cache" ) )
658 destFile.SetName( aNewProjectName + wxS( "-cache" ) );
659
660 if( destFile.GetName() == aProjectName + wxS( "-rescue" ) )
661 destFile.SetName( aNewProjectName + wxS( "-rescue" ) );
662
663 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
664 }
665 else if( ext == FILEEXT::NetlistFileExtension )
666 {
667 if( destFile.GetName() == aProjectName )
668 destFile.SetName( aNewProjectName );
669
670 CopySexprFile( aSrcFilePath, destFile.GetFullPath(),
671 [&]( const std::string& token, wxString& value ) -> bool
672 {
673 if( token == "source" )
674 {
675 for( const wxString& extension : { wxString( wxT( ".sch" ) ), wxString( wxT( ".kicad_sch" ) ) } )
676 {
677 if( value == aProjectName + extension )
678 {
679 value = aNewProjectName + extension;
680 return true;
681 }
682 else if( value == aProjectBasePath + "/" + aProjectName + extension )
683 {
684 value = aNewProjectBasePath + "/" + aNewProjectName + extension;
685 return true;
686 }
687 else if( value.StartsWith( aProjectBasePath ) )
688 {
689 value.Replace( aProjectBasePath, aNewProjectBasePath, false );
690 return true;
691 }
692 }
693 }
694
695 return false;
696 },
697 aErrors );
698 }
699 else if( destFile.GetName() == FILEEXT::SymbolLibraryTableFileName )
700 {
701 wxFileName libTableFn( aSrcFilePath );
702 LIBRARY_TABLE libTable( libTableFn, LIBRARY_TABLE_SCOPE::PROJECT );
703 libTable.SetPath( destFile.GetFullPath() );
704 libTable.SetType( LIBRARY_TABLE_TYPE::SYMBOL );
705
706 for( LIBRARY_TABLE_ROW& row : libTable.Rows() )
707 {
708 wxString uri = row.URI();
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.SetURI( uri );
718 }
719
720 libTable.Save().map_error(
721 [&]( const LIBRARY_ERROR& aError )
722 {
723 wxString msg;
724
725 if( !aErrors.empty() )
726 aErrors += wxT( "\n" );
727
728 msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
729 aErrors += msg;
730 } );
731 }
732 else
733 {
734 wxFAIL_MSG( wxS( "Unexpected filetype for Eeschema::SaveFileAs()" ) );
735 }
736}
737
738
739int IFACE::HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter )
740{
741 return m_jobHandler->RunJob( aJob, aReporter, aProgressReporter );
742}
743
744
745bool IFACE::HandleJobConfig( JOB* aJob, wxWindow* aParent )
746{
747 return m_jobHandler->HandleJobConfig( aJob, aParent );
748}
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 PROGRESS_REPORTER & GetInstance()
static REPORTER & GetInstance()
Definition reporter.cpp:130
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.
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.
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...
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: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: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 traceLibraries
Flag to enable library table and library manager tracing.
#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: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:599
void ProjectChanged() override
Definition eeschema.cpp:586
void CancelPreload(bool aBlock=true) override
Definition eeschema.cpp:574
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:739
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:745
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
Definition eeschema.cpp:593
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.