KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kiway.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) 2014 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <cstring>
26
27#include <app_monitor.h>
28#include <core/ignore.h>
29#include <macros.h>
30#include <kiway.h>
31#include <kiway_player.h>
32#include <kiway_express.h>
33#include <pgm_base.h>
34#include <config.h>
35#include <core/arraydim.h>
36#include <id.h>
37#include <kiplatform/app.h>
40#include <tool/action_manager.h>
41#include <logging.h>
42
43#include <wx/dynlib.h>
44#include <wx/stdpaths.h>
45#include <wx/debug.h>
46#include <wx/utils.h>
47#include <confirm.h>
48
49KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT];
50int KIWAY::m_kiface_version[KIWAY_FACE_COUNT];
51
52
53
54KIWAY::KIWAY( int aCtlBits, wxFrame* aTop ):
55 m_ctl( aCtlBits ), m_top( nullptr ), m_blockingDialog( wxID_NONE )
56{
57 SetTop( aTop ); // hook player_destroy_handler() into aTop.
58
59 // Set the array of all known frame window IDs to empty = wxID_NONE,
60 // once they are be created, they are added with FRAME_T as index to this array.
61 // Note: A non empty entry does not mean the frame still exists.
62 // It means only the frame was created at least once. It can be destroyed after.
63 // These entries are not cleared automatically on window closing. The purpose is just
64 // to allow a call to wxWindow::FindWindowById() using a FRAME_T frame type
65 for( int n = 0; n < KIWAY_PLAYER_COUNT; n++ )
66 m_playerFrameId[n] = wxID_NONE;
67}
68
69
70#if 0
71// Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are
72// propagated upwards to parent windows if not handled below. Therefore the
73// m_top window should receive all wxWindowDestroyEvents originating from
74// KIWAY_PLAYERs. It does anyways, but now player_destroy_handler eavesdrops
75// on that event stream looking for KIWAY_PLAYERs being closed.
76
77void KIWAY::player_destroy_handler( wxWindowDestroyEvent& event )
78{
79 // Currently : do nothing
80 event.Skip(); // skip to who, the wxApp? I'm the top window.
81}
82#endif
83
84
85void KIWAY::SetTop( wxFrame* aTop )
86{
87#if 0
88 if( m_top )
89 {
90 m_top->Disconnect( wxEVT_DESTROY,
91 wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
92 nullptr, this );
93 }
94
95 if( aTop )
96 {
97 aTop->Connect( wxEVT_DESTROY,
98 wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
99 nullptr, this );
100 }
101#endif
102
103 m_top = aTop;
104}
105
106
107const wxString KIWAY::dso_search_path( FACE_T aFaceId )
108{
109 const char* name;
110
111 switch( aFaceId )
112 {
113 case FACE_SCH: name = KIFACE_PREFIX "eeschema"; break;
114 case FACE_PCB: name = KIFACE_PREFIX "pcbnew"; break;
115 case FACE_CVPCB: name = KIFACE_PREFIX "cvpcb"; break;
116 case FACE_GERBVIEW: name = KIFACE_PREFIX "gerbview"; break;
117 case FACE_PL_EDITOR: name = KIFACE_PREFIX "pl_editor"; break;
118 case FACE_PCB_CALCULATOR: name = KIFACE_PREFIX "pcb_calculator"; break;
119 case FACE_BMP2CMP: name = KIFACE_PREFIX "bitmap2component"; break;
120 case FACE_PYTHON: name = KIFACE_PREFIX "kipython"; break;
121
122 default:
123 wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
124 return wxEmptyString;
125 }
126
127#ifndef __WXMAC__
128 wxString path;
129
131 {
132 // The 2 *.cpp program launchers: single_top.cpp and kicad.cpp expect
133 // the *.kiface's to reside in same directory as their binaries do.
134 path = wxStandardPaths::Get().GetExecutablePath();
135 }
136
137 wxFileName fn = path;
138#else
139 // we have the dso's in main OSX bundle kicad.app/Contents/PlugIns
140 wxFileName fn = Pgm().GetExecutablePath();
141 fn.AppendDir( wxT( "Contents" ) );
142 fn.AppendDir( wxT( "PlugIns" ) );
143#endif
144
145 fn.SetName( name );
146
147 // To speed up development, it's sometimes nice to run kicad from inside
148 // the build path. In that case, each program will be in a subdirectory.
149 // To find the DSOs, we need to go up one directory and then enter a subdirectory.
150 if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
151 {
152#ifdef __WXMAC__
153 // On Mac, all of the kifaces are placed in the kicad.app bundle, even though the individual
154 // standalone binaries are placed in separate bundles before the make install step runs.
155 // So, we have to jump up to the kicad directory, then the PlugIns section of the kicad
156 // bundle.
157 fn = wxStandardPaths::Get().GetExecutablePath();
158
159 fn.RemoveLastDir();
160 fn.RemoveLastDir();
161 fn.RemoveLastDir();
162 fn.RemoveLastDir();
163 fn.AppendDir( wxT( "kicad" ) );
164 fn.AppendDir( wxT( "kicad.app" ) );
165 fn.AppendDir( wxT( "Contents" ) );
166 fn.AppendDir( wxT( "PlugIns" ) );
167 fn.SetName( name );
168#else
169 const char* dirName;
170
171 // The subdirectories usually have the same name as the kiface
172 switch( aFaceId )
173 {
174 case FACE_PL_EDITOR: dirName = "pagelayout_editor"; break;
175 case FACE_PYTHON: dirName = "scripting"; break;
176 default: dirName = name + 1; break;
177 }
178
179 fn.RemoveLastDir();
180 fn.AppendDir( dirName );
181#endif
182 }
183
184 // Here a "suffix" == an extension with a preceding '.',
185 // so skip the preceding '.' to get an extension
186 fn.SetExt( &KIFACE_SUFFIX[1] );
187
188 return fn.GetFullPath();
189}
190
191
193{
194 return Pgm().GetSettingsManager().Prj();
195}
196
197
198KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
199{
200 // Since this will be called from python, cannot assume that code will
201 // not pass a bad aFaceId.
202 if( (unsigned) aFaceId >= arrayDim( m_kiface ) )
203 {
204 // @todo : throw an exception here for python's benefit, at least that
205 // way it gets some explanatory text.
206
207 wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
208 return nullptr;
209 }
210
211 // return the previously loaded KIFACE, if it was.
212 if( m_kiface[aFaceId] )
213 return m_kiface[aFaceId];
214
215 // DSO with KIFACE has not been loaded yet, does caller want to load it?
216 if( doLoad )
217 {
218 wxString dname = dso_search_path( aFaceId );
219
220 // Insert DLL search path for kicad_3dsg from build dir
221 if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
222 {
223 wxFileName myPath = wxStandardPaths::Get().GetExecutablePath();
224
225 if( !myPath.GetPath().EndsWith( wxT( "pcbnew" ) ) )
226 {
227 myPath.RemoveLastDir();
228 myPath.AppendDir( wxT( "pcbnew" ) );
230 }
231 }
232
233 wxString msg;
234
235#ifdef KICAD_WIN32_VERIFY_CODESIGN
236 bool codeSignOk = KIPLATFORM::ENV::VerifyFileSignature( dname );
237 if( !codeSignOk )
238 {
239 msg.Printf( _( "Failed to verify kiface library '%s' signature." ), dname );
240 THROW_IO_ERROR( msg );
241 }
242#endif
243
244 wxDynamicLibrary dso;
245
246 void* addr = nullptr;
247
248 // For some reason wxDynamicLibrary::Load() crashes in some languages
249 // (chinese for instance) when loading the dynamic library.
250 // The crash happens for Eeschema.
251 // So switch to "C" locale during loading (LC_COLLATE is enough).
252 int lc_new_type = LC_COLLATE;
253 std::string user_locale = setlocale( lc_new_type, nullptr );
254 setlocale( lc_new_type, "C" );
255
256 bool success = dso.Load( dname, wxDL_VERBATIM | wxDL_NOW | wxDL_GLOBAL );
257
258 setlocale( lc_new_type, user_locale.c_str() );
259
260 msg = wxString::Format( "Loading kiface %d", aFaceId );
261 APP_MONITOR::AddNavigationBreadcrumb( msg, "kiway.kiface" );
262
263 if( !success )
264 {
265 // Failure: error reporting UI was done via wxLogSysError().
266 // No further reporting required here. Apparently this is not true on all
267 // platforms and/or wxWidgets builds and KiCad will crash. Throwing the exception
268 // here and catching it in the KiCad launcher resolves the crash issue. See bug
269 // report https://bugs.launchpad.net/kicad/+bug/1577786.
270
271 msg.Printf( _( "Failed to load kiface library '%s'." ), dname );
272 THROW_IO_ERROR( msg );
273 }
274 else if( ( addr = dso.GetSymbol( wxT( KIFACE_INSTANCE_NAME_AND_VERSION ) ) ) == nullptr )
275 {
276 // Failure: error reporting UI was done via wxLogSysError().
277 // No further reporting required here. Assume the same thing applies here as
278 // above with the Load() call. This has not been tested.
279 msg.Printf( _( "Could not read instance name and version from kiface library '%s'." ),
280 dname );
281 THROW_IO_ERROR( msg );
282 }
283 else
284 {
285 KIFACE_GETTER_FUNC* ki_getter = (KIFACE_GETTER_FUNC*) addr;
286
287 KIFACE* kiface = ki_getter( &m_kiface_version[aFaceId], KIFACE_VERSION, &Pgm() );
288
289 // KIFACE_GETTER_FUNC function comment (API) says the non-NULL is unconditional.
290 wxASSERT_MSG( kiface,
291 wxT( "attempted DSO has a bug, failed to return a KIFACE*" ) );
292
293 wxDllType dsoHandle = dso.Detach();
294
295 bool startSuccess = false;
296
297 // Give the DSO a single chance to do its "process level" initialization.
298 // "Process level" specifically means stay away from any projects in there.
299
300 try
301 {
302 startSuccess = kiface->OnKifaceStart( &Pgm(), m_ctl, this );
303 }
304 catch (...)
305 {
306 // OnKiFaceStart may generate an exception
307 // Before we continue and ultimately unload our module to retry we need
308 // to process the exception before we delete the free the memory space the
309 // exception resides in
310 Pgm().HandleException( std::current_exception() );
311 }
312
313 if( startSuccess )
314 {
315 return m_kiface[aFaceId] = kiface;
316 }
317 else
318 {
319 // Usually means canceled initial global library setup
320 // But it could have been an exception/failure
321 // Let the module go out of scope to unload
322 dso.Attach( dsoHandle );
323
324 return nullptr;
325 }
326 }
327 }
328
329 return nullptr;
330}
331
332
334{
335 switch( aFrameType )
336 {
337 case FRAME_SCH:
339 case FRAME_SCH_VIEWER:
341 case FRAME_SIMULATOR:
342 return FACE_SCH;
343
344 case FRAME_PCB_EDITOR:
350 return FACE_PCB;
351
352 case FRAME_CVPCB:
354 return FACE_CVPCB;
355
356 case FRAME_PYTHON:
357 return FACE_PYTHON;
358
359 case FRAME_GERBER:
360 return FACE_GERBVIEW;
361
362 case FRAME_PL_EDITOR:
363 return FACE_PL_EDITOR;
364
365 case FRAME_CALC:
366 return FACE_PCB_CALCULATOR;
367
368 case FRAME_BM2CMP:
369 return FACE_BMP2CMP;
370
371 default:
372 return FACE_T( -1 );
373 }
374}
375
376
378{
379 wxWindowID storedId = m_playerFrameId[aFrameType];
380
381 if( storedId == wxID_NONE )
382 return nullptr;
383
384 wxWindow* frame = wxWindow::FindWindowById( storedId );
385
386 // Since wxWindow::FindWindow*() is not cheap (especially if the window does not exist),
387 // clear invalid entries to save CPU on repeated calls that do not lead to frame creation
388 if( !frame )
389 m_playerFrameId[aFrameType].compare_exchange_strong( storedId, wxID_NONE );
390
391 return static_cast<KIWAY_PLAYER*>( frame );
392}
393
394
395KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate, wxTopLevelWindow* aParent )
396{
397 // Since this will be called from python, cannot assume that code will
398 // not pass a bad aFrameType.
399 if( (unsigned) aFrameType >= KIWAY_PLAYER_COUNT )
400 {
401 // @todo : throw an exception here for python's benefit, at least that
402 // way it gets some explanatory text.
403
404 wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) );
405 return nullptr;
406 }
407
408 // return the previously opened window
409 KIWAY_PLAYER* frame = GetPlayerFrame( aFrameType );
410
411 if( frame )
412 return frame;
413
414 if( doCreate )
415 {
416 try
417 {
418 wxString msg = wxString::Format( "Creating window type %d", aFrameType );
419 APP_MONITOR::AddNavigationBreadcrumb( msg, "kiway.player" );
420
421 FACE_T face_type = KifaceType( aFrameType );
422 KIFACE* kiface = KiFACE( face_type );
423
424 if( !kiface )
425 return nullptr;
426
428 aParent, // Parent window of frame in modal mode,
429 // NULL in non modal mode
430 aFrameType,
431 this,
432 m_ctl // questionable need, these same flags
433 // were passed to KIFACE::OnKifaceStart()
434 );
435 if( frame )
436 m_playerFrameId[aFrameType].store( frame->GetId() );
437
438 return frame;
439 }
440 catch( ... )
441 {
442 Pgm().HandleException( std::current_exception() );
443 wxLogError( _( "Error loading editor." ) );
444 }
445 }
446
447 return nullptr;
448}
449
450
451bool KIWAY::PlayerClose( FRAME_T aFrameType, bool doForce )
452{
453 // Since this will be called from python, cannot assume that code will
454 // not pass a bad aFrameType.
455 if( (unsigned) aFrameType >= KIWAY_PLAYER_COUNT )
456 {
457 // @todo : throw an exception here for python's benefit, at least that
458 // way it gets some explanatory text.
459
460 wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) );
461 return false;
462 }
463
464 KIWAY_PLAYER* frame = GetPlayerFrame( aFrameType );
465
466 if( frame == nullptr ) // Already closed
467 return true;
468
469 wxString msg = wxString::Format( "Closing window type %d", aFrameType );
470 APP_MONITOR::AddNavigationBreadcrumb( msg, "kiway.playerclose" );
471
472 if( frame->NonUserClose( doForce ) )
473 {
474 m_playerFrameId[aFrameType] = wxID_NONE;
475 return true;
476 }
477
478 return false;
479}
480
481
482bool KIWAY::PlayersClose( bool doForce )
483{
484 bool ret = true;
485
486 for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
487 ret = ret && PlayerClose( FRAME_T( i ), doForce );
488
489 return ret;
490}
491
492
494{
495 m_playerFrameId[aFrameType] = wxID_NONE;
496}
497
498
499void KIWAY::ExpressMail( FRAME_T aDestination, MAIL_T aCommand, std::string& aPayload,
500 wxWindow* aSource )
501{
502 KIWAY_EXPRESS mail( aDestination, aCommand, aPayload, aSource );
503
504 ProcessEvent( mail );
505}
506
507
508void KIWAY::GetActions( std::vector<TOOL_ACTION*>& aActions ) const
509{
511 aActions.push_back( action );
512}
513
514
515void KIWAY::SetLanguage( int aLanguage )
516{
517 wxString errMsg;
518 bool ret = false;
519
520 {
521 // Only allow the traces to be logged by wx. We use our own system to log when the
522 // OS doesn't support the language, so we want to hide the wx error.
523 WX_LOG_TRACE_ONLY logtraceOnly;
524 Pgm().SetLanguageIdentifier( aLanguage );
525 ret = Pgm().SetLanguage( errMsg );
526 }
527
528 if( !ret )
529 {
530 wxString lang;
531
532 for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
533 {
534 if( aLanguage == LanguagesList[ii].m_KI_Lang_Identifier )
535 {
536 if( LanguagesList[ii].m_DoNotTranslate )
537 lang = LanguagesList[ii].m_Lang_Label;
538 else
539 lang = wxGetTranslation( LanguagesList[ii].m_Lang_Label );
540
541 break;
542 }
543 }
544
545 DisplayErrorMessage( nullptr,
546 wxString::Format( _( "Unable to switch language to %s" ), lang ),
547 errMsg );
548 return;
549 }
550
551#if 1
552 // This is a risky hack that goes away if we allow the language to be
553 // set only from the top most frame if !Kiface.IsSingle()
554
555 // Only for the C++ project manager, and not for the python one and not for
556 // single_top do we look for the EDA_BASE_FRAME as the top level window.
557 // For single_top this is not needed because that window is registered in
558 // the array below.
560 {
561 // A dynamic_cast could be better, but creates link issues
562 // (some basic_frame functions not found) on some platforms,
563 // so a static_cast is used.
564 EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
565
566 if ( top )
567 {
568 top->ShowChangedLanguage();
569 wxCommandEvent e( EDA_LANG_CHANGED );
570 top->GetEventHandler()->ProcessEvent( e );
571 }
572 }
573#endif
574
575 for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
576 {
577 KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i );
578
579 if( frame )
580 {
581 frame->ShowChangedLanguage();
582 wxCommandEvent e( EDA_LANG_CHANGED );
583 frame->GetEventHandler()->ProcessEvent( e );
584 }
585 }
586}
587
588
590{
592 {
593 // A dynamic_cast could be better, but creates link issues
594 // (some basic_frame functions not found) on some platforms,
595 // so a static_cast is used.
596 EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
597
598 if( top )
599 top->CommonSettingsChanged( aFlags );
600 }
601
602 for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
603 {
604 KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i );
605
606 if( frame )
607 frame->CommonSettingsChanged( aFlags );
608 }
609}
610
611
613{
614 APP_MONITOR::AddNavigationBreadcrumb( "Changing project", "kiway.projectchanged" );
615
617 {
618 // A dynamic_cast could be better, but creates link issues
619 // (some basic_frame functions not found) on some platforms,
620 // so a static_cast is used.
621 EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
622
623 if( top )
624 top->ProjectChanged();
625 }
626
627 for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
628 {
629 KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i );
630
631 if( frame )
632 frame->ProjectChanged();
633 }
634}
635
636
638{
639 return wxWindow::FindWindowById( m_blockingDialog );
640}
641
642
643void KIWAY::SetBlockingDialog( wxWindow* aWin )
644{
645 if( !aWin )
646 m_blockingDialog = wxID_NONE;
647 else
648 m_blockingDialog = aWin->GetId();
649}
650
651
652bool KIWAY::ProcessEvent( wxEvent& aEvent )
653{
654 KIWAY_EXPRESS* mail = dynamic_cast<KIWAY_EXPRESS*>( &aEvent );
655
656 if( mail )
657 {
658 FRAME_T dest = mail->Dest();
659
660 // see if recipient is alive
661 KIWAY_PLAYER* alive = Player( dest, false );
662
663 if( alive )
664 {
665#if 1
666 return alive->ProcessEvent( aEvent );
667#else
668 alive->KiwayMailIn( *mail );
669 return true;
670#endif
671 }
672 }
673
674 return false;
675}
676
677
678int KIWAY::ProcessJob( KIWAY::FACE_T aFace, JOB* job, REPORTER* aReporter )
679{
680 KIFACE* kiface = KiFACE( aFace );
681
682 return kiface->HandleJob( job, aReporter );
683}
684
685
686bool KIWAY::ProcessJobConfigDialog( KIWAY::FACE_T aFace, JOB* aJob, wxWindow* aWindow )
687{
688 KIFACE* kiface = KiFACE( aFace );
689
690 return kiface->HandleJobConfig( aJob, aWindow );
691}
692
693
695{
697 {
698 // A dynamic_cast could be better, but creates link issues
699 // (some basic_frame functions not found) on some platforms,
700 // so a static_cast is used.
701 EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
702
703 if( top )
704 top->Close( false );
705 }
706}
707
708
710{
711 for( KIFACE* i : m_kiface )
712 {
713 if( i )
714 i->OnKifaceEnd();
715 }
716}
const char * name
Definition: DXF_plotter.cpp:62
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
static std::list< TOOL_ACTION * > & GetActionList()
Return list of TOOL_ACTIONs.
The base frame for deriving all KiCad main window classes.
bool NonUserClose(bool aForce)
virtual void ProjectChanged()
Notification event that the project has changed.
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
An simple container class that lets us dispatch output jobs to kifaces.
Definition: job.h:183
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:40
FRAME_T Dest()
Return the destination player id of the message.
Definition: kiway_express.h:45
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
virtual void KiwayMailIn(KIWAY_EXPRESS &aEvent)
Receive KIWAY_EXPRESS messages from other players.
void OnKiCadExit()
Definition: kiway.cpp:694
bool ProcessJobConfigDialog(KIWAY::FACE_T aFace, JOB *aJob, wxWindow *aWindow)
Definition: kiway.cpp:686
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
const wxString dso_search_path(FACE_T aFaceId)
Get the [path &] name of the DSO holding the requested FACE_T.
Definition: kiway.cpp:107
void SetBlockingDialog(wxWindow *aWin)
Definition: kiway.cpp:643
virtual bool PlayerClose(FRAME_T aFrameType, bool doForce)
Call the KIWAY_PLAYER::Close( bool force ) function on the window and if not vetoed,...
Definition: kiway.cpp:451
static FACE_T KifaceType(FRAME_T aFrameType)
A simple mapping function which returns the FACE_T which is known to implement aFrameType.
Definition: kiway.cpp:333
wxWindowID m_blockingDialog
Definition: kiway.h:473
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
Definition: kiway.cpp:637
static KIFACE * m_kiface[KIWAY_FACE_COUNT]
Definition: kiway.h:466
wxFrame * m_top
Definition: kiway.h:471
virtual void SetLanguage(int aLanguage)
Change the language and then calls ShowChangedLanguage() on all #KIWAY_PLAYERs.
Definition: kiway.cpp:515
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
Definition: kiway.cpp:198
FACE_T
Known KIFACE implementations.
Definition: kiway.h:291
@ FACE_SCH
eeschema DSO
Definition: kiway.h:292
@ FACE_PL_EDITOR
Definition: kiway.h:296
@ FACE_PYTHON
Definition: kiway.h:299
@ FACE_PCB
pcbnew DSO
Definition: kiway.h:293
@ FACE_CVPCB
Definition: kiway.h:294
@ FACE_GERBVIEW
Definition: kiway.h:295
@ FACE_BMP2CMP
Definition: kiway.h:298
@ FACE_PCB_CALCULATOR
Definition: kiway.h:297
static int m_kiface_version[KIWAY_FACE_COUNT]
Definition: kiway.h:467
KIWAY_PLAYER * GetPlayerFrame(FRAME_T aFrameType)
Definition: kiway.cpp:377
bool ProcessEvent(wxEvent &aEvent) override
Definition: kiway.cpp:652
virtual bool PlayersClose(bool doForce)
Call the KIWAY_PLAYER::Close( bool force ) function on all the windows and if none are vetoed,...
Definition: kiway.cpp:482
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob, REPORTER *aReporter=nullptr)
Definition: kiway.cpp:678
std::atomic< wxWindowID > m_playerFrameId[KIWAY_PLAYER_COUNT]
Definition: kiway.h:481
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:499
void OnKiwayEnd()
Definition: kiway.cpp:709
KIWAY(int aCtlBits, wxFrame *aTop=nullptr)
Definition: kiway.cpp:54
virtual void CommonSettingsChanged(int aFlags=0)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition: kiway.cpp:589
void PlayerDidClose(FRAME_T aFrameType)
Notifies a Kiway that a player has been closed.
Definition: kiway.cpp:493
virtual void GetActions(std::vector< TOOL_ACTION * > &aActions) const
Append all registered actions to the given list.
Definition: kiway.cpp:508
void SetTop(wxFrame *aTop)
Tell this KIWAY about the top most frame in the program and optionally allows it to play the role of ...
Definition: kiway.cpp:85
virtual void ProjectChanged()
Calls ProjectChanged() on all KIWAY_PLAYERs.
Definition: kiway.cpp:612
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:192
int m_ctl
Definition: kiway.h:469
virtual void SetLanguageIdentifier(int menu_id)
Set in .m_language_id member the wxWidgets language identifier ID from the KiCad menu id (internal me...
Definition: pgm_base.cpp:704
void HandleException(std::exception_ptr aPtr)
A exception handler to be used at the top level if exceptions bubble up that for.
Definition: pgm_base.cpp:817
virtual const wxString & GetExecutablePath() const
Definition: pgm_base.cpp:870
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
virtual bool SetLanguage(wxString &aErrMsg, bool first_time=false)
Set the dictionary file name for internationalization.
Definition: pgm_base.cpp:562
Container for project specific data.
Definition: project.h:65
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:73
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
Represent a single user action.
Definition: tool_action.h:304
A logger class that filters out all log messages that are not generated by wxLogTrace and ignores the...
Definition: logging.h:32
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:203
This file is part of the common library.
#define _(s)
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:33
@ FRAME_PCB_EDITOR
Definition: frame_type.h:42
@ FRAME_CALC
Definition: frame_type.h:63
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ FRAME_CVPCB_DISPLAY
Definition: frame_type.h:53
@ FRAME_FOOTPRINT_VIEWER
Definition: frame_type.h:45
@ FRAME_BM2CMP
Definition: frame_type.h:61
@ FRAME_FOOTPRINT_WIZARD
Definition: frame_type.h:46
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ FRAME_SCH
Definition: frame_type.h:34
@ FRAME_SIMULATOR
Definition: frame_type.h:38
@ KIWAY_PLAYER_COUNT
Definition: frame_type.h:65
@ FRAME_FOOTPRINT_CHOOSER
Definition: frame_type.h:44
@ FRAME_PL_EDITOR
Definition: frame_type.h:59
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:43
@ FRAME_GERBER
Definition: frame_type.h:57
@ FRAME_PYTHON
Definition: frame_type.h:55
@ FRAME_PCB_DISPLAY3D
Definition: frame_type.h:47
@ FRAME_CVPCB
Definition: frame_type.h:52
@ FRAME_SYMBOL_CHOOSER
Definition: frame_type.h:37
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:39
#define KFCTL_CPP_PROJECT_SUITE
Running under C++ project mgr, possibly with others.
Definition: kiway.h:160
KIFACE * KIFACE_GETTER_FUNC(int *aKIFACEversion, int aKIWAYversion, PGM_BASE *aProgram)
Point to the one and only KIFACE export.
Definition: kiway.h:504
#define KIFACE_INSTANCE_NAME_AND_VERSION
Definition: kiway.h:114
#define KIFACE_VERSION
The KIWAY and KIFACE classes are used to communicate between various process modules,...
Definition: kiway.h:109
#define KFCTL_STANDALONE
Running as a standalone Top.
Definition: kiway.h:159
This file contains miscellaneous commonly used macros and functions.
MAIL_T
The set of mail types sendable via KIWAY::ExpressMail() and supplied as the aCommand parameter to tha...
Definition: mail_type.h:38
void AddNavigationBreadcrumb(const wxString &aMsg, const wxString &aCategory)
Add a navigation breadcrumb.
void AddDynamicLibrarySearchPath(const wxString &aPath)
Inserts a search path for loading dynamic libraries.
Definition: unix/app.cpp:100
bool VerifyFileSignature(const wxString &aPath)
Validates the code signing signature of a given file This is most likely only ever going to be applic...
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:893
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition: pgm_base.cpp:89
see class PGM_BASE
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
Implement a participant in the KIWAY alchemy.
Definition: kiway.h:152
virtual bool HandleJobConfig(JOB *aJob, wxWindow *aParent)
Definition: kiway.h:250
virtual int HandleJob(JOB *aJob, REPORTER *aReporter)
Definition: kiway.h:245
int m_KI_Lang_Identifier
KiCad identifier used in menu selection (See id.h)
Definition: pgm_base.h:74
wxString m_Lang_Label
Labels used in menus.
Definition: pgm_base.h:77
IFACE KIFACE_BASE kiface("pcb_test_frame", KIWAY::FACE_PCB)