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
26#include <pgm_base.h>
27#include <kiface_base.h>
29#include <confirm.h>
30#include <gestfich.h>
31#include <eda_dde.h>
33#include "eeschema_helpers.h"
34#include <eeschema_settings.h>
35#include <sch_edit_frame.h>
37#include <symbol_edit_frame.h>
38#include <symbol_viewer_frame.h>
40#include <symbol_lib_table.h>
47#include <kiway.h>
50#include <sexpr/sexpr.h>
51#include <sexpr/sexpr_parser.h>
52#include <kiface_ids.h>
54#include <wx/ffile.h>
56
57#include <schematic.h>
58#include <connection_graph.h>
68#include <sim/simulator_frame.h>
69
71#include <toolbars_sch_editor.h>
73
74#include <wx/crt.h>
75
76// The main sheet of the project
78
79
80namespace SCH {
81
82
83// TODO: This should move out of this file
84static std::unique_ptr<SCHEMATIC> readSchematicFromFile( const std::string& aFilename )
85{
86 SCH_IO* pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD );
87 std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>( nullptr );
88
90
91 // TODO: this must load the schematic's project, not a default project. At the very minimum
92 // variable resolution won't work without the project, but there might also be issues with
93 // netclasses, etc.
94 manager.LoadProject( "" );
95 schematic->Reset();
96 schematic->SetProject( &manager.Prj() );
97 schematic->SetRoot( pi->LoadSchematicFile( aFilename, schematic.get() ) );
98 schematic->CurrentSheet().push_back( &schematic->Root() );
99
100 SCH_SCREENS screens( schematic->Root() );
101
102 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
103 screen->UpdateLocalLibSymbolLinks();
104
105 SCH_SHEET_LIST sheets = schematic->Hierarchy();
106
107 // Restore all of the loaded symbol instances from the root sheet screen.
108 sheets.UpdateSymbolInstanceData( schematic->RootScreen()->GetSymbolInstances() );
109
110 if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
111 {
112 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
113 screen->FixLegacyPowerSymbolMismatches();
114 }
115
116 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
117 screen->MigrateSimModels();
118
119 sheets.AnnotatePowerSymbols();
120
121 // NOTE: This is required for multi-unit symbols to be correct
122 for( SCH_SHEET_PATH& sheet : sheets )
123 sheet.UpdateAllScreenReferences();
124
125 // TODO: this must handle SchematicCleanup somehow. The original version didn't because
126 // it knew that QA test cases were saved in a clean state.
127
128 // TODO: does this need to handle PruneOrphanedSymbolInstances() and
129 // PruneOrphanedSheetInstances()?
130
131 schematic->ConnectionGraph()->Recalculate( sheets, true );
132
133 return schematic;
134}
135
136
137// TODO: This should move out of this file
138bool generateSchematicNetlist( const wxString& aFilename, std::string& aNetlist )
139{
140 std::unique_ptr<SCHEMATIC> schematic = readSchematicFromFile( aFilename.ToStdString() );
141 NETLIST_EXPORTER_KICAD exporter( schematic.get() );
142 STRING_FORMATTER formatter;
143
144 exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
145 aNetlist = formatter.GetString();
146
147 return true;
148}
149
150
151static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
152{
153 // Of course all are virtual overloads, implementations of the KIFACE.
154
155 IFACE( const char* aName, KIWAY::FACE_T aType ) :
156 KIFACE_BASE( aName, aType ),
158 {}
159
160 bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) override;
161
162 void Reset() override;
163
164 void OnKifaceEnd() override;
165
166 wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
167 {
168 switch( aClassId )
169 {
170 case FRAME_SCH:
171 {
172 SCH_EDIT_FRAME* frame = new SCH_EDIT_FRAME( aKiway, aParent );
173
175
176 if( Kiface().IsSingle() )
177 {
178 // only run this under single_top, not under a project manager.
180 }
181
182 return frame;
183 }
184
186 return new SYMBOL_EDIT_FRAME( aKiway, aParent );
187
188 case FRAME_SIMULATOR:
189 {
190 try
191 {
192 SIMULATOR_FRAME* frame = new SIMULATOR_FRAME( aKiway, aParent );
193 return frame;
194 }
195 catch( const SIMULATOR_INIT_ERR& )
196 {
197 // catch the init err exception as we don't want it to bubble up
198 // its going to be some ngspice install issue but we don't want to log that
199 return nullptr;
200 }
201 }
202
203 case FRAME_SCH_VIEWER:
204 return new SYMBOL_VIEWER_FRAME( aKiway, aParent );
205
207 {
208 bool cancelled = false;
209 SYMBOL_CHOOSER_FRAME* chooser = new SYMBOL_CHOOSER_FRAME( aKiway, aParent, cancelled );
210
211 if( cancelled )
212 {
213 chooser->Destroy();
214 return nullptr;
215 }
216
217 return chooser;
218 }
219
221 InvokeSchEditSymbolLibTable( aKiway, aParent );
222 // Dialog has completed; nothing to return.
223 return nullptr;
224
226 InvokeEditDesignBlockLibTable( aKiway, aParent );
227 // Dialog has completed; nothing to return.
228 return nullptr;
231 return new PANEL_SYM_DISPLAY_OPTIONS( aParent, GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" ) );
232
235 APP_SETTINGS_BASE* cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" );
237
238 if( !frame )
239 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
241 if( !frame )
242 frame = aKiway->Player( FRAME_SCH, false );
243
244 if( frame )
245 SetUserUnits( frame->GetUserUnits() );
246
247 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH_SYMBOL_EDITOR );
248 }
249
251 {
252 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
253
254 if( !frame )
255 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
256
257 if( !frame )
258 frame = aKiway->Player( FRAME_SCH, false );
259
260 if( frame )
261 SetUserUnits( frame->GetUserUnits() );
262
263 return new PANEL_SYM_EDITING_OPTIONS( aParent, this, frame );
264 }
265
267 {
268 APP_SETTINGS_BASE* cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" );
269 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SYMBOL_EDIT_TOOLBAR_SETTINGS>( "symbol_editor-toolbars" );
270
271 std::vector<TOOL_ACTION*> actions;
272 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
273
275 actions.push_back( action );
276
278 controls.push_back( control );
279
280 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
281 }
282
283 case PANEL_SYM_COLORS:
284 return new PANEL_SYM_COLOR_SETTINGS( aParent );
285
287 return new PANEL_EESCHEMA_DISPLAY_OPTIONS( aParent, GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) );
288
289 case PANEL_SCH_GRIDS:
290 {
291 EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
292 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
293
294 if( !frame )
295 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
296
297 if( !frame )
298 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
299
300 if( frame )
301 SetUserUnits( frame->GetUserUnits() );
302
303 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH );
304 }
305
307 {
308 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
309
310 if( !frame )
311 frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
312
313 if( !frame )
314 frame = aKiway->Player( FRAME_SCH_VIEWER, false );
315
316 if( frame )
317 SetUserUnits( frame->GetUserUnits() );
318
319 return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, this, frame );
320 }
321
323 return new PANEL_EESCHEMA_ANNOTATION_OPTIONS( aParent, aKiway->Player( FRAME_SCH, false ) );
324
326 {
327 APP_SETTINGS_BASE* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
328 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SCH_EDIT_TOOLBAR_SETTINGS>( "eeschema-toolbars" );
329
330 std::vector<TOOL_ACTION*> actions;
331 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
332
334 actions.push_back( action );
335
337 controls.push_back( control );
338
339 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
340 }
341
342 case PANEL_SCH_COLORS:
343 return new PANEL_EESCHEMA_COLOR_SETTINGS( aParent );
344
346 return new PANEL_TEMPLATE_FIELDNAMES( aParent, nullptr );
347
349 return new PANEL_SIMULATOR_PREFERENCES( aParent );
350
351 default:
352 return nullptr;
353 }
354 }
355
366 void* IfaceOrAddress( int aDataId ) override
367 {
368 switch( aDataId )
369 {
371 return (void*) generateSchematicNetlist;
372 }
373
374 return nullptr;
375 }
376
382 void SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
383 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
384 const wxString& aSrcFilePath, wxString& aErrors ) override;
385
386
387 int HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter ) override;
388
389 bool HandleJobConfig( JOB* aJob, wxWindow* aParent ) override;
390
391private:
392 bool loadGlobalLibTable();
394
395 std::unique_ptr<EESCHEMA_JOBS_HANDLER> m_jobHandler;
396
397} kiface( "eeschema", KIWAY::FACE_SCH );
398
399} // namespace
400
401using namespace SCH;
402
403
405
406
407// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
408// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
409KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
410{
411 return &kiface;
412}
413
414
415bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
416{
417 // This is process-level-initialization, not project-level-initialization of the DSO.
418 // Do nothing in here pertinent to a project!
420
421 // Register the symbol editor settings as well because they share a KiFACE and need to be
422 // loaded prior to use to avoid threading deadlocks
424 aProgram->GetSettingsManager().RegisterSettings( symSettings ); // manager takes ownership
425
426 // We intentionally register KifaceSettings after SYMBOL_EDITOR_SETTINGS
427 // In legacy configs, many settings were in a single editor config nd the migration routine
428 // for the main editor file will try and call into the now separate settings stores
429 // to move the settings into them
431
432 start_common( aCtlBits );
433
435 {
436 // we didnt get anywhere deregister the settings
437 aProgram->GetSettingsManager().FlushAndRelease( symSettings, false );
438 aProgram->GetSettingsManager().FlushAndRelease( KifaceSettings(), false );
439 return false;
440 }
441
442 m_jobHandler = std::make_unique<EESCHEMA_JOBS_HANDLER>( aKiway );
443
445 {
446 m_jobHandler->SetReporter( &CLI_REPORTER::GetInstance() );
447 m_jobHandler->SetProgressReporter( &CLI_PROGRESS_REPORTER::GetInstance() );
448 }
449
450 return true;
451}
452
453
455{
457}
458
459
461{
463
464 if( !fn.FileExists() )
465 {
466 if( !( m_start_flags & KFCTL_CLI ) )
467 {
468 // Ensure the splash screen does not hide the dialog:
469 Pgm().HideSplash();
470
471 DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG symDialog( nullptr );
472
473 if( symDialog.ShowModal() != wxID_OK )
474 return false;
475 }
476 }
477 else
478 {
479 try
480 {
481 // The global table is not related to a specific project. All projects
482 // will use the same global table. So the KIFACE::OnKifaceStart() contract
483 // of avoiding anything project specific is not violated here.
485 return false;
486 }
487 catch( const IO_ERROR& ioe )
488 {
489 // if we are here, a incorrect global symbol library table was found.
490 // Incorrect global symbol library table is not a fatal error:
491 // the user just has to edit the (partially) loaded table.
492 wxString msg =
493 _( "An error occurred attempting to load the global symbol library table.\n"
494 "Please edit this global symbol library table in Preferences menu." );
495
496 DisplayErrorMessage( nullptr, msg, ioe.What() );
497 }
498 }
499
500 return true;
501}
502
503
505{
506 try
507 {
509
510 if( !fn.FileExists() )
511 {
512 DESIGN_BLOCK_LIB_TABLE emptyTable;
513 emptyTable.Save( fn.GetFullPath() );
514 }
515
516 // The global table is not related to a specific project. All projects
517 // will use the same global table. So the KIFACE::OnKifaceStart() contract
518 // of avoiding anything project specific is not violated here.
521 return false;
522 }
523 catch( const IO_ERROR& ioe )
524 {
525 // if we are here, a incorrect global design block library table was found.
526 // Incorrect global design block library table is not a fatal error:
527 // the user just has to edit the (partially) loaded table.
528 wxString msg =
529 _( "An error occurred attempting to load the global design block library table.\n"
530 "Please edit this global design block library table in Preferences menu." );
531
532 DisplayErrorMessage( nullptr, msg, ioe.What() );
533 }
534
535 return true;
536}
537
538
540{
541 end_common();
542}
543
544
545static void traverseSEXPR( SEXPR::SEXPR* aNode,
546 const std::function<void( SEXPR::SEXPR* )>& aVisitor )
547{
548 aVisitor( aNode );
549
550 if( aNode->IsList() )
551 {
552 for( unsigned i = 0; i < aNode->GetNumberOfChildren(); i++ )
553 traverseSEXPR( aNode->GetChild( i ), aVisitor );
554 }
555}
556
557
558void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
559 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
560 const wxString& aSrcFilePath, wxString& aErrors )
561{
562 wxFileName destFile( aSrcFilePath );
563 wxString destPath = destFile.GetPathWithSep();
564 wxUniChar pathSep = wxFileName::GetPathSeparator();
565 wxString ext = destFile.GetExt();
566
567 if( destPath.StartsWith( aProjectBasePath + pathSep ) )
568 destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
569
570 destFile.SetPath( destPath );
571
576 {
577 if( destFile.GetName() == aProjectName )
578 {
579 destFile.SetName( aNewProjectName );
580 }
581 else if( destFile.GetName() == aNewProjectName )
582 {
583 wxString msg;
584
585 if( !aErrors.empty() )
586 aErrors += wxS( "\n" );
587
588 msg.Printf( _( "Cannot copy file '%s' as it will be overwritten by the new root "
589 "sheet file." ), destFile.GetFullPath() );
590 aErrors += msg;
591 return;
592 }
593
594 // Sheet paths when auto-generated are relative to the root, so those will stay
595 // pointing to whatever they were pointing at.
596 // The author can create their own absolute and relative sheet paths. Absolute
597 // sheet paths aren't an issue, and relative ones will continue to work as long
598 // as the author didn't include any '..'s. If they did, it's still not clear
599 // whether they should be adjusted or not (as the author may be duplicating an
600 // entire tree with several projects within it), so we leave this as an exercise
601 // to the author.
602
603 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
604 }
606 {
607 // Symbols are not project-specific. Keep their source names.
608 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
609 }
613 {
614 if( destFile.GetName() == aProjectName + wxS( "-cache" ) )
615 destFile.SetName( aNewProjectName + wxS( "-cache" ) );
616
617 if( destFile.GetName() == aProjectName + wxS( "-rescue" ) )
618 destFile.SetName( aNewProjectName + wxS( "-rescue" ) );
619
620 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
621 }
622 else if( ext == FILEEXT::NetlistFileExtension )
623 {
624 bool success = false;
625
626 if( destFile.GetName() == aProjectName )
627 destFile.SetName( aNewProjectName );
628
629 try
630 {
631 SEXPR::PARSER parser;
632 std::unique_ptr<SEXPR::SEXPR> sexpr( parser.ParseFromFile( TO_UTF8( aSrcFilePath ) ) );
633
634 traverseSEXPR( sexpr.get(), [&]( SEXPR::SEXPR* node )
635 {
636 if( node->IsList() && node->GetNumberOfChildren() > 1
637 && node->GetChild( 0 )->IsSymbol()
638 && node->GetChild( 0 )->GetSymbol() == "source" )
639 {
640 auto pathNode = dynamic_cast<SEXPR::SEXPR_STRING*>( node->GetChild( 1 ) );
641 auto symNode = dynamic_cast<SEXPR::SEXPR_SYMBOL*>( node->GetChild( 1 ) );
642 wxString path;
643
644 if( pathNode )
645 path = pathNode->m_value;
646 else if( symNode )
647 path = symNode->m_value;
648
649 if( path == aProjectName + wxS( ".sch" ) )
650 path = aNewProjectName + wxS( ".sch" );
651 else if( path == aProjectBasePath + "/" + aProjectName + wxS( ".sch" ) )
652 path = aNewProjectBasePath + "/" + aNewProjectName + wxS( ".sch" );
653 else if( path.StartsWith( aProjectBasePath ) )
654 path.Replace( aProjectBasePath, aNewProjectBasePath, false );
655
656 if( pathNode )
657 pathNode->m_value = path;
658 else if( symNode )
659 symNode->m_value = path;
660 }
661 } );
662
663 wxFFile destNetList( destFile.GetFullPath(), "wb" );
664
665 if( destNetList.IsOpened() )
666 success = destNetList.Write( sexpr->AsString( 0 ) );
667
668 // wxFFile dtor will close the file
669 }
670 catch( ... )
671 {
672 success = false;
673 }
674
675 if( !success )
676 {
677 wxString msg;
678
679 if( !aErrors.empty() )
680 aErrors += wxS( "\n" );
681
682 msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
683 aErrors += msg;
684 }
685 }
686 else if( destFile.GetName() == FILEEXT::SymbolLibraryTableFileName )
687 {
688 SYMBOL_LIB_TABLE symbolLibTable;
689 symbolLibTable.Load( aSrcFilePath );
690
691 for( unsigned i = 0; i < symbolLibTable.GetCount(); i++ )
692 {
693 LIB_TABLE_ROW& row = symbolLibTable.At( i );
694 wxString uri = row.GetFullURI();
695
696 uri.Replace( wxS( "/" ) + aProjectName + wxS( "-cache.lib" ),
697 wxS( "/" ) + aNewProjectName + wxS( "-cache.lib" ) );
698 uri.Replace( wxS( "/" ) + aProjectName + wxS( "-rescue.lib" ),
699 wxS( "/" ) + aNewProjectName + wxS( "-rescue.lib" ) );
700 uri.Replace( wxS( "/" ) + aProjectName + wxS( ".lib" ),
701 wxS( "/" ) + aNewProjectName + wxS( ".lib" ) );
702
703 row.SetFullURI( uri );
704 }
705
706 try
707 {
708 symbolLibTable.Save( destFile.GetFullPath() );
709 }
710 catch( ... )
711 {
712 wxString msg;
713
714 if( !aErrors.empty() )
715 aErrors += "\n";
716
717 msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
718 aErrors += msg;
719 }
720 }
721 else
722 {
723 wxFAIL_MSG( wxS( "Unexpected filetype for Eeschema::SaveFileAs()" ) );
724 }
725}
726
727
728int IFACE::HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter )
729{
730 return m_jobHandler->RunJob( aJob, aReporter, aProgressReporter );
731}
732
733
734bool IFACE::HandleJobConfig( JOB* aJob, wxWindow* aParent )
735{
736 return m_jobHandler->HandleJobConfig( aJob, aParent );
737}
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.
Class to hold basic information about controls that can be added to the toolbars.
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.
Definition: app_settings.h:108
static PROGRESS_REPORTER & GetInstance()
static REPORTER & GetInstance()
Definition: reporter.cpp:141
static wxString GetGlobalTableFileName()
static bool LoadGlobalTable(DESIGN_BLOCK_LIB_TABLE &aTable)
Load the global design block library table into aTable.
static DESIGN_BLOCK_LIB_TABLE & GetGlobalLibTable()
int ShowModal() override
The base frame for deriving all KiCad main window classes.
static void SetSchEditFrame(SCH_EDIT_FRAME *aSchEditFrame)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
An simple container class that lets us dispatch output jobs to kifaces.
Definition: job.h:183
A KIFACE implementation.
Definition: kiface_base.h:39
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();.
Definition: kiface_base.cpp:42
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().
Definition: kiface_base.cpp:32
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_base.h:125
bool IsSingle() const
Is this KIFACE running under single_top?
Definition: kiface_base.h:107
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:286
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:395
FACE_T
Known KIFACE implementations.
Definition: kiway.h:292
@ FACE_SCH
eeschema DSO
Definition: kiway.h:293
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
void SetFullURI(const wxString &aFullURI)
Change the full URI for the library.
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
LIB_TABLE_ROW & At(unsigned aIndex)
Get the 'n'th LIB_TABLE_ROW object.
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
unsigned GetCount() const
Get the number of rows contained in the table.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
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:103
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
void HideSplash()
Definition: pgm_base.cpp:326
A progress reporter interface for use in multi-threaded environments.
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:57
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: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: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.
void FlushAndRelease(JSON_SETTINGS *aSettings, bool aSave=true)
If the given settings object is registered, save it to disk and unregister it.
std::unique_ptr< SEXPR > ParseFromFile(const std::string &aFilename)
size_t GetNumberOfChildren() const
Definition: sexpr.cpp:71
bool IsList() const
Definition: sexpr.h:49
SEXPR * GetChild(size_t aIndex) const
Definition: sexpr.cpp:49
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:449
const std::string & GetString()
Definition: richio.h:472
Symbol library viewer main window.
The symbol library editor main window.
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
static wxString GetGlobalTableFileName()
Fetch the global symbol library table file name.
static bool LoadGlobalTable(SYMBOL_LIB_TABLE &aTable)
Load the global symbol library table into aTable.
Symbol library viewer main window.
Represent a single user action.
Definition: tool_action.h:304
EDA_UNITS GetUserUnits() const
void SetUserUnits(EDA_UNITS aUnits)
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:194
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:77
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition: eeschema.cpp:404
static void traverseSEXPR(SEXPR::SEXPR *aNode, const std::function< void(SEXPR::SEXPR *)> &aVisitor)
Definition: eeschema.cpp:545
@ 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:84
@ PANEL_SCH_TOOLBARS
Definition: frame_type.h:83
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ PANEL_SCH_DISP_OPTIONS
Definition: frame_type.h:78
@ PANEL_SCH_SIMULATOR
Definition: frame_type.h:85
@ 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_SYM_COLORS
Definition: frame_type.h:75
@ PANEL_SCH_ANNO_OPTIONS
Definition: frame_type.h:81
@ PANEL_SCH_GRIDS
Definition: frame_type.h:79
@ PANEL_SCH_COLORS
Definition: frame_type.h:82
@ DIALOG_DESIGN_BLOCK_LIBRARY_TABLE
Definition: frame_type.h:123
@ FRAME_SYMBOL_CHOOSER
Definition: frame_type.h:37
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
Definition: gestfich.cpp:290
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
#define KIFACE_API
Definition: import_export.h:61
@ KIFACE_NETLIST_SCHEMATIC
Definition: kiface_ids.h:56
#define KFCTL_CLI
Running as CLI app.
Definition: kiway.h:162
#define KIFACE_GETTER
Definition: kiway.h:110
Definition: eeschema.cpp:80
static std::unique_ptr< SCHEMATIC > readSchematicFromFile(const std::string &aFilename)
Definition: eeschema.cpp:84
SCH::IFACE KIFACE_BASE, UNITS_PROVIDER kiface("eeschema", KIWAY::FACE_SCH)
bool generateSchematicNetlist(const wxString &aFilename, std::string &aNetlist)
Definition: eeschema.cpp:138
#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:902
see class PGM_BASE
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:429
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:153
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
Definition: eeschema.cpp:415
bool loadGlobalDesignBlockLibTable()
Definition: eeschema.cpp:504
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:558
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
Definition: eeschema.cpp:166
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition: eeschema.cpp:155
void Reset() override
Reloads global state.
Definition: eeschema.cpp:454
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
Definition: eeschema.cpp:366
int HandleJob(JOB *aJob, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter) override
Definition: eeschema.cpp:728
std::unique_ptr< EESCHEMA_JOBS_HANDLER > m_jobHandler
Definition: eeschema.cpp:395
bool loadGlobalLibTable()
Definition: eeschema.cpp:460
bool HandleJobConfig(JOB *aJob, wxWindow *aParent) override
Definition: eeschema.cpp:734
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
Definition: eeschema.cpp:539
Definition of file extensions used in Kicad.