KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcbnew.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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[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>
30#include <confirm.h>
31#include <kiface_base.h>
32#include <kiface_ids.h>
33#include <pcb_edit_frame.h>
34#include <eda_dde.h>
35#include <macros.h>
36#include <wx/snglinst.h>
37#include <gestfich.h>
38#include <paths.h>
39#include <pcbnew_settings.h>
49#include <footprint_info_impl.h>
53#include <panel_edit_options.h>
63#include <project_pcb.h>
64#include <python_scripting.h>
65#include <string_utils.h>
66#include <thread_pool.h>
67#include <trace_helpers.h>
68#include <widgets/kistatusbar.h>
69
70#include <wx/tokenzr.h>
71
72#include "invoke_pcb_dialog.h"
74#include "pcbnew_jobs_handler.h"
75
79#include <toolbars_pcb_editor.h>
80
81#include <wx/crt.h>
82
83/* init functions defined by swig */
84
85extern "C" PyObject* PyInit__pcbnew( void );
86
87namespace PCB {
88
89static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
90{
91 // Of course all are virtual overloads, implementations of the KIFACE.
92
93 IFACE( const char* aName, KIWAY::FACE_T aType ) :
94 KIFACE_BASE( aName, aType ),
96 {}
97
98 bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) override;
99
100 void Reset() override;
101
102 void OnKifaceEnd() override;
103
104 wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
105 {
106 switch( aClassId )
107 {
108 case FRAME_PCB_EDITOR:
109 {
110 auto frame = new PCB_EDIT_FRAME( aKiway, aParent );
111
112 // give the scripting helpers access to our frame
114
115 if( Kiface().IsSingle() )
116 {
117 // only run this under single_top, not under a project manager.
118 frame->CreateServer( KICAD_PCB_PORT_SERVICE_NUMBER );
119 }
120
121 return frame;
122 }
123
125 return new FOOTPRINT_EDIT_FRAME( aKiway, aParent );
126
128 return new FOOTPRINT_VIEWER_FRAME( aKiway, aParent );
129
131 return new FOOTPRINT_CHOOSER_FRAME( aKiway, aParent );
132
134 return new FOOTPRINT_WIZARD_FRAME( aKiway, aParent, FRAME_T( aClassId ) );
135
137 return FOOTPRINT_PREVIEW_PANEL::New( aKiway, aParent, this );
138
140 {
141 DIALOG_CONFIGURE_PATHS dlg( aParent );
142
143 // The dialog's constructor probably failed to set its Kiway because the
144 // dynamic_cast fails when aParent was allocated by a separate compilation
145 // module. So set it directly.
146 dlg.SetKiway( &dlg, aKiway );
147
148 // Use QuasiModal so that HTML help window will work
149 if( dlg.ShowQuasiModal() == wxID_OK )
151
152 // Dialog has completed; nothing to return.
153 return nullptr;
154 }
155
157 InvokePcbLibTableEditor( aKiway, aParent );
158 // Dialog has completed; nothing to return.
159 return nullptr;
160
162 return new PANEL_DISPLAY_OPTIONS( aParent, GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" ) );
163
164 case PANEL_FP_GRIDS:
165 {
167 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
168
169 if( !frame )
170 frame = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
171
172 if( !frame )
173 frame = aKiway->Player( FRAME_PCB_EDITOR, false );
174
175 if( frame )
176 SetUserUnits( frame->GetUserUnits() );
177
178 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_FOOTPRINT_EDITOR );
179 }
180
184
186 {
187 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
188
189 if( !frame )
190 frame = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
191
192 if( !frame )
193 frame = aKiway->Player( FRAME_PCB_EDITOR, false );
194
195 if( frame )
196 SetUserUnits( frame->GetUserUnits() );
197
198 return new PANEL_EDIT_OPTIONS( aParent, this, frame, true );
199 }
200
202 {
203 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
204
205 if( !frame )
206 frame = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
207
208 if( !frame )
209 frame = aKiway->Player( FRAME_PCB_EDITOR, false );
210
211 if( frame )
212 SetUserUnits( frame->GetUserUnits() );
213
214 return new PANEL_FP_EDITOR_FIELD_DEFAULTS( aParent );
215 }
216
218 {
219 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
220
221 if( !frame )
222 frame = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
223
224 if( !frame )
225 frame = aKiway->Player( FRAME_PCB_EDITOR, false );
226
227 if( frame )
228 SetUserUnits( frame->GetUserUnits() );
229
230 return new PANEL_FP_EDITOR_GRAPHICS_DEFAULTS( aParent, this );
231 }
232
234 {
237
238 std::vector<TOOL_ACTION*> actions;
239 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
240
242 actions.push_back( action );
243
245 controls.push_back( control );
246
247 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
248 }
249
250 case PANEL_FP_COLORS:
251 return new PANEL_FP_EDITOR_COLOR_SETTINGS( aParent );
252
254 return new PANEL_DISPLAY_OPTIONS( aParent, GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) );
255
256 case PANEL_PCB_GRIDS:
257 {
259 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_PCB_EDITOR, false );
260
261 if( !frame )
262 frame = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
263
264 if( !frame )
265 frame = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
266
267 if( frame )
268 SetUserUnits( frame->GetUserUnits() );
269
270 return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_PCB_EDITOR );
271 }
272
276
278 {
279 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_PCB_EDITOR, false );
280
281 if( !frame )
282 frame = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
283
284 if( !frame )
285 frame = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
286
287 if( frame )
288 SetUserUnits( frame->GetUserUnits() );
289
290 return new PANEL_EDIT_OPTIONS( aParent, this, frame, false );
291 }
292
293 case PANEL_PCB_COLORS:
294 {
295 BOARD* board = nullptr;
296 EDA_BASE_FRAME* boardProvider = aKiway->Player( FRAME_PCB_EDITOR, false );
297
298 if( boardProvider )
299 board = static_cast<PCB_EDIT_FRAME*>( boardProvider )->GetBoard();
300
301 return new PANEL_PCBNEW_COLOR_SETTINGS( aParent, board );
302 }
303
308
309 std::vector<TOOL_ACTION*> actions;
310 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
313 actions.push_back( action );
316 controls.push_back( control );
318 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
319 }
320
322 return new PANEL_PCBNEW_ACTION_PLUGINS( aParent );
323
325 return new PANEL_3D_DISPLAY_OPTIONS( aParent );
326
327 case PANEL_3DV_OPENGL:
328 return new PANEL_3D_OPENGL_OPTIONS( aParent );
329
331 return new PANEL_3D_RAYTRACING_OPTIONS( aParent );
332
334 {
335 APP_SETTINGS_BASE* cfg = GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" );
336 TOOLBAR_SETTINGS* tb = GetToolbarSettings<EDA_3D_VIEWER_TOOLBAR_SETTINGS>( "3d_viewer-toolbars" );
337
338 std::vector<TOOL_ACTION*> actions;
339 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
340
341 for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
342 actions.push_back( action );
343
344 for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList( FRAME_PCB_DISPLAY3D ) )
345 controls.push_back( control );
346
347 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
348 }
349
350 default:
351 return nullptr;
352 }
353 }
354
365 void* IfaceOrAddress( int aDataId ) override
366 {
367 switch( aDataId )
368 {
369 // Return a pointer to the global instance of the footprint list.
371 return (void*) &GFootprintList;
372
374 // This is the mechanism by which FOOTPRINT_SELECT_WIDGET can get access to the adapter
375 // without directly linking to pcbnew or pcbcommon, going through PROJECT::FootprintLibAdapter
376 // TODO this is kind of cursed and needs thought to support multi-project
378
380 return reinterpret_cast<void*>( PyInit__pcbnew );
381
382 default:
383 return nullptr;
384 }
385 }
386
392 void SaveFileAs( const wxString& aProjectBasePath, const wxString& aSrcProjectName,
393 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
394 const wxString& aSrcFilePath, wxString& aErrors ) override;
395
396 int HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter ) override;
397
398 bool HandleJobConfig( JOB* aJob, wxWindow* aParent ) override;
399
400 void PreloadLibraries( KIWAY* aKiway ) override;
401 void ProjectChanged() override;
402 void CancelPreload( bool aBlock = true ) override;
403
404private:
405 std::unique_ptr<PCBNEW_JOBS_HANDLER> m_jobHandler;
406 std::shared_ptr<BACKGROUND_JOB> m_libraryPreloadBackgroundJob;
407 std::future<void> m_libraryPreloadReturn;
409 std::atomic_bool m_libraryPreloadAbort;
410
411} kiface( "pcbnew", KIWAY::FACE_PCB );
412
413} // namespace
414
415
416using namespace PCB;
417
418
420
421
422// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
423// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
424KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
425{
426 return &kiface;
427}
428
429
434
435
436bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
437{
438 // This is process-level-initialization, not project-level-initialization of the DSO.
439 // Do nothing in here pertinent to a project!
441
442 SETTINGS_MANAGER& mgr = aProgram->GetSettingsManager();
443
446
447 // We intentionally register KifaceSettings after FOOTPRINT_EDITOR_SETTINGS and EDA_3D_VIEWER_SETTINGS
448 // In legacy configs, many settings were in a single editor config and the migration routine
449 // for the main editor file will try and call into the now separate settings stores
450 // to move the settings into them
452
453 // Register the footprint editor settings as well because they share a KiFACE and need to be
454 // loaded prior to use to avoid threading deadlocks
456
457 start_common( aCtlBits );
458
459 m_jobHandler = std::make_unique<PCBNEW_JOBS_HANDLER>( aKiway );
460
462 {
463 m_jobHandler->SetReporter( &CLI_REPORTER::GetInstance() );
464 m_jobHandler->SetProgressReporter( &CLI_PROGRESS_REPORTER::GetInstance() );
465 }
466
467 return true;
468}
469
470
472{
473}
474
475
477{
478 end_common();
479}
480
481
482void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aSrcProjectName,
483 const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
484 const wxString& aSrcFilePath, wxString& aErrors )
485{
486 wxFileName destFile( aSrcFilePath );
487 wxString destPath = destFile.GetPathWithSep();
488 wxUniChar pathSep = wxFileName::GetPathSeparator();
489 wxString ext = destFile.GetExt();
490
491 if( destPath.StartsWith( aProjectBasePath + pathSep ) )
492 destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
493
494 wxString srcProjectFootprintLib = pathSep + aSrcProjectName + wxT( ".pretty" ) + pathSep;
495 wxString newProjectFootprintLib = pathSep + aNewProjectName + wxT( ".pretty" ) + pathSep;
496
497 destPath.Replace( srcProjectFootprintLib, newProjectFootprintLib, true );
498
499 destFile.SetPath( destPath );
500
503 {
504 if( destFile.GetName() == aSrcProjectName )
505 destFile.SetName( aNewProjectName );
506
507 CopySexprFile( aSrcFilePath, destFile.GetFullPath(),
508 [&]( const std::string& token, wxString& value )
509 {
510 if( token == "sheetfile" )
511 {
512 for( const wxString& extension : { wxT( ".sch" ), wxT( ".kicad_sch" ) } )
513 {
514 if( value == aSrcProjectName + extension )
515 {
516 value = aNewProjectName + extension;
517 return true;
518 }
519 else if( value == aProjectBasePath + "/" + aSrcProjectName + extension )
520 {
521 value = aNewProjectBasePath + "/" + aNewProjectName + extension;
522 return true;
523 }
524 else if( value.StartsWith( aProjectBasePath ) )
525 {
526 value.Replace( aProjectBasePath, aNewProjectBasePath, false );
527 return true;
528 }
529 }
530 }
531
532 return false;
533 },
534 aErrors );
535 }
536 else if( ext == FILEEXT::LegacyPcbFileExtension )
537 {
538 if( destFile.GetName() == aSrcProjectName )
539 destFile.SetName( aNewProjectName );
540
541 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
542 }
545 {
546 // Footprints are not project-specific. Keep their source names.
547 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
548 }
550 {
551 // TODO
552 }
553 else if( ext == wxT( "rpt" ) )
554 {
555 // DRC must be the "gold standard". Since we can't guarantee that there aren't
556 // any non-deterministic cases in the save-as algorithm, we don't want to certify
557 // the result with the source's DRC report. Therefore copy it under the old
558 // name.
559 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
560 }
561 else if( destFile.GetName() == FILEEXT::FootprintLibraryTableFileName )
562 {
563 wxFileName libTableFn( aSrcFilePath );
564 LIBRARY_TABLE libTable( libTableFn, LIBRARY_TABLE_SCOPE::PROJECT );
565 libTable.SetPath( destFile.GetFullPath() );
566 libTable.SetType( LIBRARY_TABLE_TYPE::FOOTPRINT );
567
568 for( LIBRARY_TABLE_ROW& row : libTable.Rows() )
569 {
570 wxString uri = row.URI();
571
572 uri.Replace( wxT( "/" ) + aSrcProjectName + wxT( ".pretty" ),
573 wxT( "/" ) + aNewProjectName + wxT( ".pretty" ) );
574
575 row.SetURI( uri );
576 }
577
578 libTable.Save().map_error(
579 [&]( const LIBRARY_ERROR& aError )
580 {
581 wxString msg;
582
583 if( !aErrors.empty() )
584 aErrors += wxT( "\n" );
585
586 msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
587 aErrors += msg;
588 } );
589 }
590 else
591 {
592 wxFAIL_MSG( wxT( "Unexpected filetype for Pcbnew::SaveFileAs()" ) );
593 }
594}
595
596
597int IFACE::HandleJob( JOB* aJob, REPORTER* aReporter, PROGRESS_REPORTER* aProgressReporter )
598{
599 return m_jobHandler->RunJob( aJob, aReporter, aProgressReporter );
600}
601
602
603bool IFACE::HandleJobConfig( JOB* aJob, wxWindow* aParent )
604{
605 return m_jobHandler->HandleJobConfig( aJob, aParent );
606}
607
608
610{
611 constexpr static int interval = 150;
612 constexpr static int timeLimit = 120000;
613
614 wxCHECK( aKiway, /* void */ );
615
616 if( m_libraryPreloadInProgress.load() )
617 return;
618
620
622 Pgm().GetBackgroundJobMonitor().Create( _( "Loading Footprint Libraries" ) );
623
624 auto preload =
625 [this, aKiway]() -> void
626 {
627 std::shared_ptr<BACKGROUND_JOB_REPORTER> reporter =
629
631
632 int elapsed = 0;
633
634 reporter->Report( _( "Loading Footprint Libraries" ) );
635 adapter->AsyncLoad();
636
637 while( true )
638 {
639 if( m_libraryPreloadAbort.load() )
640 {
641 m_libraryPreloadAbort.store( false );
642 break;
643 }
644
645 std::this_thread::sleep_for( std::chrono::milliseconds( interval ) );
646
647 if( std::optional<float> loadStatus = adapter->AsyncLoadProgress() )
648 {
649 float progress = *loadStatus;
650 reporter->SetCurrentProgress( progress );
651
652 if( progress >= 1 )
653 break;
654 }
655 else
656 {
657 reporter->SetCurrentProgress( 1 );
658 break;
659 }
660
661 elapsed += interval;
662
663 if( elapsed > timeLimit )
664 break;
665 }
666
667 adapter->BlockUntilLoaded();
668
669 // Collect and report library load errors from adapter
670 wxString errors = adapter->GetLibraryLoadErrors();
671
672 wxLogTrace( traceLibraries, "pcbnew PreloadLibraries: adapter errors.IsEmpty()=%d, length=%zu",
673 errors.IsEmpty(), errors.length() );
674
675 if( !errors.IsEmpty() )
676 {
677 std::vector<LOAD_MESSAGE> messages = ExtractLibraryLoadErrors( errors, RPT_SEVERITY_ERROR );
678
679 wxLogTrace( traceLibraries, " -> adapter: collected %zu messages", messages.size() );
680
681 if( !messages.empty() )
682 Pgm().AddLibraryLoadMessages( messages );
683 }
684 else
685 {
686 wxLogTrace( traceLibraries, " -> no errors from footprint adapter" );
687 }
688
689 // TODO: Remove once fp-info-cache isn't a thing
690 GFootprintList.ReadFootprintFiles( adapter, nullptr, reporter.get() );
691
692 // Also collect errors from GFootprintList
693 wxLogTrace( traceLibraries, " -> GFootprintList.GetErrorCount()=%u", GFootprintList.GetErrorCount() );
694
695 if( GFootprintList.GetErrorCount() > 0 )
696 {
697 std::vector<LOAD_MESSAGE> messages =
699
700 wxLogTrace( traceLibraries, " -> GFootprintList: collected %zu messages", messages.size() );
701
702 if( !messages.empty() )
703 Pgm().AddLibraryLoadMessages( messages );
704 }
705 else
706 {
707 wxLogTrace( traceLibraries, " -> no errors from GFootprintList" );
708 }
709
712 m_libraryPreloadInProgress.store( false );
713
714 std::string payload = "";
715 aKiway->ExpressMail( FRAME_PCB_EDITOR, MAIL_RELOAD_LIB, payload, nullptr, true );
716 aKiway->ExpressMail( FRAME_FOOTPRINT_EDITOR, MAIL_RELOAD_LIB, payload, nullptr, true );
717 aKiway->ExpressMail( FRAME_CVPCB, MAIL_RELOAD_LIB, payload, nullptr, true );
718 };
719
721 m_libraryPreloadInProgress.store( true );
722 m_libraryPreloadReturn = tp.submit_task( preload );
723}
724
725
727{
728 if( m_libraryPreloadInProgress.load() )
729 m_libraryPreloadAbort.store( true );
730}
731
732
733void IFACE::CancelPreload( bool aBlock )
734{
735 if( m_libraryPreloadInProgress.load() )
736 {
737 m_libraryPreloadAbort.store( true );
738
739 if( aBlock )
741 }
742}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
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(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.
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.
static FOOTPRINT_PREVIEW_PANEL * New(KIWAY *aKiway, wxWindow *aParent, UNITS_PROVIDER *aUnitsProvider)
Component library viewer main window.
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 SetKiway(wxWindow *aDest, KIWAY *aKiway)
It is only used for debugging, since "this" is not a wxWindow*.
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_PCB
pcbnew DSO
Definition kiway.h:302
virtual void CommonSettingsChanged(int aFlags=0)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition kiway.cpp:600
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.
The main frame for Pcbnew.
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 FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Take ownership of the pointer passed in.
Represent a single user action.
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_PCB_PORT_SERVICE_NUMBER
Pcbnew listens on this port for commands from Eeschema.
Definition eda_dde.h:40
EDA_UNITS
Definition eda_units.h:48
FOOTPRINT_LIST_IMPL GFootprintList
The global footprint info table.
Definition cvpcb.cpp:138
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:33
@ PANEL_PCB_GRIDS
Definition frame_type.h:97
@ FRAME_PCB_EDITOR
Definition frame_type.h:42
@ PANEL_3DV_TOOLBARS
Definition frame_type.h:107
@ FRAME_FOOTPRINT_VIEWER
Definition frame_type.h:45
@ PANEL_3DV_OPENGL
Definition frame_type.h:105
@ PANEL_FP_DEFAULT_GRAPHICS_VALUES
Definition frame_type.h:93
@ PANEL_PCB_TOOLBARS
Definition frame_type.h:100
@ PANEL_PCB_ORIGINS_AXES
Definition frame_type.h:102
@ FRAME_FOOTPRINT_WIZARD
Definition frame_type.h:46
@ PANEL_PCB_EDIT_OPTIONS
Definition frame_type.h:98
@ PANEL_FP_DISPLAY_OPTIONS
Definition frame_type.h:87
@ PANEL_PCB_COLORS
Definition frame_type.h:99
@ PANEL_3DV_RAYTRACING
Definition frame_type.h:106
@ DIALOG_PCB_LIBRARY_TABLE
Definition frame_type.h:125
@ FRAME_FOOTPRINT_PREVIEW
Definition frame_type.h:48
@ FRAME_FOOTPRINT_CHOOSER
Definition frame_type.h:44
@ PANEL_FP_GRIDS
Definition frame_type.h:88
@ PANEL_FP_ORIGINS_AXES
Definition frame_type.h:94
@ PANEL_PCB_DISPLAY_OPTS
Definition frame_type.h:96
@ DIALOG_CONFIGUREPATHS
Definition frame_type.h:122
@ PANEL_FP_COLORS
Definition frame_type.h:90
@ PANEL_FP_DEFAULT_FIELDS
Definition frame_type.h:92
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:43
@ FRAME_PCB_DISPLAY3D
Definition frame_type.h:47
@ PANEL_FP_EDIT_OPTIONS
Definition frame_type.h:89
@ PANEL_FP_TOOLBARS
Definition frame_type.h:91
@ PANEL_PCB_ACTION_PLUGINS
Definition frame_type.h:101
@ PANEL_3DV_DISPLAY_OPTIONS
Definition frame_type.h:104
@ FRAME_CVPCB
Definition frame_type.h:52
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 LegacyPcbFileExtension
static const std::string FootprintLibraryTableFileName
static const std::string BackupFileSuffix
static const std::string LegacyFootprintLibPathExtension
static const std::string FootprintAssignmentFileExtension
static const std::string KiCadFootprintFileExtension
static const std::string KiCadPcbFileExtension
const wxChar *const traceLibraries
Flag to enable library table and library manager tracing.
#define KIFACE_API
PROJECT & Prj()
Definition kicad.cpp:637
@ KIFACE_SCRIPTING_LEGACY
Definition kiface_ids.h:44
@ KIFACE_FOOTPRINT_LIBRARY_ADAPTER
Definition kiface_ids.h:40
@ KIFACE_FOOTPRINT_LIST
Return a pointer to the global instance of FOOTPRINT_LIST from pcbnew.
Definition kiface_ids.h:39
#define KFCTL_CLI
Running as CLI app.
Definition kiway.h:164
#define KIFACE_GETTER
Definition kiway.h:110
This file contains miscellaneous commonly used macros and functions.
@ MAIL_RELOAD_LIB
Definition mail_type.h:57
PCB::IFACE KIFACE_BASE, UNITS_PROVIDER kiface("pcbnew", KIWAY::FACE_PCB)
void InvokePcbLibTableEditor(KIWAY *aKiway, wxWindow *aCaller)
Function InvokePcbLibTableEditor shows the modal DIALOG_FP_LIB_TABLE for purposes of editing the glob...
PyObject * PyInit__pcbnew(void)
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition pcbnew.cpp:419
SETTINGS_MANAGER * GetSettingsManager()
void ScriptingSetPcbEditFrame(PCB_EDIT_FRAME *aPcbEditFrame)
BOARD * GetBoard()
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::atomic_bool m_libraryPreloadInProgress
Definition pcbnew.cpp:408
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
Definition pcbnew.cpp:436
void PreloadLibraries(KIWAY *aKiway) override
Definition pcbnew.cpp:609
void ProjectChanged() override
Definition pcbnew.cpp:726
void SaveFileAs(const wxString &aProjectBasePath, const wxString &aSrcProjectName, 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 pcbnew.cpp:482
void CancelPreload(bool aBlock=true) override
Definition pcbnew.cpp:733
std::shared_ptr< BACKGROUND_JOB > m_libraryPreloadBackgroundJob
Definition pcbnew.cpp:406
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
Definition pcbnew.cpp:365
void Reset() override
Reloads global state.
Definition pcbnew.cpp:471
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
Definition pcbnew.cpp:104
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition pcbnew.cpp:93
std::atomic_bool m_libraryPreloadAbort
Definition pcbnew.cpp:409
int HandleJob(JOB *aJob, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter) override
Definition pcbnew.cpp:597
std::unique_ptr< PCBNEW_JOBS_HANDLER > m_jobHandler
Definition pcbnew.cpp:405
bool HandleJobConfig(JOB *aJob, wxWindow *aParent) override
Definition pcbnew.cpp:603
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
Definition pcbnew.cpp:476
std::future< void > m_libraryPreloadReturn
Definition pcbnew.cpp:407
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
#define ENVVARS_CHANGED
wxLogTrace helper definitions.
Definition of file extensions used in Kicad.