KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIWAY Class Reference

A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad process. More...

#include <kiway.h>

Inheritance diagram for KIWAY:

Public Types

enum  FACE_T {
  FACE_SCH , FACE_PCB , FACE_CVPCB , FACE_GERBVIEW ,
  FACE_PL_EDITOR , FACE_PCB_CALCULATOR , FACE_BMP2CMP , FACE_PYTHON ,
  KIWAY_FACE_COUNT
}
 Known KIFACE implementations. More...
 

Public Member Functions

 ~KIWAY ()
 
virtual KIFACEKiFACE (FACE_T aFaceId, bool doLoad=true)
 Return the KIFACE* given a FACE_T.
 
virtual KIWAY_PLAYERPlayer (FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
 Return the KIWAY_PLAYER* given a FRAME_T.
 
virtual bool PlayerClose (FRAME_T aFrameType, bool doForce)
 Call the KIWAY_PLAYER::Close( bool force ) function on the window and if not vetoed, returns true, else false.
 
virtual bool PlayersClose (bool doForce)
 Call the KIWAY_PLAYER::Close( bool force ) function on all the windows and if none are vetoed, returns true, else false.
 
void PlayerDidClose (FRAME_T aFrameType)
 Notifies a Kiway that a player has been closed.
 
virtual void ExpressMail (FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr, bool aFromOtherThread=false)
 Send aPayload to aDestination from aSource.
 
virtual void GetActions (std::vector< TOOL_ACTION * > &aActions) const
 Append all registered actions to the given list.
 
virtual PROJECTPrj () const
 Return the PROJECT associated with this KIWAY.
 
LOCAL_HISTORYLocalHistory ()
 Return the LOCAL_HISTORY associated with this KIWAY.
 
virtual void SetLanguage (int aLanguage)
 Change the language and then calls ShowChangedLanguage() on all #KIWAY_PLAYERs.
 
virtual void CommonSettingsChanged (int aFlags=0)
 Call CommonSettingsChanged() on all KIWAY_PLAYERs.
 
void ClearFileHistory ()
 Clear the wxWidgets file history on each open frame.
 
virtual void ProjectChanged ()
 Calls ProjectChanged() on all KIWAY_PLAYERs.
 
 KIWAY (int aCtlBits, wxFrame *aTop=nullptr)
 
void SetCtlBits (int aCtlBits)
 Overwrites previously set ctl bits, only for use in kicad.cpp to flip between standalone and manager mode before we actually load anything.
 
void SetTop (wxFrame *aTop)
 Tell this KIWAY about the top most frame in the program and optionally allows it to play the role of one of the KIWAY_PLAYERs if launched from single_top.cpp.
 
wxFrame * GetTop ()
 
void OnKiCadExit ()
 
void OnKiwayEnd ()
 
bool ProcessEvent (wxEvent &aEvent) override
 
void QueueEvent (wxEvent *aEvent) override
 
int ProcessJob (KIWAY::FACE_T aFace, JOB *aJob, REPORTER *aReporter=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
 
bool ProcessJobConfigDialog (KIWAY::FACE_T aFace, JOB *aJob, wxWindow *aWindow)
 
wxWindow * GetBlockingDialog ()
 Gets the window pointer to the blocking dialog (to send it signals)
 
void SetBlockingDialog (wxWindow *aWin)
 

Static Public Member Functions

static FACE_T KifaceType (FRAME_T aFrameType)
 A simple mapping function which returns the FACE_T which is known to implement aFrameType.
 

Private Member Functions

const wxString dso_search_path (FACE_T aFaceId)
 Get the [path &] name of the DSO holding the requested FACE_T.
 
bool set_kiface (FACE_T aFaceType, KIFACE *aKiface)
 
KIWAY_PLAYERGetPlayerFrame (FRAME_T aFrameType)
 

Private Attributes

int m_ctl
 
wxFrame * m_top
 
wxWindowID m_blockingDialog
 
std::atomic< wxWindowID > m_playerFrameId [KIWAY_PLAYER_COUNT]
 
LOCAL_HISTORYm_local_history
 

Static Private Attributes

static std::array< KIFACE *, KIWAY_FACE_COUNTm_kiface
 
static std::array< int, KIWAY_FACE_COUNTm_kiface_version
 

Friends

struct PGM_SINGLE_TOP
 

Detailed Description

A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad process.

It makes it possible to call between DSOs without having to link them together, and without having to link to the top process module which houses the KIWAY(s). More importantly it makes it possible to send custom wxEvents between DSOs and from the top process module down into the DSOs. The latter capability is thought useful for driving the lower DSOs from a python test rig or for demo (automation) purposes.

Most all calls are via virtual functions, which means C++ vtables are used to hold function pointers and eliminate the need to link to specific object code libraries, speeding development and encouraging clearly defined interface design. Unlike Microsoft COM, which is a multi-vendor design supporting DLL's built at various points in time, the KIWAY alchemy is single project, with all components being built at the same time. So one should expect solid compatibility between all KiCad components, as long at they are compiled at the same time.

There is one KIWAY in the launching portion of the process for each open KiCad project. Each project has its own KIWAY. Available to each KIWAY is an actual PROJECT data structure. If you have a KIWAY, you can get to the PROJECT using KIWAY::Prj().

In summary, a KIWAY facilitates communicating between DSOs, where the topic of the communication is project specific. Here a "project" means a BOARD and a SCHEMATIC and a NETLIST, (anything relating to production of a single BOARD and added to class PROJECT.)

Definition at line 294 of file kiway.h.

Member Enumeration Documentation

◆ FACE_T

Known KIFACE implementations.

Enumerator
FACE_SCH 

eeschema DSO

FACE_PCB 

pcbnew DSO

FACE_CVPCB 
FACE_GERBVIEW 
FACE_PL_EDITOR 
FACE_PCB_CALCULATOR 
FACE_BMP2CMP 
FACE_PYTHON 
KIWAY_FACE_COUNT 

Definition at line 300 of file kiway.h.

Constructor & Destructor Documentation

◆ ~KIWAY()

KIWAY::~KIWAY ( )

Definition at line 71 of file kiway.cpp.

References m_local_history.

◆ KIWAY()

KIWAY::KIWAY ( int aCtlBits,
wxFrame * aTop = nullptr )

Member Function Documentation

◆ ClearFileHistory()

void KIWAY::ClearFileHistory ( )

Clear the wxWidgets file history on each open frame.

Preference records are handled by SETTINGS_MANAGER (as not all frames might be open).

Definition at line 622 of file kiway.cpp.

References EDA_BASE_FRAME::ClearFileHistory(), GetPlayerFrame(), KFCTL_CPP_PROJECT_SUITE, KIWAY_PLAYER_COUNT, m_ctl, m_top, and top().

◆ CommonSettingsChanged()

void KIWAY::CommonSettingsChanged ( int aFlags = 0)
virtual

Call CommonSettingsChanged() on all KIWAY_PLAYERs.

Use after changing suite-wide options such as panning, autosave interval, etc.

Definition at line 599 of file kiway.cpp.

References EDA_BASE_FRAME::CommonSettingsChanged(), GetPlayerFrame(), KFCTL_CPP_PROJECT_SUITE, KIWAY_PLAYER_COUNT, m_ctl, m_top, and top().

Referenced by PCB_EDIT_FRAME::ShowBoardSetupDialog(), EDA_BASE_FRAME::ShowPreferences(), and SCH_EDIT_FRAME::ShowSchematicSetupDialog().

◆ dso_search_path()

const wxString KIWAY::dso_search_path ( FACE_T aFaceId)
private

Get the [path &] name of the DSO holding the requested FACE_T.

Definition at line 114 of file kiway.cpp.

References FACE_BMP2CMP, FACE_CVPCB, FACE_GERBVIEW, FACE_PCB, FACE_PCB_CALCULATOR, FACE_PL_EDITOR, FACE_PYTHON, FACE_SCH, PGM_BASE::GetExecutablePath(), KFCTL_CPP_PROJECT_SUITE, KFCTL_STANDALONE, m_ctl, name, path, and Pgm().

Referenced by KiFACE().

◆ ExpressMail()

◆ GetActions()

void KIWAY::GetActions ( std::vector< TOOL_ACTION * > & aActions) const
virtual

Append all registered actions to the given list.

Definition at line 518 of file kiway.cpp.

References ACTION_MANAGER::GetActionList().

◆ GetBlockingDialog()

wxWindow * KIWAY::GetBlockingDialog ( )

◆ GetPlayerFrame()

KIWAY_PLAYER * KIWAY::GetPlayerFrame ( FRAME_T aFrameType)
private
Returns
the reference of the KIWAY_PLAYER having the type aFrameType if exists, or NULL if this KIWAY_PLAYER was not yet created, or was closed

Definition at line 389 of file kiway.cpp.

References m_playerFrameId.

Referenced by ClearFileHistory(), CommonSettingsChanged(), Player(), PlayerClose(), ProjectChanged(), and SetLanguage().

◆ GetTop()

wxFrame * KIWAY::GetTop ( )
inline

Definition at line 448 of file kiway.h.

References m_top.

◆ KiFACE()

◆ KifaceType()

◆ LocalHistory()

◆ OnKiCadExit()

◆ OnKiwayEnd()

void KIWAY::OnKiwayEnd ( )

Definition at line 775 of file kiway.cpp.

References m_kiface.

◆ Player()

KIWAY_PLAYER * KIWAY::Player ( FRAME_T aFrameType,
bool doCreate = true,
wxTopLevelWindow * aParent = nullptr )
virtual

Return the KIWAY_PLAYER* given a FRAME_T.

If it is not already created, the required KIFACE is found and loaded and initialized if necessary, then the KIWAY_PLAYER window is created but not shown. Caller must Show() it. If it is already created, then the existing KIWAY_PLAYER* pointer is returned.

Parameters
aFrameTypeis from enum FRAME_T.
doCreatewhen true asks that the player be created if it is not already created, false means do not create and maybe return NULL.
aParentis a parent for modal KIWAY_PLAYER frames, otherwise NULL used only when doCreate = true and by KIWAY_PLAYER frames created in modal form
Returns
a valid opened KIWAY_PLAYER or NULL if there is something wrong or doCreate was false and the player has yet to be created.
Exceptions
IO_ERRORif the *.kiface file could not be found, filled with text saying what.

Definition at line 407 of file kiway.cpp.

References _, APP_MONITOR::AddNavigationBreadcrumb(), GetPlayerFrame(), PGM_BASE::HandleException(), KiFACE(), kiface(), KifaceType(), KIWAY_PLAYER_COUNT, m_ctl, m_playerFrameId, and Pgm().

Referenced by PROJECT_TREE_ITEM::Activate(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PCB_BASE_EDIT_FRAME::AddLibrary(), SCH_EDIT_FRAME::AskToSaveChanges(), SYMBOL_EDIT_FRAME::CanCloseSymbolFromSchematic(), PCB_EDIT_FRAME::canCloseWindow(), SCH_EDIT_FRAME::canCloseWindow(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), EESCHEMA_JOBS_HANDLER::EESCHEMA_JOBS_HANDLER(), IfaceOrAddress(), InvokeSchEditSymbolLibTable(), EDA_DRAW_FRAME::IsScriptingConsoleVisible(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), KIGFX::WX_VIEW_CONTROLS::onMotion(), SCH_EDIT_FRAME::OnOpenCvpcb(), SCH_EDIT_FRAME::OnOpenPcbnew(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), SCH_EDIT_FRAME::OnUpdatePCB(), PCBNEW_JOBS_HANDLER::PCBNEW_JOBS_HANDLER(), ProcessEvent(), FOOTPRINT_WIZARD_FRAME::PythonPluginsReload(), QueueEvent(), SYMBOL_EDIT_FRAME::saveCurrentSymbol(), SaveFileAs(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), EDA_DRAW_FRAME::ScriptingConsoleEnableDisable(), FOOTPRINT_EDIT_FRAME::setupTools(), FOOTPRINT_EDIT_FRAME::setupUIConditions(), BOARD_EDITOR_CONTROL::ShowEeschema(), and PCB_EDIT_FRAME::TestStandalone().

◆ PlayerClose()

bool KIWAY::PlayerClose ( FRAME_T aFrameType,
bool doForce )
virtual

Call the KIWAY_PLAYER::Close( bool force ) function on the window and if not vetoed, returns true, else false.

If window actually closes, then this KIWAY marks it as not opened internally.

Returns
true if the window is closed and not vetoed, else false.

Definition at line 460 of file kiway.cpp.

References APP_MONITOR::AddNavigationBreadcrumb(), GetPlayerFrame(), KIWAY_PLAYER_COUNT, m_playerFrameId, and EDA_BASE_FRAME::NonUserClose().

Referenced by PlayersClose().

◆ PlayerDidClose()

void KIWAY::PlayerDidClose ( FRAME_T aFrameType)

Notifies a Kiway that a player has been closed.

Definition at line 499 of file kiway.cpp.

References m_playerFrameId.

Referenced by KIWAY_PLAYER::Destroy().

◆ PlayersClose()

bool KIWAY::PlayersClose ( bool doForce)
virtual

Call the KIWAY_PLAYER::Close( bool force ) function on all the windows and if none are vetoed, returns true, else false.

If any window actually closes, then* this KIWAY marks it as not opened internally.

Returns
true indicates that all windows closed because none were vetoed, false means at least one cast a veto. Any that cast a veto are still open.

Definition at line 488 of file kiway.cpp.

References KIWAY_PLAYER_COUNT, and PlayerClose().

◆ Prj()

PROJECT & KIWAY::Prj ( ) const
virtual

◆ ProcessEvent()

bool KIWAY::ProcessEvent ( wxEvent & aEvent)
override

◆ ProcessJob()

◆ ProcessJobConfigDialog()

bool KIWAY::ProcessJobConfigDialog ( KIWAY::FACE_T aFace,
JOB * aJob,
wxWindow * aWindow )

Definition at line 752 of file kiway.cpp.

References KiFACE(), and kiface().

◆ ProjectChanged()

void KIWAY::ProjectChanged ( )
virtual

Calls ProjectChanged() on all KIWAY_PLAYERs.

Used after changing the project to ensure all players are updated correctly.

Definition at line 645 of file kiway.cpp.

References APP_MONITOR::AddNavigationBreadcrumb(), LOCAL_HISTORY::ClearAllSavers(), FACE_PCB, FACE_SCH, GetPlayerFrame(), KFCTL_CPP_PROJECT_SUITE, KiFACE(), KIWAY_PLAYER_COUNT, LocalHistory(), m_ctl, m_top, Pgm(), PgmOrNull(), EDA_BASE_FRAME::ProjectChanged(), and top().

◆ QueueEvent()

void KIWAY::QueueEvent ( wxEvent * aEvent)
override

Definition at line 725 of file kiway.cpp.

References KIWAY_MAIL_EVENT::Dest(), and Player().

Referenced by ExpressMail().

◆ set_kiface()

bool KIWAY::set_kiface ( FACE_T aFaceType,
KIFACE * aKiface )
inlineprivate

Definition at line 473 of file kiway.h.

References KIWAY_FACE_COUNT, and m_kiface.

◆ SetBlockingDialog()

void KIWAY::SetBlockingDialog ( wxWindow * aWin)

Definition at line 690 of file kiway.cpp.

References m_blockingDialog.

Referenced by DIALOG_SHIM::~DIALOG_SHIM().

◆ SetCtlBits()

void KIWAY::SetCtlBits ( int aCtlBits)
inline

Overwrites previously set ctl bits, only for use in kicad.cpp to flip between standalone and manager mode before we actually load anything.

Definition at line 439 of file kiway.h.

References m_ctl.

◆ SetLanguage()

void KIWAY::SetLanguage ( int aLanguage)
virtual

◆ SetTop()

void KIWAY::SetTop ( wxFrame * aTop)

Tell this KIWAY about the top most frame in the program and optionally allows it to play the role of one of the KIWAY_PLAYERs if launched from single_top.cpp.

Parameters
aTopis the top most wxFrame in the entire program.

Definition at line 92 of file kiway.cpp.

References m_top.

Referenced by KIWAY().

Friends And Related Symbol Documentation

◆ PGM_SINGLE_TOP

friend struct PGM_SINGLE_TOP
friend

Definition at line 296 of file kiway.h.

References PGM_SINGLE_TOP.

Referenced by PGM_SINGLE_TOP.

Member Data Documentation

◆ m_blockingDialog

wxWindowID KIWAY::m_blockingDialog
private

Definition at line 497 of file kiway.h.

Referenced by GetBlockingDialog(), KIWAY(), and SetBlockingDialog().

◆ m_ctl

◆ m_kiface

std::array< KIFACE *, KIWAY::FACE_T::KIWAY_FACE_COUNT > KIWAY::m_kiface
staticprivate

Definition at line 490 of file kiway.h.

Referenced by KiFACE(), OnKiwayEnd(), and set_kiface().

◆ m_kiface_version

std::array< int, KIWAY::FACE_T::KIWAY_FACE_COUNT > KIWAY::m_kiface_version
staticprivate

Definition at line 491 of file kiway.h.

Referenced by KiFACE().

◆ m_local_history

LOCAL_HISTORY* KIWAY::m_local_history
private

Definition at line 507 of file kiway.h.

Referenced by KIWAY(), LocalHistory(), and ~KIWAY().

◆ m_playerFrameId

std::atomic<wxWindowID> KIWAY::m_playerFrameId[KIWAY_PLAYER_COUNT]
private

Definition at line 505 of file kiway.h.

Referenced by GetPlayerFrame(), KIWAY(), Player(), PlayerClose(), and PlayerDidClose().

◆ m_top

wxFrame* KIWAY::m_top
private

The documentation for this class was generated from the following files: