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.
 
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)
 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.
 
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
 
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]
 

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 285 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 291 of file kiway.h.

Constructor & Destructor Documentation

◆ ~KIWAY()

KIWAY::~KIWAY ( )
throw ( )
inline

Definition at line 305 of file kiway.h.

◆ KIWAY()

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

Definition at line 54 of file kiway.cpp.

References KIWAY_PLAYER_COUNT, m_blockingDialog, m_ctl, m_playerFrameId, m_top, and SetTop().

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

References EDA_BASE_FRAME::ClearFileHistory(), GetPlayerFrame(), KFCTL_CPP_PROJECT_SUITE, KIWAY_PLAYER_COUNT, m_ctl, and m_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 589 of file kiway.cpp.

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

Referenced by PCB::IFACE::CreateKiWindow(), 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 107 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 508 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 377 of file kiway.cpp.

References m_playerFrameId.

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

◆ GetTop()

wxFrame * KIWAY::GetTop ( )
inline

Definition at line 434 of file kiway.h.

References m_top.

◆ KiFACE()

◆ KifaceType()

◆ OnKiCadExit()

◆ OnKiwayEnd()

void KIWAY::OnKiwayEnd ( )

Definition at line 732 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 395 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 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(), PCB::IFACE::CreateKiWindow(), 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(), 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 451 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 493 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 482 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 192 of file kiway.cpp.

References PGM_BASE::GetSettingsManager(), Pgm(), and SETTINGS_MANAGER::Prj().

Referenced by CVPCB_MAINFRAME::BuildLibrariesList(), FOOTPRINT_LIST::GetInstance(), PCB_BASE_FRAME::GetLibraryItemsForListDialog(), InvokeEditDesignBlockLibTable(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), KIWAY_HOLDER::Prj(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), and FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList().

◆ ProcessEvent()

bool KIWAY::ProcessEvent ( wxEvent & aEvent)
override

◆ ProcessJob()

◆ ProcessJobConfigDialog()

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

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

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

◆ set_kiface()

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

Definition at line 457 of file kiway.h.

References KIWAY_FACE_COUNT, and m_kiface.

◆ SetBlockingDialog()

void KIWAY::SetBlockingDialog ( wxWindow * aWin)

Definition at line 666 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 425 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 85 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 287 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 481 of file kiway.h.

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

◆ m_ctl

◆ m_kiface

KIFACE * KIWAY::m_kiface
staticprivate

Definition at line 474 of file kiway.h.

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

◆ m_kiface_version

int KIWAY::m_kiface_version
staticprivate

Definition at line 475 of file kiway.h.

Referenced by KiFACE().

◆ m_playerFrameId

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

Definition at line 489 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: