KiCad PCB EDA Suite
KIFACE_BASE Class Referenceabstract

A KIFACE implementation. More...

#include <kiface_base.h>

Inheritance diagram for KIFACE_BASE:
KIFACE BMP2CMP::IFACE CV::IFACE GERBV::IFACE IFACE PCB::IFACE PCBCALC::IFACE PGE::IFACE SCH::IFACE

Public Member Functions

virtual bool OnKifaceStart (PGM_BASE *aProgram, int aCtlBits) override=0
 Typically start_common() is called from here. More...
 
virtual void OnKifaceEnd () override
 Called just once just before the DSO is to be unloaded. More...
 
virtual wxWindow * CreateKiWindow (wxWindow *aParent, int aClassId, KIWAY *aKIWAY, int aCtlBits=0) override=0
 Create a wxWindow for the current project. More...
 
virtual void * IfaceOrAddress (int aDataId) override=0
 Return pointer to the requested object. More...
 
 KIFACE_BASE (const char *aKifaceName, KIWAY::FACE_T aId)
 
const wxString Name ()
 
APP_SETTINGS_BASEKifaceSettings () const
 
void InitSettings (APP_SETTINGS_BASE *aSettings)
 
int StartFlags () const
 Return whatever was passed as aCtlBits to OnKifaceStart(). More...
 
bool IsSingle () const
 Is this KIFACE running under single_top? More...
 
const wxString & GetHelpFileName () const
 Return just the basename portion of the current help file. More...
 
SEARCH_STACKKifaceSearch ()
 Only for DSO specific 'non-library' files. More...
 
void GetActions (std::vector< TOOL_ACTION * > &aActions) const override
 Append this Kiface's registered actions to the given list. More...
 
virtual void SaveFileAs (const wxString &srcProjectBasePath, const wxString &srcProjectName, const wxString &newProjectBasePath, const wxString &newProjectName, const wxString &srcFilePath, wxString &aErrors)
 Saving a file under a different name is delegated to the various KIFACEs because the project doesn't know the internal format of the various files (which may have paths in them that need updating). More...
 
virtual int HandleJob (JOB *aJob)
 

Protected Member Functions

bool start_common (int aCtlBits)
 Common things to do for a top program module, during OnKifaceStart(). More...
 
void end_common ()
 Common things to do for a top program module, during OnKifaceEnd();. More...
 

Private Attributes

KIWAY::FACE_T m_id
 
BIN_MOD m_bm
 
int m_start_flags
 flags provided in OnKifaceStart() More...
 

Detailed Description

A KIFACE implementation.

This has useful for DSOs which implement a KIFACE. It is abstract so a few functions must be implemented in derivations.

Definition at line 38 of file kiface_base.h.

Constructor & Destructor Documentation

◆ KIFACE_BASE()

KIFACE_BASE::KIFACE_BASE ( const char *  aKifaceName,
KIWAY::FACE_T  aId 
)
inline
Parameters
aKifaceNameshould point to a C string in permanent storage which contains the name of the DSO. Examples: "eeschema", "pcbnew", etc. This controls the name of the wxConfigBase established in m_bm, so it should be lowercase.
aIdis the type of DSO ( #FACE_SCH, #FACE_PCB, #FACE_CVPCB, #FACE_GERBVIEW, #FACE_PL_EDITOR, #FACE_PCB_CALCULATOR, #FACE_BMP2CMP)

Definition at line 65 of file kiface_base.h.

65 :
66 m_id( aId ),
67 m_bm( aKifaceName ),
68 m_start_flags( 0 )
69 {
70 }
KIWAY::FACE_T m_id
Definition: kiface_base.h:123
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_base.h:127
BIN_MOD m_bm
Definition: kiface_base.h:125

Member Function Documentation

◆ CreateKiWindow()

virtual wxWindow * KIFACE_BASE::CreateKiWindow ( wxWindow *  aParent,
int  aClassId,
KIWAY aKIWAY,
int  aCtlBits = 0 
)
overridepure virtual

Create a wxWindow for the current project.

The caller must cast the return value into the known type.

Parameters
aParentmay be NULL or is otherwise the parent to connect under. If NULL then caller may want to connect the returned wxWindow into some hierarchy after this function returns.
aClassIdidentifies which wxFrame or wxDialog to retrieve, using a value known to the implementing KIFACE.
aKIWAYtells the window which KIWAY (and PROJECT) it is a participant in.
aCtlBitsconsists of bit flags from the set of KFCTL_* #defines above.
Returns
the window created and if not NULL, should be cast into the known type using and old school cast. dynamic_cast is problematic since it needs typeinfo probably not contained in the caller's link image.

Implements KIFACE.

Implemented in BMP2CMP::IFACE, CV::IFACE, SCH::IFACE, GERBV::IFACE, PGE::IFACE, PCBCALC::IFACE, PCB::IFACE, and IFACE.

◆ end_common()

void KIFACE_BASE::end_common ( )
protected

Common things to do for a top program module, during OnKifaceEnd();.

Definition at line 107 of file kiface_base.cpp.

108{
109 m_bm.End();
110}
void End()
Definition: bin_mod.cpp:50

References BIN_MOD::End(), and m_bm.

Referenced by CV::IFACE::OnKifaceEnd(), SCH::IFACE::OnKifaceEnd(), GERBV::IFACE::OnKifaceEnd(), OnKifaceEnd(), PGE::IFACE::OnKifaceEnd(), PCBCALC::IFACE::OnKifaceEnd(), and PCB::IFACE::OnKifaceEnd().

◆ GetActions()

void KIFACE_BASE::GetActions ( std::vector< TOOL_ACTION * > &  aActions) const
inlineoverridevirtual

Append this Kiface's registered actions to the given list.

Implements KIFACE.

Definition at line 116 of file kiface_base.h.

117 {
119 aActions.push_back( action );
120 }
static std::list< TOOL_ACTION * > & GetActionList()
Return list of TOOL_ACTIONs.
Represent a single user action.
Definition: tool_action.h:68

References ACTION_MANAGER::GetActionList().

◆ GetHelpFileName()

const wxString & KIFACE_BASE::GetHelpFileName ( ) const
inline

Return just the basename portion of the current help file.

Definition at line 110 of file kiface_base.h.

110{ return m_bm.m_help_file; }
wxString m_help_file
Definition: bin_mod.h:58

References m_bm, and BIN_MOD::m_help_file.

Referenced by EDA_BASE_FRAME::help_name().

◆ HandleJob()

virtual int KIFACE::HandleJob ( JOB aJob)
inlinevirtualinherited

Reimplemented in SCH::IFACE, and PCB::IFACE.

Definition at line 238 of file kiway.h.

239 {
240 return 0;
241 }

◆ IfaceOrAddress()

virtual void * KIFACE_BASE::IfaceOrAddress ( int  aDataId)
overridepure virtual

Return pointer to the requested object.

The safest way to use this is to retrieve a pointer to a static instance of an interface, similar to how the KIFACE interface is exported. But if you know what you are doing use it to retrieve anything you want. Segfaults are your fault.

Parameters
aDataIdidentifies which object you want the address of, and consists of choices known in advance by the implementing KIFACE.
Returns
the requested object which must be cast into the known type.

Implements KIFACE.

Implemented in BMP2CMP::IFACE, CV::IFACE, SCH::IFACE, GERBV::IFACE, PGE::IFACE, PCBCALC::IFACE, PCB::IFACE, and IFACE.

Referenced by get_instance_from_id().

◆ InitSettings()

void KIFACE_BASE::InitSettings ( APP_SETTINGS_BASE aSettings)
inline

Definition at line 95 of file kiface_base.h.

95{ m_bm.InitSettings( aSettings ); }
void InitSettings(APP_SETTINGS_BASE *aPtr)
Takes ownership of a new application settings object.
Definition: bin_mod.h:53

References BIN_MOD::InitSettings(), and m_bm.

Referenced by BMP2CMP::IFACE::CreateKiWindow(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), GERBV::IFACE::OnKifaceStart(), PGE::IFACE::OnKifaceStart(), PCBCALC::IFACE::OnKifaceStart(), and PCB::IFACE::OnKifaceStart().

◆ IsSingle()

bool KIFACE_BASE::IsSingle ( ) const
inline

Is this KIFACE running under single_top?

Definition at line 105 of file kiface_base.h.

#define KFCTL_STANDALONE
Running as a standalone Top.
Definition: kiway.h:158

References KFCTL_STANDALONE, and m_start_flags.

Referenced by ACTION_MENU::AddQuitOrClose(), PCB::IFACE::CreateKiWindow(), DIALOG_DRC::DIALOG_DRC(), SCH_EDIT_FRAME::OnImportProject(), SCH_EDIT_FRAME::SaveProject(), and SCH_EDIT_FRAME::SendSelectItemsToPcb().

◆ KifaceSearch()

SEARCH_STACK & KIFACE_BASE::KifaceSearch ( )
inline

Only for DSO specific 'non-library' files.

(The library search path is in the PROJECT class.)

Definition at line 114 of file kiface_base.h.

114{ return m_bm.m_search; }
SEARCH_STACK m_search
Definition: bin_mod.h:60

References m_bm, and BIN_MOD::m_search.

Referenced by CVPCB_MAINFRAME::buildEquivalenceList(), DS_DATA_MODEL::ResolvePath(), and EDA_BASE_FRAME::sys_search().

◆ KifaceSettings()

APP_SETTINGS_BASE * KIFACE_BASE::KifaceSettings ( ) const
inline

Definition at line 93 of file kiface_base.h.

93{ return m_bm.m_config; }
APP_SETTINGS_BASE * m_config
maybe from $HOME/.${m_name}
Definition: bin_mod.h:57

References m_bm, and BIN_MOD::m_config.

Referenced by DIALOG_SYMBOL_FIELDS_TABLE::AddField(), AUTOPLACER::AUTOPLACER(), EDA_DRAW_FRAME::CommonSettingsChanged(), EDA_BASE_FRAME::config(), BMP2CMP::IFACE::CreateKiWindow(), DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE(), DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER(), DIALOG_ERC::DIALOG_ERC(), DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES(), DIALOG_PRINT_GERBVIEW::DIALOG_PRINT_GERBVIEW(), DIALOG_PRINT_PCBNEW::DIALOG_PRINT_PCBNEW(), DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES(), DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE(), DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES(), KIGFX::eeconfig(), PCB_PLUGIN::FootprintSave(), DIALOG_PLOT_SCHEMATIC::getPlotOptions(), LAYERS_MAP_DIALOG::initDialog(), DIALOG_PLOT_SCHEMATIC::initDlg(), DIALOG_ANNOTATE::InitValues(), NETLIST_DIALOG::InstallCustomPages(), LIB_TREE_MODEL_ADAPTER::LIB_TREE_MODEL_ADAPTER(), EDA_DRAW_FRAME::loadCanvasTypeSetting(), DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames(), DIALOG_SYMBOL_FIELDS_TABLE::OnAddField(), DIALOG_SYMBOL_FIELDS_TABLE::OnColumnItemToggled(), LAYERS_MAP_DIALOG::OnGetSetup(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), GERBV::IFACE::OnKifaceStart(), PGE::IFACE::OnKifaceStart(), PCBCALC::IFACE::OnKifaceStart(), PCB::IFACE::OnKifaceStart(), DIALOG_RESCUE_EACH::OnNeverShowClick(), SCH_EDIT_FRAME::OnResizeHierarchyNavigator(), LAYERS_MAP_DIALOG::OnStoreSetup(), DIALOG_SYMBOL_FIELDS_TABLE::OnTableColSize(), DIALOG_EESCHEMA_PAGE_SETTINGS::onTransferDataToWindow(), SCH_EDIT_FRAME::OpenProjectFiles(), pcbconfig(), TRANSLINE_IDENT::ReadConfig(), PCB_EDIT_FRAME::redrawNetnames(), EDA_DRAW_FRAME::saveCanvasTypeSetting(), LIB_TREE_MODEL_ADAPTER::SaveSettings(), PCB_CALCULATOR_FRAME::SaveSettings(), SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS(), PANEL_PCBNEW_ACTION_PLUGINS::TransferDataFromWindow(), RATSNEST_VIEW_ITEM::ViewDraw(), TRANSLINE_IDENT::WriteConfig(), NETLIST_DIALOG::WriteCurrentNetlistSetup(), DIALOG_ANNOTATE::~DIALOG_ANNOTATE(), DIALOG_COLOR_PICKER::~DIALOG_COLOR_PICKER(), DIALOG_EESCHEMA_PAGE_SETTINGS::~DIALOG_EESCHEMA_PAGE_SETTINGS(), DIALOG_ERC::~DIALOG_ERC(), DIALOG_LABEL_PROPERTIES::~DIALOG_LABEL_PROPERTIES(), DIALOG_SHEET_PROPERTIES::~DIALOG_SHEET_PROPERTIES(), and DIALOG_SYMBOL_PROPERTIES::~DIALOG_SYMBOL_PROPERTIES().

◆ Name()

const wxString KIFACE_BASE::Name ( )
inline

Definition at line 88 of file kiface_base.h.

89 {
90 return wxString::FromUTF8( m_bm.m_name );
91 }
const char * m_name
name of this binary module, static C string.
Definition: bin_mod.h:55

References m_bm, and BIN_MOD::m_name.

◆ OnKifaceEnd()

virtual void KIFACE_BASE::OnKifaceEnd ( )
inlineoverridevirtual

Called just once just before the DSO is to be unloaded.

It is called before static C++ destructors are called. A default implementation is supplied.

Implements KIFACE.

Reimplemented in CV::IFACE, SCH::IFACE, GERBV::IFACE, PGE::IFACE, PCBCALC::IFACE, PCB::IFACE, and IFACE.

Definition at line 46 of file kiface_base.h.

47 {
48 // overload this if you want, end_common() may be handy.
49 end_common();
50 }
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.

References end_common().

◆ OnKifaceStart()

virtual bool KIFACE_BASE::OnKifaceStart ( PGM_BASE aProgram,
int  aCtlBits 
)
overridepure virtual

Typically start_common() is called from here.

Implements KIFACE.

Implemented in BMP2CMP::IFACE, CV::IFACE, SCH::IFACE, GERBV::IFACE, PGE::IFACE, PCBCALC::IFACE, PCB::IFACE, and IFACE.

◆ SaveFileAs()

virtual void KIFACE::SaveFileAs ( const wxString &  srcProjectBasePath,
const wxString &  srcProjectName,
const wxString &  newProjectBasePath,
const wxString &  newProjectName,
const wxString &  srcFilePath,
wxString &  aErrors 
)
inlinevirtualinherited

Saving a file under a different name is delegated to the various KIFACEs because the project doesn't know the internal format of the various files (which may have paths in them that need updating).

Reimplemented in SCH::IFACE, GERBV::IFACE, PGE::IFACE, and PCB::IFACE.

Definition at line 210 of file kiway.h.

216 {
217 // If a KIFACE owns files then it needs to implement this....
218 }

Referenced by SAVE_AS_TRAVERSER::OnFile().

◆ start_common()

bool KIFACE_BASE::start_common ( int  aCtlBits)
protected

Common things to do for a top program module, during OnKifaceStart().

Definition at line 97 of file kiface_base.cpp.

98{
99 m_start_flags = aCtlBits;
100 m_bm.Init();
102
103 return true;
104}
static void setSearchPaths(SEARCH_STACK *aDst, KIWAY::FACE_T aId)
Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings.
Definition: kiface_base.cpp:33
void Init()
Definition: bin_mod.cpp:38

References BIN_MOD::Init(), m_bm, m_id, BIN_MOD::m_search, m_start_flags, and setSearchPaths().

Referenced by BMP2CMP::IFACE::OnKifaceStart(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), GERBV::IFACE::OnKifaceStart(), PGE::IFACE::OnKifaceStart(), PCBCALC::IFACE::OnKifaceStart(), and PCB::IFACE::OnKifaceStart().

◆ StartFlags()

int KIFACE_BASE::StartFlags ( ) const
inline

Return whatever was passed as aCtlBits to OnKifaceStart().

Definition at line 100 of file kiface_base.h.

100{ return m_start_flags; }

References m_start_flags.

Member Data Documentation

◆ m_bm

BIN_MOD KIFACE_BASE::m_bm
private

◆ m_id

KIWAY::FACE_T KIFACE_BASE::m_id
private

Definition at line 123 of file kiface_base.h.

Referenced by start_common().

◆ m_start_flags

int KIFACE_BASE::m_start_flags
private

flags provided in OnKifaceStart()

Definition at line 127 of file kiface_base.h.

Referenced by IsSingle(), start_common(), and StartFlags().


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