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 () throw ()
 
virtual KIFACEKiFACE (FACE_T aFaceId, bool doLoad=true)
 Return the KIFACE* given a FACE_T. More...
 
virtual KIWAY_PLAYERPlayer (FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
 Return the KIWAY_PLAYER* given a FRAME_T. More...
 
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. More...
 
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. More...
 
void PlayerDidClose (FRAME_T aFrameType)
 Notifies a Kiway that a player has been closed. More...
 
virtual void ExpressMail (FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
 Send aPayload to aDestination from aSource. More...
 
virtual void GetActions (std::vector< TOOL_ACTION * > &aActions) const
 Append all registered actions to the given list. More...
 
virtual PROJECTPrj () const
 Return the PROJECT associated with this KIWAY. More...
 
virtual void SetLanguage (int aLanguage)
 Change the language and then calls ShowChangedLanguage() on all #KIWAY_PLAYERs. More...
 
virtual void CommonSettingsChanged (bool aEnvVarsChanged, bool aTextVarsChanged)
 Call CommonSettingsChanged() on all KIWAY_PLAYERs. More...
 
virtual void ProjectChanged ()
 Calls ProjectChanged() on all KIWAY_PLAYERs. More...
 
 KIWAY (PGM_BASE *aProgram, 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. More...
 
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. More...
 
wxFrame * GetTop ()
 
void OnKiCadExit ()
 
void OnKiwayEnd ()
 
bool ProcessEvent (wxEvent &aEvent) override
 
int ProcessJob (KIWAY::FACE_T aFace, JOB *job)
 
wxWindow * GetBlockingDialog ()
 Gets the window pointer to the blocking dialog (to send it signals) More...
 
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. More...
 

Private Member Functions

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

Private Attributes

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

Static Private Attributes

static KIFACEm_kiface [KIWAY_FACE_COUNT]
 
static int m_kiface_version [KIWAY_FACE_COUNT]
 

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 278 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 284 of file kiway.h.

Constructor & Destructor Documentation

◆ ~KIWAY()

KIWAY::~KIWAY ( )
throw (
)
inline

Definition at line 298 of file kiway.h.

◆ KIWAY()

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

Definition at line 57 of file kiway.cpp.

References KIWAY_PLAYER_COUNT, m_playerFrameId, and SetTop().

Member Function Documentation

◆ CommonSettingsChanged()

void KIWAY::CommonSettingsChanged ( bool  aEnvVarsChanged,
bool  aTextVarsChanged 
)
virtual

◆ 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 110 of file kiway.cpp.

References FACE_BMP2CMP, FACE_CVPCB, FACE_GERBVIEW, FACE_PCB, FACE_PCB_CALCULATOR, FACE_PL_EDITOR, FACE_PYTHON, FACE_SCH, 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 562 of file kiway.cpp.

References ACTION_MANAGER::GetActionList().

Referenced by DIALOG_LIST_HOTKEYS::DIALOG_LIST_HOTKEYS(), and EDA_BASE_FRAME::ShowPreferences().

◆ 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 414 of file kiway.cpp.

References m_playerFrameId.

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

◆ GetTop()

wxFrame * KIWAY::GetTop ( )
inline

Definition at line 421 of file kiway.h.

References m_top.

Referenced by COMMON_CONTROL::ShowProjectManager().

◆ KiFACE()

◆ KifaceType()

KIWAY::FACE_T KIWAY::KifaceType ( FRAME_T  aFrameType)
static

◆ OnKiCadExit()

◆ OnKiwayEnd()

void KIWAY::OnKiwayEnd ( )

Definition at line 758 of file kiway.cpp.

References m_kiface.

Referenced by PGM_SINGLE_TOP::OnPgmExit(), PGM_KICAD::OnPgmExit(), and PGM_TEST_FRAME::OnPgmExit().

◆ 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 432 of file kiway.cpp.

References _, IFACE::CreateKiWindow(), GetPlayerFrame(), kiface(), KiFACE(), KifaceType(), KIWAY_PLAYER_COUNT, m_ctl, m_playerFrameId, and Pgm().

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PCB_BASE_EDIT_FRAME::AddLibrary(), SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic(), SCH_EDIT_FRAME::AskToSaveChanges(), SYMBOL_EDIT_FRAME::CanCloseSymbolFromSchematic(), SCH_EDIT_FRAME::canCloseWindow(), PCB_EDIT_FRAME::canCloseWindow(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), PCB::IFACE::CreateKiWindow(), FIELDS_EDITOR_GRID_TRICKS::doPopupSelection(), FIELDS_GRID_TRICKS::doPopupSelection(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), BACK_ANNOTATE::FetchNetlistFromPCB(), IMPORT_PROJ_HELPER::ImportIndividualFile(), InvokeSchEditSymbolLibTable(), EDA_DRAW_FRAME::IsScriptingConsoleVisible(), DIALOG_CHANGE_SYMBOLS::launchMatchIdSymbolBrowser(), DIALOG_CHANGE_SYMBOLS::launchNewIdSymbolBrowser(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), TEXT_BUTTON_SYMBOL_CHOOSER::OnButtonClick(), TEXT_BUTTON_FP_CHOOSER::OnButtonClick(), KIGFX::WX_VIEW_CONTROLS::onMotion(), SCH_EDIT_FRAME::OnOpenCvpcb(), SCH_EDIT_FRAME::OnOpenPcbnew(), PGM_SINGLE_TOP::OnPgmInit(), PGM_KICAD::OnPgmInit(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard(), SCH_EDIT_FRAME::OnUpdatePCB(), FOOTPRINT_EDIT_FRAME::OnUpdateSaveFootprintToBoard(), ProcessEvent(), SCH_EDIT_TOOL::Properties(), FOOTPRINT_WIZARD_FRAME::PythonPluginsReload(), SCH_EDITOR_CONTROL::rescueProject(), PCB_EDIT_FRAME::RunEeschema(), EE_INSPECTION_TOOL::RunSimulation(), SYMBOL_EDIT_FRAME::saveCurrentSymbol(), SaveFileAs(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), EDA_DRAW_FRAME::ScriptingConsoleEnableDisable(), FOOTPRINT_EDIT_FRAME::setupTools(), PCB_EDIT_FRAME::ShowFootprintPropertiesDialog(), CVPCB_CONTROL::ShowFootprintViewer(), COMMON_CONTROL::ShowPlayer(), KICAD_MANAGER_CONTROL::ShowPlayer(), SCH_EDITOR_CONTROL::SimProbe(), SCH_EDITOR_CONTROL::SimTune(), SIMULATOR_FRAME::SIMULATOR_FRAME(), PCB_EDIT_FRAME::TestStandalone(), DIALOG_FOOTPRINT_ASSOCIATIONS::TransferDataToWindow(), BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB(), and DIALOG_EXCHANGE_FOOTPRINTS::ViewAndSelectFootprint().

◆ 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 496 of file kiway.cpp.

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

Referenced by SCH_EDIT_FRAME::canCloseWindow(), and PlayersClose().

◆ PlayerDidClose()

void KIWAY::PlayerDidClose ( FRAME_T  aFrameType)

Notifies a Kiway that a player has been closed.

Definition at line 547 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 536 of file kiway.cpp.

References KIWAY_PLAYER_COUNT, and PlayerClose().

◆ Prj()

PROJECT & KIWAY::Prj ( ) const
virtual

Return the PROJECT associated with this KIWAY.

This is here as an accessor, so that there is freedom to put the actual PROJECT storage in a place decided by the implementation, and not known to the caller.

Definition at line 196 of file kiway.cpp.

References Pgm(), and Prj().

Referenced by CVPCB_MAINFRAME::BuildLibrariesList(), SYMBOL_PREVIEW_WIDGET::DisplaySymbol(), FOOTPRINT_LIST::GetInstance(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), LIB_TREE::onDetailsLink(), Prj(), Prj(), KIWAY_HOLDER::Prj(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), and PCB_BASE_FRAME::SelectLibrary().

◆ ProcessEvent()

bool KIWAY::ProcessEvent ( wxEvent &  aEvent)
override

◆ ProcessJob()

◆ 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 666 of file kiway.cpp.

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

Referenced by SETTINGS_MANAGER::LoadProject(), and SETTINGS_MANAGER::UnloadProject().

◆ set_kiface()

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

Definition at line 442 of file kiway.h.

References KIWAY_FACE_COUNT, and m_kiface.

Referenced by PGM_SINGLE_TOP::OnPgmInit().

◆ SetBlockingDialog()

void KIWAY::SetBlockingDialog ( wxWindow *  aWin)

Definition at line 700 of file kiway.cpp.

References m_blockingDialog.

Referenced by DIALOG_SHIM::DIALOG_SHIM(), and 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 412 of file kiway.h.

References m_ctl.

Referenced by PGM_KICAD::OnPgmInit().

◆ SetLanguage()

◆ 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 88 of file kiway.cpp.

References m_top.

Referenced by KIWAY(), PGM_SINGLE_TOP::OnPgmInit(), and PGM_KICAD::OnPgmInit().

Friends And Related Function Documentation

◆ PGM_SINGLE_TOP

friend struct PGM_SINGLE_TOP
friend

Definition at line 280 of file kiway.h.

Member Data Documentation

◆ m_blockingDialog

wxWindowID KIWAY::m_blockingDialog
private

Definition at line 467 of file kiway.h.

Referenced by GetBlockingDialog(), and SetBlockingDialog().

◆ m_ctl

int KIWAY::m_ctl
private

◆ m_kiface

KIFACE * KIWAY::m_kiface
staticprivate

Definition at line 459 of file kiway.h.

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

◆ m_kiface_version

int KIWAY::m_kiface_version
staticprivate

Definition at line 460 of file kiway.h.

Referenced by KiFACE().

◆ m_playerFrameId

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

Definition at line 475 of file kiway.h.

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

◆ m_program

PGM_BASE* KIWAY::m_program
private

Definition at line 462 of file kiway.h.

Referenced by KiFACE().

◆ m_top

wxFrame* KIWAY::m_top
private

Definition at line 465 of file kiway.h.

Referenced by CommonSettingsChanged(), GetTop(), OnKiCadExit(), ProjectChanged(), SetLanguage(), and SetTop().


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