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, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <algorithm>
23
24#include <api/api_handler_sch.h>
26#include <api/api_server.h>
27#include <api/api_utils.h>
31#include <pgm_base.h>
32#include <kiface_base.h>
35#include <confirm.h>
36#include <gestfich.h>
38#include "eeschema_helpers.h"
40#include <reporter.h>
41#include "git/kigit_sch_merge.h"
44#include <eeschema_settings.h>
45#include <sch_edit_frame.h>
47#include <symbol_edit_frame.h>
48#include <symbol_viewer_frame.h>
55#include <kiway.h>
56#include <project_sch.h>
57#include <richio.h>
60#include <sexpr/sexpr.h>
61#include <sexpr/sexpr_parser.h>
62#include <string_utils.h>
63#include <trace_helpers.h>
64#include <thread_pool.h>
65#include <kiface_ids.h>
66#include <widgets/kistatusbar.h>
68#include <wx/ffile.h>
69#include <wx/tokenzr.h>
71
72#include <schematic.h>
73#include <connection_graph.h>
84#include <sim/simulator_frame.h>
85
87#include <toolbars_sch_editor.h>
89
90#include <sch_io/sch_io.h>
91#include <sch_io/sch_io_mgr.h>
92
93#include <wx/crt.h>
94
95// The main sheet of the project
97
98
99namespace SCH {
100
101// Non-job kiface exports for diff/merge (returned by IfaceOrAddress). Defined
102// after the kiface instance so they can route into its jobs handler.
103static int eeschemaMergeExport( int aKind, const wxString& aAncestor, const wxString& aOurs,
104 const wxString& aTheirs, const wxString& aOutput, bool aInteractive,
105 bool aSingleFile, REPORTER* aReporter );
106static int eeschemaOpenDiffDialogExport( int aKind, const wxString& aFileA, const wxString& aFileB,
107 const wxString& aLabelA, const wxString& aLabelB,
108 wxWindow* aParent, REPORTER* aReporter );
109
110
111
112// TODO: This should move out of this file
113static std::unique_ptr<SCHEMATIC> readSchematicFromFile( const std::string& aFilename )
114{
115 SCH_IO* pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD );
116 std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>( nullptr );
117
119
120 wxFileName pro( aFilename );
121 pro.SetExt( FILEEXT::ProjectFileExtension );
122 pro.MakeAbsolute();
123 wxString projectPath = pro.GetFullPath();
124
125 PROJECT* project = manager.GetProject( projectPath );
126
127 if( !project )
128 {
129 manager.LoadProject( projectPath, true );
130 project = manager.GetProject( projectPath );
131 }
132
133 schematic->Reset();
134 schematic->SetProject( project );
135 SCH_SHEET* rootSheet = pi->LoadSchematicFile( aFilename, schematic.get() );
136
137 if( !rootSheet )
138 return nullptr;
139
140 std::vector<SCH_SHEET*> topLevelSheets = schematic->GetTopLevelSheets();
141 bool rootIsTopLevel = std::find( topLevelSheets.begin(), topLevelSheets.end(), rootSheet )
142 != topLevelSheets.end();
143 bool rootIsVirtualRoot = rootSheet == &schematic->Root() || rootSheet->IsVirtualRootSheet();
144
145 if( !rootIsTopLevel && !rootIsVirtualRoot )
146 schematic->SetTopLevelSheets( { rootSheet } );
147
148 SCH_SCREENS screens( schematic->Root() );
149
150 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
151 screen->UpdateLocalLibSymbolLinks();
152
153 SCH_SHEET_LIST sheets = schematic->Hierarchy();
154
155 // Restore all of the loaded symbol instances from the root sheet screen.
156 sheets.UpdateSymbolInstanceData( schematic->RootScreen()->GetSymbolInstances() );
157
158 if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
159 {
160 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
161 screen->FixLegacyPowerSymbolMismatches();
162 }
163
164 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
165 screen->MigrateSimModels();
166
167 sheets.AnnotatePowerSymbols();
168
169 // NOTE: This is required for multi-unit symbols to be correct
170 for( SCH_SHEET_PATH& sheet : sheets )
171 sheet.UpdateAllScreenReferences();
172
173 // TODO: this must handle SchematicCleanup somehow. The original version didn't because
174 // it knew that QA test cases were saved in a clean state.
175
176 // TODO: does this need to handle PruneOrphanedSymbolInstances() and
177 // PruneOrphanedSheetInstances()?
178
179 schematic->ConnectionGraph()->Recalculate( sheets, true );
180
181 return schematic;
182}
183
184
185// TODO: This should move out of this file
186bool generateSchematicNetlist( const wxString& aFilename, std::string& aNetlist )
187{
188 std::unique_ptr<SCHEMATIC> schematic = readSchematicFromFile( aFilename.ToStdString() );
189 NETLIST_EXPORTER_KICAD exporter( schematic.get() );
190 STRING_FORMATTER formatter;
191
192 exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
193 aNetlist = formatter.GetString();
194
195 return true;
196}
197
198
199static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
200{
201 // Of course all are virtual overloads, implementations of the KIFACE.
202
203 IFACE( const char* aName, KIWAY::FACE_T aType ) :
204 KIFACE_BASE( aName, aType ),
207 {}
208
209 bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) override;
210
211 void Reset() override;
212
213 void OnKifaceEnd() override;
214
215 wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
216 {
217 switch( aClassId )
218 {
219 case FRAME_SCH:
220 {
221 SCH_EDIT_FRAME* frame = new SCH_EDIT_FRAME( aKiway, aParent );
222
224
225 if( Kiface().IsSingle() )
226 {
227 // only run this under single_top, not under a project manager.
230 }
231
232 return frame;
234
236 return new SYMBOL_EDIT_FRAME( aKiway, aParent );
237
238 case FRAME_SIMULATOR:
239 {
240 try
241 {
242 SIMULATOR_FRAME* frame = new SIMULATOR_FRAME( aKiway, aParent );
243 return frame;
244 }
245 catch( const SIMULATOR_INIT_ERR& )
246 {
247 // catch the init err exception as we don't want it to bubble up
248 // its going to be some ngspice install issue but we don't want to log that
249 return nullptr;
250 }
252
253 case FRAME_SCH_VIEWER:
254 return new SYMBOL_VIEWER_FRAME( aKiway, aParent );
255
257 {
258 bool cancelled = false;
259 SYMBOL_CHOOSER_FRAME* chooser = new SYMBOL_CHOOSER_FRAME( aKiway, aParent, cancelled );
260
261 if( cancelled )
262 {
263 chooser->Destroy();
264 return nullptr;
266
267 return chooser;
268 }
269
271 InvokeSchEditSymbolLibTable( aKiway, aParent );
272 // Dialog has completed; nothing to return.
273 return nullptr;
274
277 // Dialog has completed; nothing to return.
278 return nullptr;
281 return new PANEL_SYM_DISPLAY_OPTIONS( aParent, GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" ) );
282
288 if( !frame )
289 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
291 if( !frame )
292 frame = aKiway->Player( FRAME_SCH, false );
294 if( frame )
297 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH_SYMBOL_EDITOR );
298 }
299
301 return CreateSnappingPanel( aParent, GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" ),
303
305 {
306 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
307
308 if( !frame )
309 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
310
311 if( !frame )
312 frame = aKiway->Player( FRAME_SCH, false );
313
314 if( frame )
315 SetUserUnits( frame->GetUserUnits() );
316
317 return new PANEL_SYM_EDITING_OPTIONS( aParent, this, frame );
318 }
319
321 {
322 APP_SETTINGS_BASE* cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" );
323 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SYMBOL_EDIT_TOOLBAR_SETTINGS>( "symbol_editor-toolbars" );
324
325 std::vector<TOOL_ACTION*> actions;
326 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
327
328 for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
329 actions.push_back( action );
330
331 for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList( FRAME_SCH_SYMBOL_EDITOR ) )
332 controls.push_back( control );
333
334 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, FRAME_SCH_SYMBOL_EDITOR, actions, controls );
335 }
336
337 case PANEL_SYM_COLORS:
338 return new PANEL_SYM_COLOR_SETTINGS( aParent );
339
341 return new PANEL_EESCHEMA_DISPLAY_OPTIONS( aParent, GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) );
342
343 case PANEL_SCH_GRIDS:
344 {
345 EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
346 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
347
348 if( !frame )
349 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
350
351 if( !frame )
352 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
353
354 if( frame )
355 SetUserUnits( frame->GetUserUnits() );
356
357 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH );
358 }
359
363
365 {
366 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
367
368 if( !frame )
369 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
370
371 if( !frame )
372 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
373
374 if( frame )
375 SetUserUnits( frame->GetUserUnits() );
376
377 return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, this, frame );
378 }
379
381 {
382 APP_SETTINGS_BASE* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
383 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SCH_EDIT_TOOLBAR_SETTINGS>( "eeschema-toolbars" );
384
385 std::vector<TOOL_ACTION*> actions;
386 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
387
388 for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
389 actions.push_back( action );
390
391 for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList( FRAME_SCH ) )
392 controls.push_back( control );
393
394 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, FRAME_SCH, actions, controls );
395 }
396
397 case PANEL_SCH_COLORS:
398 return new PANEL_EESCHEMA_COLOR_SETTINGS( aParent );
399
401 return new PANEL_TEMPLATE_FIELDNAMES( aParent, nullptr );
402
404 {
405 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
406
407 if( !frame )
408 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
409
410 if( !frame )
411 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
412
413 return new class PANEL_SCH_DATA_SOURCES( aParent, frame );
414 }
415
417 return new PANEL_SIMULATOR_PREFERENCES( aParent );
418
419 default:
420 return nullptr;
421 }
422 }
423
434 void* IfaceOrAddress( int aDataId ) override
435 {
436 switch( aDataId )
437 {
439 return (void*) generateSchematicNetlist;
440
442 return reinterpret_cast<void*>( &eeschemaMergeExport );
443
445 return reinterpret_cast<void*>( &eeschemaOpenDiffDialogExport );
446 }
447
448 return nullptr;
449 }
450
453
459 void SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
460 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
461 const wxString& aSrcFilePath, wxString& aErrors ) override;
462
463
464 int HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter ) override;
465
466 bool HandleJobConfig( JOB* aJob, wxWindow* aParent ) override;
467
468 bool HandleApiOpenDocument( const DOCUMENT_SPEC& aSpec,
469 KICAD_API_SERVER* aServer,
470 wxString* aError ) override;
471
472 bool handleCreateSchematic( const wxString& aPath, KICAD_API_SERVER* aServer, wxString* aError );
473 bool HandleApiCloseDocument( const wxString& aSchFileName,
474 KICAD_API_SERVER* aServer,
475 wxString* aError ) override;
476
477 void PreloadLibraries( KIWAY* aKiway ) override;
478 void CancelPreload( bool aBlock = true ) override;
479 void ProjectChanged() override;
480 void RegisterLibraryHandlers( KICAD_API_SERVER* aServer ) override;
481 bool LoadAllLibraries() override;
482
483
484private:
485 std::unique_ptr<EESCHEMA_JOBS_HANDLER> m_jobHandler;
486 std::shared_ptr<BACKGROUND_JOB> m_libraryPreloadBackgroundJob;
487 std::future<void> m_libraryPreloadReturn;
489 std::atomic_bool m_libraryPreloadAbort;
490
491 void closeCurrentDocument( KICAD_API_SERVER* aServer );
492
493 KIWAY* m_kiway = nullptr;
495 std::shared_ptr<HEADLESS_SCH_CONTEXT> m_openContext;
496 std::unique_ptr<API_HANDLER_SCH> m_openHandler;
497 std::unique_ptr<API_HANDLER_SCH_LIBRARIES> m_apiHandlerSchLibs;
498
499} kiface( "eeschema", KIWAY::FACE_SCH );
500
501
502int eeschemaMergeExport( int aKind, const wxString& aAncestor, const wxString& aOurs,
503 const wxString& aTheirs, const wxString& aOutput, bool aInteractive,
504 bool aSingleFile, REPORTER* aReporter )
505{
506 return kiface.JobHandler()->RunMerge( static_cast<KICAD_DIFF::DOC_KIND>( aKind ), aAncestor,
507 aOurs, aTheirs, aOutput, aInteractive, aSingleFile,
508 aReporter );
509}
510
511
512int eeschemaOpenDiffDialogExport( int aKind, const wxString& aFileA, const wxString& aFileB,
513 const wxString& aLabelA, const wxString& aLabelB,
514 wxWindow* aParent, REPORTER* aReporter )
515{
516 return kiface.JobHandler()->OpenDiffDialog( static_cast<KICAD_DIFF::DOC_KIND>( aKind ), aFileA,
517 aFileB, aLabelA, aLabelB, aParent, aReporter );
518}
519
520} // namespace
521
522using namespace SCH;
523
524
526
527
528// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
529// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
530KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
531{
532 return &kiface;
533}
534
535
536bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
537{
538 // This is process-level-initialization, not project-level-initialization of the DSO.
539 // Do nothing in here pertinent to a project!
541
542 // Register the symbol editor settings as well because they share a KiFACE and need to be
543 // loaded prior to use to avoid threading deadlocks
545 aProgram->GetSettingsManager().RegisterSettings( symSettings ); // manager takes ownership
546
547 // We intentionally register KifaceSettings after SYMBOL_EDITOR_SETTINGS
548 // In legacy configs, many settings were in a single editor config nd the migration routine
549 // for the main editor file will try and call into the now separate settings stores
550 // to move the settings into them
552
553 start_common( aCtlBits );
554
555 m_kiway = aKiway;
556
557 m_jobHandler = std::make_unique<EESCHEMA_JOBS_HANDLER>( aKiway );
558
560 {
561 m_jobHandler->SetReporter( &CLI_REPORTER::GetInstance() );
562 m_jobHandler->SetProgressReporter( &CLI_PROGRESS_REPORTER::GetInstance() );
563 }
564
565 if( Pgm().ApiServerOrNull() )
566 {
567 m_apiHandlerSchLibs = std::make_unique<API_HANDLER_SCH_LIBRARIES>();
569 }
570
571 // Register the schematic and symbol-library merge drivers with libgit2 so
572 // `.gitattributes` entries `merge=kicad-sch` and `merge=kicad-sym-lib`
573 // route through KiCad-aware merge logic.
576
577 return true;
578}
579
580
582{
583 if( m_jobHandler )
584 m_jobHandler->ClearCachedSchematic();
585}
586
587
589{
590 constexpr static int interval = 150;
591 constexpr static int timeLimit = 120000;
592
593 wxCHECK( aKiway, /* void */ );
594
595 // Use compare_exchange to atomically check and set the flag to prevent race conditions
596 // when PreloadLibraries is called multiple times concurrently (e.g., from project manager
597 // and schematic editor both scheduling via CallAfter)
598 bool expected = false;
599
600 if( !m_libraryPreloadInProgress.compare_exchange_strong( expected, true ) )
601 return;
602
604
606 Pgm().GetBackgroundJobMonitor().Create( _( "Loading Symbol Libraries" ) );
607
608 auto preload =
609 [this, aKiway]() -> void
610 {
611 std::shared_ptr<BACKGROUND_JOB_REPORTER> reporter =
613
615
616 int elapsed = 0;
617 bool aborted = false;
618
619 reporter->Report( _( "Loading Symbol Libraries" ) );
620 adapter->AsyncLoad();
621
622 while( true )
623 {
624 if( m_libraryPreloadAbort.load() )
625 {
626 m_libraryPreloadAbort.store( false );
627 aborted = true;
628 break;
629 }
630
631 std::this_thread::sleep_for( std::chrono::milliseconds( interval ) );
632
633 if( std::optional<float> loadStatus = adapter->AsyncLoadProgress() )
634 {
635 float progress = *loadStatus;
636 reporter->SetCurrentProgress( progress );
637
638 if( progress >= 1 )
639 break;
640 }
641 else
642 {
643 reporter->SetCurrentProgress( 1 );
644 break;
645 }
646
647 elapsed += interval;
648
649 if( elapsed > timeLimit )
650 break;
651 }
652
653 // AbortAsyncLoad() sets the adapter's worker abort flag and then blocks,
654 // so workers exit at their next checkpoint. BlockUntilLoaded() alone just
655 // waits for each future to complete naturally, which can hang indefinitely
656 // if a worker is stuck on a stalled network or filesystem operation.
657 if( aborted )
658 adapter->AbortAsyncLoad();
659 else
660 adapter->BlockUntilLoaded();
661
662 // If aborted, skip operations that use the adapter since the project may have changed
663 // and the adapter's project reference could be stale. This prevents use-after-free
664 // crashes when switching projects during library preload.
665 if( !aborted )
666 {
667 // Collect library load errors for async reporting
669 }
670 else
671 {
672 wxLogTrace( traceLibraries, "eeschema PreloadLibraries: aborted, skipping symbol processing" );
673 }
674
677 m_libraryPreloadInProgress.store( false );
678
679 // Only send reload notifications if we weren't aborted
680 if( !aborted )
681 {
682 std::string payload = "";
683 aKiway->ExpressMail( FRAME_SCH, MAIL_RELOAD_LIB, payload, nullptr, true );
684 aKiway->ExpressMail( FRAME_SCH_SYMBOL_EDITOR, MAIL_RELOAD_LIB, payload, nullptr, true );
685 aKiway->ExpressMail( FRAME_SCH_VIEWER, MAIL_RELOAD_LIB, payload, nullptr, true );
686 }
687 };
688
689 std::future<void> preloadFuture = std::async( std::launch::async, preload );
690 m_libraryPreloadReturn = std::move( preloadFuture );
691}
692
693
694void IFACE::CancelPreload( bool aBlock )
695{
696 if( m_libraryPreloadInProgress.load() )
697 {
698 m_libraryPreloadAbort.store( true );
699
700 if( aBlock )
702 }
703}
704
705
707{
708 if( m_libraryPreloadInProgress.load() )
709 m_libraryPreloadAbort.store( true );
710}
711
712
714{
716 {
717 if( Pgm().ApiServerOrNull() )
719
720 m_apiHandlerSchLibs.reset();
721 }
722
723 // Release the CLI-cached schematic while the static ERC_ITEM tables it serializes against are
724 // still alive; deferring to static teardown crashes reading dangling severity keys
725 if( m_jobHandler )
726 m_jobHandler->ClearCachedSchematic();
727
728 end_common();
729}
730
731
732void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
733 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
734 const wxString& aSrcFilePath, wxString& aErrors )
735{
736 wxFileName destFile( aSrcFilePath );
737 wxString destPath = destFile.GetPathWithSep();
738 wxUniChar pathSep = wxFileName::GetPathSeparator();
739 wxString ext = destFile.GetExt();
740
741 if( destPath.StartsWith( aProjectBasePath + pathSep ) )
742 destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
743
744 destFile.SetPath( destPath );
745
750 {
751 if( destFile.GetName() == aProjectName )
752 {
753 destFile.SetName( aNewProjectName );
754 }
755 else if( destFile.GetName() == aNewProjectName )
756 {
757 wxString msg;
758
759 if( !aErrors.empty() )
760 aErrors += wxS( "\n" );
761
762 msg.Printf( _( "Cannot copy file '%s' as it will be overwritten by the new root "
763 "sheet file." ), destFile.GetFullPath() );
764 aErrors += msg;
765 return;
766 }
767
768 CopySexprFile( aSrcFilePath, destFile.GetFullPath(),
769 [&]( const std::string& token, wxString& value ) -> bool
770 {
771 if( token == "project" && value == aProjectName )
772 {
773 value = aNewProjectName;
774 return true;
775 }
776
777 return false;
778 },
779 aErrors );
780 }
782 {
783 // Symbols are not project-specific. Keep their source names.
784 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
785 }
789 {
790 if( destFile.GetName() == aProjectName + wxS( "-cache" ) )
791 destFile.SetName( aNewProjectName + wxS( "-cache" ) );
792
793 if( destFile.GetName() == aProjectName + wxS( "-rescue" ) )
794 destFile.SetName( aNewProjectName + wxS( "-rescue" ) );
795
796 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
797 }
798 else if( ext == FILEEXT::NetlistFileExtension )
799 {
800 if( destFile.GetName() == aProjectName )
801 destFile.SetName( aNewProjectName );
802
803 CopySexprFile( aSrcFilePath, destFile.GetFullPath(),
804 [&]( const std::string& token, wxString& value ) -> bool
805 {
806 if( token == "source" )
807 {
808 for( const wxString& extension : { wxString( wxT( ".sch" ) ), wxString( wxT( ".kicad_sch" ) ) } )
809 {
810 if( value == aProjectName + extension )
811 {
812 value = aNewProjectName + extension;
813 return true;
814 }
815 else if( value == aProjectBasePath + "/" + aProjectName + extension )
816 {
817 value = aNewProjectBasePath + "/" + aNewProjectName + extension;
818 return true;
819 }
820 else if( value.StartsWith( aProjectBasePath ) )
821 {
822 value.Replace( aProjectBasePath, aNewProjectBasePath, false );
823 return true;
824 }
825 }
826 }
827
828 return false;
829 },
830 aErrors );
831 }
832 else if( destFile.GetName() == FILEEXT::SymbolLibraryTableFileName )
833 {
834 wxFileName libTableFn( aSrcFilePath );
835 LIBRARY_TABLE libTable( libTableFn, LIBRARY_TABLE_SCOPE::PROJECT );
836 libTable.SetPath( destFile.GetFullPath() );
837 libTable.SetType( LIBRARY_TABLE_TYPE::SYMBOL );
838
839 for( LIBRARY_TABLE_ROW& row : libTable.Rows() )
840 {
841 wxString uri = row.URI();
842
843 uri.Replace( wxS( "/" ) + aProjectName + wxS( "-cache.lib" ),
844 wxS( "/" ) + aNewProjectName + wxS( "-cache.lib" ) );
845 uri.Replace( wxS( "/" ) + aProjectName + wxS( "-rescue.lib" ),
846 wxS( "/" ) + aNewProjectName + wxS( "-rescue.lib" ) );
847 uri.Replace( wxS( "/" ) + aProjectName + wxS( ".lib" ),
848 wxS( "/" ) + aNewProjectName + wxS( ".lib" ) );
849
850 row.SetURI( uri );
851 }
852
853 libTable.Save().map_error(
854 [&]( const LIBRARY_ERROR& aError )
855 {
856 wxString msg;
857
858 if( !aErrors.empty() )
859 aErrors += wxT( "\n" );
860
861 msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
862 aErrors += msg;
863 } );
864 }
865 else
866 {
867 wxFAIL_MSG( wxS( "Unexpected filetype for Eeschema::SaveFileAs()" ) );
868 }
869}
870
871
872int IFACE::HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter )
873{
874 return m_jobHandler->RunJob( aJob, aReporter, aProgressReporter );
875}
876
877
878bool IFACE::HandleJobConfig( JOB* aJob, wxWindow* aParent )
879{
880 return m_jobHandler->HandleJobConfig( aJob, aParent );
881}
882
883
884// TODO(JE) some of the below methods can probably be factored out and shared between sch/pcb
886{
887 if( m_openHandler )
888 {
889 if( aServer )
890 aServer->DeregisterHandler( m_openHandler.get() );
891
892 m_openHandler.reset();
893 }
894
895 m_openContext.reset();
896
897 delete m_openSchematic;
898 m_openSchematic = nullptr;
899
900 // The jobs handler caches the last-loaded schematic. Clear it so the next job
901 // uses the schematic from the newly opened document rather than a stale copy.
902 m_jobHandler->ClearCachedSchematic();
903}
904
905
907 KICAD_API_SERVER* aServer, wxString* aError )
908{
909 wxCHECK( aServer, false );
910
911 if( aSpec.kind == DOCUMENT_SPEC::KIND::CREATE_KIND )
912 return handleCreateSchematic( aSpec.path, aServer, aError );
913
914 if( aSpec.path.IsEmpty() )
915 {
916 if( aError )
917 *aError = wxS( "No path specified to open" );
918
919 return false;
920 }
921
922 wxFileName projectPath( aSpec.path );
923
924 if( projectPath.GetExt() == FILEEXT::KiCadSchematicFileExtension )
925 projectPath.SetExt( FILEEXT::ProjectFileExtension );
926 else if( projectPath.GetExt() != FILEEXT::ProjectFileExtension )
927 projectPath.SetExt( FILEEXT::ProjectFileExtension );
928
929 projectPath.MakeAbsolute();
930
931 // We currently only support one document per type (and each needs to come from
932 // the same project). This will need evolution once we support MDI and multi-project.
933 closeCurrentDocument( aServer );
934
935 SETTINGS_MANAGER& settingsManager = Pgm().GetSettingsManager();
936
937 // Reuse an already-loaded project if one exists for this path.
938 PROJECT* project = settingsManager.GetProject( projectPath.GetFullPath() );
939
940 if( !project )
941 {
942 if( !settingsManager.LoadProject( projectPath.GetFullPath(), true ) )
943 wxLogTrace( traceApi, "Warning: no project file found for %s", aSpec.path );
944
945 project = settingsManager.GetProject( projectPath.GetFullPath() );
946 }
947
948 if( !project )
949 {
950 if( aError )
951 *aError = wxString::Format( wxS( "Error loading project for %s" ), aSpec.path );
952
953 return false;
954 }
955
956 wxFileName schPath( projectPath );
957 schPath.SetExt( FILEEXT::KiCadSchematicFileExtension );
958
959 if( !schPath.FileExists() )
960 {
961 if( aError )
962 *aError = wxString::Format( wxS( "File not found: %s" ), schPath.GetFullPath() );
963
964 return false;
965 }
966
967 SCHEMATIC* schematic = nullptr;
968
969 try
970 {
971 schematic = EESCHEMA_HELPERS::LoadSchematic( schPath.GetFullPath(), false, false, project );
972
973 if( !schematic )
974 {
975 if( aError )
976 *aError = wxS( "Failed to load schematic" );
977
978 return false;
979 }
980 }
981 catch( ... )
982 {
983 if( aError )
984 *aError = wxS( "Failed to load schematic" );
985
986 return false;
987 }
988
990
991 m_openContext = std::make_shared<HEADLESS_SCH_CONTEXT>( &m_openSchematic, project, m_kiway );
992
994 {
995 m_apiHandlerSchLibs = std::make_unique<API_HANDLER_SCH_LIBRARIES>();
996 aServer->RegisterHandler( m_apiHandlerSchLibs.get() );
997 }
998
999 m_openHandler = std::make_unique<API_HANDLER_SCH>( m_openContext );
1000 aServer->RegisterHandler( m_openHandler.get() );
1001
1002 return true;
1003}
1004
1005
1006bool IFACE::handleCreateSchematic( const wxString& aPath, KICAD_API_SERVER* aServer, wxString* aError )
1007{
1008 wxFileName schPath( aPath );
1009 schPath.MakeAbsolute();
1010
1011 wxFileName projectPath( schPath );
1012 projectPath.SetExt( FILEEXT::ProjectFileExtension );
1013
1014 if( m_openSchematic && m_openSchematic->HasHierarchy() )
1015 {
1016 if( m_openSchematic->Hierarchy().IsModified() )
1017 {
1018 if( aError )
1019 *aError = wxS( "The current schematic has unsaved changes; save or revert it first" );
1020
1021 return false;
1022 }
1023 }
1024
1025 closeCurrentDocument( aServer );
1026
1027 SETTINGS_MANAGER& settingsManager = Pgm().GetSettingsManager();
1028
1029 PROJECT* project = settingsManager.GetProject( projectPath.GetFullPath() );
1030
1031 if( !project )
1032 {
1033 // Create the project settings in memory (LoadProject falls back to defaults when the
1034 // file does not exist on disk) without writing any files.
1035 settingsManager.LoadProject( projectPath.GetFullPath(), true );
1036 project = settingsManager.GetProject( projectPath.GetFullPath() );
1037 }
1038
1039 if( !project )
1040 {
1041 if( aError )
1042 *aError = wxString::Format( wxS( "Error creating project for %s" ), aPath );
1043
1044 return false;
1045 }
1046
1047 std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>( project );
1048 schematic->CreateDefaultScreens();
1049
1050 SCH_SCREENS screens( schematic->Root() );
1051 schematic->RootScreen()->SetFileName( schPath.GetFullPath() );
1052
1053 m_openSchematic = schematic.release();
1054
1055 m_openContext = std::make_shared<HEADLESS_SCH_CONTEXT>( &m_openSchematic, project, m_kiway );
1056
1057 if( !m_apiHandlerSchLibs )
1058 {
1059 m_apiHandlerSchLibs = std::make_unique<API_HANDLER_SCH_LIBRARIES>();
1060 aServer->RegisterHandler( m_apiHandlerSchLibs.get() );
1061 }
1062
1063 m_openHandler = std::make_unique<API_HANDLER_SCH>( m_openContext );
1064 aServer->RegisterHandler( m_openHandler.get() );
1065
1066 return true;
1067}
1068
1069
1070bool IFACE::HandleApiCloseDocument( const wxString& aSchFileName, KICAD_API_SERVER* aServer,
1071 wxString* aError )
1072{
1073 wxCHECK( aServer, false );
1074
1075 if( !m_openContext )
1076 {
1077 if( aError )
1078 *aError = wxS( "No document is currently open" );
1079
1080 return false;
1081 }
1082
1083 if( !aSchFileName.IsEmpty() )
1084 {
1085 wxFileName currentSch( m_openContext->GetCurrentFileName() );
1086
1087 if( currentSch.GetFullName() != aSchFileName )
1088 {
1089 if( aError )
1090 *aError = wxS( "Requested document does not match the open document" );
1091
1092 return false;
1093 }
1094 }
1095
1096 closeCurrentDocument( aServer );
1097 return true;
1098}
1099
1100
1102{
1103 wxCHECK_RET( aServer, "no API server provided" );
1104
1105 if( !m_apiHandlerSchLibs )
1106 {
1107 m_apiHandlerSchLibs = std::make_unique<API_HANDLER_SCH_LIBRARIES>();
1108 aServer->RegisterHandler( m_apiHandlerSchLibs.get() );
1109 }
1110}
1111
1112
1114{
1116
1117 if( !adapter )
1118 return false;
1119
1120 adapter->AsyncLoad();
1121 return true;
1122}
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
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:261
static bool IsOnStandardSocketPath()
static void AnnounceToPrimary(FRAME_T aFrameType)
The base frame for deriving all KiCad main window classes.
static void SetSchEditFrame(SCH_EDIT_FRAME *aSchEditFrame)
static SCHEMATIC * LoadSchematic(const wxString &aFileName, bool aSetActive, bool aForceDefaultProject, PROJECT *aProject=nullptr, bool aCalculateConnectivity=true, REPORTER *aRootReporter=nullptr)
Handle Eeschema job dispatches.
SNAP_INFERENCE_SETTINGS m_SnapInference
An simple container class that lets us dispatch output jobs to kifaces.
Definition job.h:184
void RegisterHandler(API_HANDLER *aHandler)
Adds a new request handler to the server.
void DeregisterHandler(API_HANDLER *aHandler)
A KIFACE implementation.
Definition kiface_base.h:35
KIFACE_BASE(const char *aKifaceName, KIWAY::FACE_T aId)
Definition kiface_base.h:63
void InitSettings(APP_SETTINGS_BASE *aSettings)
Definition kiface_base.h:93
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:91
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?
static int Apply(const git_merge_driver_source *aSrc, const char **aPathOut, unsigned int *aModeOut, git_buf *aMergedOut)
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:340
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:388
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:486
FACE_T
Known KIFACE implementations.
Definition kiway.h:346
@ FACE_SCH
eeschema DSO
Definition kiway.h:347
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition kiway.cpp:201
std::optional< float > AsyncLoadProgress() const
Returns async load progress between 0.0 and 1.0, or nullopt if load is not in progress.
std::vector< KI_ERROR > GetLibraryLoadErrors() const
Returns all library load errors as newline-separated strings for display.
void AbortAsyncLoad()
Aborts any async load in progress; blocks until fully done aborting.
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:101
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
Definition pgm_base.h:129
void AddLibraryLoadMessages(const std::vector< KI_ERROR > &aMessages)
Add library load messages to all registered status bars.
void ClearLibraryLoadMessages()
Clear library load messages from all registered status bars.
KICAD_API_SERVER & GetApiServer()
Definition pgm_base.h:141
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:123
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:63
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Holds all the data relating to one schematic.
Definition schematic.h:148
Schematic editor (Eeschema) main window.
Base class that schematic file and library loading and saving plugins should derive from.
Definition sch_io.h:60
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:69
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition sch_screen.h:758
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
bool IsVirtualRootSheet() const
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.
Implement an OUTPUTFORMATTER to a memory buffer.
Definition richio.h:430
const std::string & GetString()
Definition richio.h:453
Symbol library viewer main window.
SNAP_INFERENCE_SETTINGS m_SnapInference
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)
EDA_UNITS
Definition eda_units.h:44
SCH_SHEET * g_RootSheet
Definition eeschema.cpp:96
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition eeschema.cpp:525
@ PANEL_SYM_EDIT_GRIDS
Definition frame_type.h:74
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:31
@ PANEL_SCH_FIELD_NAME_TEMPLATES
Definition frame_type.h:86
@ PANEL_SCH_TOOLBARS
Definition frame_type.h:85
@ PANEL_SYM_SNAPPING
Definition frame_type.h:75
@ FRAME_SCH_VIEWER
Definition frame_type.h:32
@ PANEL_SCH_DISP_OPTIONS
Definition frame_type.h:80
@ PANEL_SCH_SIMULATOR
Definition frame_type.h:87
@ FRAME_SCH
Definition frame_type.h:30
@ PANEL_SYM_TOOLBARS
Definition frame_type.h:78
@ FRAME_SIMULATOR
Definition frame_type.h:34
@ PANEL_SYM_EDIT_OPTIONS
Definition frame_type.h:76
@ PANEL_SCH_EDIT_OPTIONS
Definition frame_type.h:83
@ PANEL_SYM_DISP_OPTIONS
Definition frame_type.h:73
@ DIALOG_SCH_LIBRARY_TABLE
Definition frame_type.h:132
@ PANEL_SCH_DATA_SOURCES
Definition frame_type.h:88
@ PANEL_SYM_COLORS
Definition frame_type.h:77
@ PANEL_SCH_SNAPPING
Definition frame_type.h:82
@ PANEL_SCH_GRIDS
Definition frame_type.h:81
@ PANEL_SCH_COLORS
Definition frame_type.h:84
@ DIALOG_DESIGN_BLOCK_LIBRARY_TABLE
Definition frame_type.h:131
@ FRAME_SYMBOL_CHOOSER
Definition frame_type.h:33
void CopySexprFile(const wxString &aSrcPath, const wxString &aDestPath, std::function< bool(const std::string &token, wxString &value)> aCallback, wxString &aErrors)
Definition gestfich.cpp:370
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
Definition gestfich.cpp:343
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.
const wxChar *const traceApi
Flag to enable debug output related to the IPC API and its plugin system.
Definition api_utils.cpp:33
#define KIFACE_API
@ KIFACE_MERGE_DOCUMENT
int (*)( int aKind, const wxString& aAncestor, const wxString& aOurs, const wxString& aTheirs,...
Definition kiface_ids.h:45
@ KIFACE_NETLIST_SCHEMATIC
Definition kiface_ids.h:38
@ KIFACE_OPEN_DIFF_DIALOG
int (*)( int aKind, const wxString& aFileA, const wxString& aFileB, const wxString& aLabelA,...
Definition kiface_ids.h:52
#define KFCTL_CLI
Running as CLI app.
Definition kiway.h:176
#define KIFACE_GETTER
Definition kiway.h:110
@ MAIL_RELOAD_LIB
Definition mail_type.h:53
DOC_KIND
Document type a diff/merge entry point should route to, derived from a file path's extension.
bool RegisterMergeDriver(const char *aName, MERGE_APPLY_FN aApply)
Register a KiCad merge driver with libgit2.
static int eeschemaMergeExport(int aKind, const wxString &aAncestor, const wxString &aOurs, const wxString &aTheirs, const wxString &aOutput, bool aInteractive, bool aSingleFile, REPORTER *aReporter)
Definition eeschema.cpp:502
static std::unique_ptr< SCHEMATIC > readSchematicFromFile(const std::string &aFilename)
Definition eeschema.cpp:113
SCH::IFACE KIFACE_BASE, UNITS_PROVIDER kiface("eeschema", KIWAY::FACE_SCH)
bool generateSchematicNetlist(const wxString &aFilename, std::string &aNetlist)
Definition eeschema.cpp:186
static int eeschemaOpenDiffDialogExport(int aKind, const wxString &aFileA, const wxString &aFileB, const wxString &aLabelA, const wxString &aLabelB, wxWindow *aParent, REPORTER *aReporter)
Definition eeschema.cpp:512
#define GNL_ALL
@ GNL_OPT_KICAD
void InvokeEditDesignBlockLibTable(KIWAY *aKiway, wxWindow *aParent)
PANEL_SNAPPING * CreateSnappingPanel(wxWindow *aParent, SETTINGS_T *aCfg, FRAME_T aFrameType, SNAP_INFERENCE_SETTINGS SETTINGS_T::*aInference=nullptr, MAGNETIC_SETTINGS SETTINGS_T::*aMagnetics=nullptr)
Build the snapping page for an editor.
void InvokeSchEditSymbolLibTable(KIWAY *aKiway, wxWindow *aParent)
PGM_BASE & Pgm()
The global program "get" accessor.
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.
wxString path
File path (KIND::FILE_KIND) or project path (KIND::FPID_KIND).
Definition kiway.h:164
Implement a participant in the KIWAY alchemy.
Definition kiway.h:153
std::future< void > m_libraryPreloadReturn
Definition eeschema.cpp:487
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
Definition eeschema.cpp:536
std::shared_ptr< BACKGROUND_JOB > m_libraryPreloadBackgroundJob
Definition eeschema.cpp:486
std::unique_ptr< API_HANDLER_SCH > m_openHandler
Definition eeschema.cpp:496
void PreloadLibraries(KIWAY *aKiway) override
Definition eeschema.cpp:588
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:732
void ProjectChanged() override
Definition eeschema.cpp:706
void CancelPreload(bool aBlock=true) override
Definition eeschema.cpp:694
void closeCurrentDocument(KICAD_API_SERVER *aServer)
Definition eeschema.cpp:885
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
Definition eeschema.cpp:215
EESCHEMA_JOBS_HANDLER * JobHandler() const
Accessor for the non-job diff/merge exports (eeschemaMergeExport etc.).
Definition eeschema.cpp:452
std::atomic_bool m_libraryPreloadAbort
Definition eeschema.cpp:489
KIWAY * m_kiway
Definition eeschema.cpp:493
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition eeschema.cpp:203
void RegisterLibraryHandlers(KICAD_API_SERVER *aServer) override
Register this face's library API handlers on the given server.
void Reset() override
Reloads global state.
Definition eeschema.cpp:581
bool HandleApiCloseDocument(const wxString &aSchFileName, KICAD_API_SERVER *aServer, wxString *aError) override
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
Definition eeschema.cpp:434
int HandleJob(JOB *aJob, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter) override
Definition eeschema.cpp:872
std::unique_ptr< EESCHEMA_JOBS_HANDLER > m_jobHandler
Definition eeschema.cpp:485
std::unique_ptr< API_HANDLER_SCH_LIBRARIES > m_apiHandlerSchLibs
Definition eeschema.cpp:497
bool LoadAllLibraries() override
Starts a background load of all libraries of the type owned by this face.
std::atomic_bool m_libraryPreloadInProgress
Definition eeschema.cpp:488
bool HandleApiOpenDocument(const DOCUMENT_SPEC &aSpec, KICAD_API_SERVER *aServer, wxString *aError) override
Definition eeschema.cpp:906
bool HandleJobConfig(JOB *aJob, wxWindow *aParent) override
Definition eeschema.cpp:878
std::shared_ptr< HEADLESS_SCH_CONTEXT > m_openContext
Definition eeschema.cpp:495
bool handleCreateSchematic(const wxString &aPath, KICAD_API_SERVER *aServer, wxString *aError)
SCHEMATIC * m_openSchematic
Definition eeschema.cpp:494
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
Definition eeschema.cpp:713
IbisParser parser & reporter
VECTOR3I expected(15, 30, 45)
static const long long MM
wxLogTrace helper definitions.
Definition of file extensions used in Kicad.