KiCad PCB EDA Suite
PCB::IFACE Struct Reference
Inheritance diagram for PCB::IFACE:
KIFACE_I KIFACE

Public Member Functions

 IFACE (const char *aName, KIWAY::FACE_T aType)
 
bool OnKifaceStart (PGM_BASE *aProgram, int aCtlBits) override
 Function OnKifaceStart is called just once shortly after the DSO is loaded. More...
 
void OnKifaceEnd () override
 Function OnKifaceEnd is called just once just before the DSO is to be unloaded. More...
 
wxWindow * CreateWindow (wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
 Function CreateWindow creates a wxWindow for the current project. More...
 
void * IfaceOrAddress (int aDataId) override
 Function IfaceOrAddress return a pointer to the requested object. More...
 
const wxString Name ()
 
wxConfigBase * KifaceSettings () const
 
int StartFlags () const
 Function StartFlags returns whatever was passed as aCtlBits to OnKifaceStart() More...
 
bool IsSingle () const
 Function IsSingle is this KIFACE_I running under single_top? More...
 
const wxString & GetHelpFileName () const
 Function GetHelpFileName returns just the basename portion of the current help file. More...
 
wxFileHistory & GetFileHistory ()
 
SEARCH_STACKKifaceSearch ()
 Only for DSO specific 'non-library' files. More...
 

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

Detailed Description

Definition at line 100 of file pcbnew.cpp.

Constructor & Destructor Documentation

PCB::IFACE::IFACE ( const char *  aName,
KIWAY::FACE_T  aType 
)
inline

Definition at line 104 of file pcbnew.cpp.

104  :
105  KIFACE_I( aName, aType )
106  {}
KIFACE_I(const char *aKifaceName, KIWAY::FACE_T aId)
Constructor.
Definition: kiface_i.h:76

Member Function Documentation

wxWindow* PCB::IFACE::CreateWindow ( wxWindow *  aParent,
int  aClassId,
KIWAY aKIWAY,
int  aCtlBits = 0 
)
inlineoverridevirtual

Function CreateWindow creates 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
wxWindow* - 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_I.

Definition at line 112 of file pcbnew.cpp.

References CreateServer(), FRAME_PCB, FRAME_PCB_FOOTPRINT_PREVIEW, FRAME_PCB_FOOTPRINT_WIZARD_MODAL, FRAME_PCB_MODULE_EDITOR, FRAME_PCB_MODULE_VIEWER, FRAME_PCB_MODULE_VIEWER_MODAL, KIFACE_I::IsSingle(), KICAD_PCB_PORT_SERVICE_NUMBER, Kiface(), FOOTPRINT_PREVIEW_PANEL::New(), and ScriptingSetPcbEditFrame().

113  {
114  wxWindow* frame = NULL;
115 
116  switch( aClassId )
117  {
118  case FRAME_PCB:
119  frame = dynamic_cast< wxWindow* >( new PCB_EDIT_FRAME( aKiway, aParent ) );
120 
121 #if defined( KICAD_SCRIPTING )
122  // give the scripting helpers access to our frame
124 #endif
125 
126  if( Kiface().IsSingle() )
127  {
128  // only run this under single_top, not under a project manager.
130  }
131 
132  break;
133 
135  frame = dynamic_cast< wxWindow* >( new FOOTPRINT_EDIT_FRAME( aKiway, aParent ) );
136  break;
137 
140  frame = dynamic_cast< wxWindow* >( new FOOTPRINT_VIEWER_FRAME( aKiway, aParent,
141  FRAME_T( aClassId ) ) );
142  break;
143 
145  frame = dynamic_cast< wxWindow* >( new FOOTPRINT_WIZARD_FRAME( aKiway, aParent,
146  FRAME_T( aClassId ) ) );
147  break;
148 
150  frame = dynamic_cast< wxWindow* >( FOOTPRINT_PREVIEW_PANEL::New( aKiway, aParent ) );
151  break;
152 
153  default:
154  break;
155  }
156 
157  return frame;
158  }
Class FOOTPRINT_WIZARD_FRAME.
#define KICAD_PCB_PORT_SERVICE_NUMBER
< Pcbnew listens on this port for commands from Eeschema
Definition: eda_dde.h:39
wxSocketServer * CreateServer(wxWindow *window, int service, bool local)
Definition: eda_dde.cpp:49
void ScriptingSetPcbEditFrame(PCB_EDIT_FRAME *aPCBEdaFrame)
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
Component library viewer main window.
Definition: modview_frame.h:44
static FOOTPRINT_PREVIEW_PANEL * New(KIWAY *aKiway, wxWindow *aParent)
bool IsSingle() const
Function IsSingle is this KIFACE_I running under single_top?
Definition: kiface_i.h:113
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: pcbnew.cpp:186
void KIFACE_I::end_common ( )
protectedinherited

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

Definition at line 104 of file kiface_i.cpp.

References BIN_MOD::End(), and KIFACE_I::m_bm.

Referenced by KIFACE_I::OnKifaceEnd(), PGE::IFACE::OnKifaceEnd(), GERBV::IFACE::OnKifaceEnd(), and CV::IFACE::OnKifaceEnd().

105 {
106  m_bm.End();
107 }
BIN_MOD m_bm
Definition: kiface_i.h:130
void End()
Definition: bin_mod.cpp:53
wxFileHistory& KIFACE_I::GetFileHistory ( )
inlineinherited
const wxString& KIFACE_I::GetHelpFileName ( ) const
inlineinherited

Function GetHelpFileName returns just the basename portion of the current help file.

Definition at line 119 of file kiface_i.h.

References KIFACE_I::m_bm, and BIN_MOD::m_help_file.

Referenced by EDA_BASE_FRAME::help_name().

119 { return m_bm.m_help_file; }
BIN_MOD m_bm
Definition: kiface_i.h:130
wxString m_help_file
Definition: bin_mod.h:59
void* PCB::IFACE::IfaceOrAddress ( int  aDataId)
inlineoverridevirtual

Function IfaceOrAddress return a 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.

Parameters
aDataIdidentifies which object you want the address of.
Returns
void* - and must be cast into the know type.

Implements KIFACE_I.

Definition at line 171 of file pcbnew.cpp.

172  {
173  return NULL;
174  }
bool KIFACE_I::IsSingle ( ) const
inlineinherited

Function IsSingle is this KIFACE_I running under single_top?

Definition at line 113 of file kiface_i.h.

References KFCTL_STANDALONE, and KIFACE_I::m_start_flags.

Referenced by SCH::IFACE::CreateWindow(), CreateWindow(), SCH_EDIT_FRAME::OnOpenPcbnew(), PCB_EDIT_FRAME::SendMessageToEESCHEMA(), and SCH_EDIT_FRAME::SendMessageToPCBNEW().

113 { return m_start_flags & KFCTL_STANDALONE; }
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_i.h:132
#define KFCTL_STANDALONE
Am running as a standalone Top.
Definition: kiway.h:158
SEARCH_STACK& KIFACE_I::KifaceSearch ( )
inlineinherited

Only for DSO specific 'non-library' files.

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

Definition at line 125 of file kiface_i.h.

References KIFACE_I::m_bm, and BIN_MOD::m_search.

Referenced by CVPCB_MAINFRAME::buildEquivalenceList(), FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), WORKSHEET_LAYOUT::MakeFullFileName(), WORKSHEET_LAYOUT::MakeShortFileName(), and EDA_BASE_FRAME::sys_search().

125 { return m_bm.m_search; }
BIN_MOD m_bm
Definition: kiface_i.h:130
SEARCH_STACK m_search
Definition: bin_mod.h:61
wxConfigBase* KIFACE_I::KifaceSettings ( ) const
inlineinherited

Definition at line 101 of file kiface_i.h.

References KIFACE_I::m_bm, and BIN_MOD::m_config.

Referenced by AUTOPLACER::AUTOPLACER(), PCB_EDIT_FRAME::Begin_Zone(), EDA_BASE_FRAME::config(), DIALOG_BOM::DIALOG_BOM(), DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE(), DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL(), DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT(), DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG(), DIALOG_EXPORT_3DFILE::DIALOG_EXPORT_3DFILE(), DIALOG_EXPORT_IDF3::DIALOG_EXPORT_IDF3(), DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP(), DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST(), DIALOG_GENDRILL::DIALOG_GENDRILL(), DIALOG_KEEPOUT_AREA_PROPERTIES::DIALOG_KEEPOUT_AREA_PROPERTIES(), DIALOG_NETLIST::DIALOG_NETLIST(), DIALOG_PLOT::DIALOG_PLOT(), DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC(), DIALOG_PRINT_FOR_MODEDIT::DIALOG_PRINT_FOR_MODEDIT(), DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER(), DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH(), DIALOG_SVG_PRINT::DIALOG_SVG_PRINT(), EDA_DRAW_PANEL::EDA_DRAW_PANEL(), FOOTPRINT_EDIT_FRAME::Export_Module(), FOOTPRINT_EDIT_FRAME::Import_Module(), DIALOG_GEN_MODULE_POSITION::initDialog(), PCB_BASE_FRAME::LoadCanvasTypeSetting(), NETLIST_DIALOG::NETLIST_DIALOG(), LAYERS_MAP_DIALOG::OnGetSetup(), SCH::IFACE::OnKifaceEnd(), SCH::IFACE::OnKifaceStart(), DIALOG_NON_COPPER_ZONES_EDITOR::OnOkClick(), LAYERS_MAP_DIALOG::OnStoreSetup(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::SaveCanvasTypeSetting(), and EDA_DRAW_PANEL::~EDA_DRAW_PANEL().

101 { return m_bm.m_config; }
BIN_MOD m_bm
Definition: kiface_i.h:130
wxConfigBase * m_config
maybe from $HOME/.${m_name}
Definition: bin_mod.h:57
const wxString KIFACE_I::Name ( )
inlineinherited

Definition at line 99 of file kiface_i.h.

References KIFACE_I::m_bm, and BIN_MOD::m_name.

99 { return wxString::FromUTF8( m_bm.m_name ); }
BIN_MOD m_bm
Definition: kiface_i.h:130
const char * m_name
name of this binary module, static C string.
Definition: bin_mod.h:55
void IFACE::OnKifaceEnd ( )
overridevirtual

Function OnKifaceEnd is 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.

Definition at line 361 of file pcbnew.cpp.

362 {
363  // This function deletes OpenGL contexts used (if any) by wxGLCanvas objects.
364  // It can be called only when closing the application, because it deletes an OpenGL context
365  // which can still be in usage. Destroying OpenGL contexts earlier may crash the application.
367 
368  end_common();
369 #if defined( KICAD_SCRIPTING_WXPYTHON )
370  // Restore the thread state and tell Python to cleanup after itself.
371  // wxPython will do its own cleanup as part of that process.
372  // This should only be called if python was setup correctly.
373 
374  if( IsWxPythonLoaded() )
376 #endif
377 }
void DeleteAll()
Function DeleteAll destroys all managed OpenGL contexts.
void pcbnewFinishPythonScripting()
static GL_CONTEXT_MANAGER & Get()
Function Get returns the GL_CONTEXT_MANAGER instance (singleton).
bool IsWxPythonLoaded()
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
Definition: kiface_i.cpp:104
bool IFACE::OnKifaceStart ( PGM_BASE aProgram,
int  aCtlBits 
)
overridevirtual

Function OnKifaceStart is called just once shortly after the DSO is loaded.

It is the second function called, immediately after the KIFACE_GETTER(). However before either of those, static C++ constructors are called. The DSO implementation should do process level initialization here, not project specific since there will be multiple projects open eventually.

Parameters
aProgramis the process block: PGM_BASE*
aCtlBitsconsists of bit flags from the set of KFCTL_* #defines above.
Returns
bool - true if DSO initialized OK, false if not. When returning false, the loader may optionally decide to terminate the process or not, but will not put out any UI because that is the duty of this function to say why it is returning false. Never return false without having reported to the UI why.

Implements KIFACE_I.

Definition at line 311 of file pcbnew.cpp.

References DisplayError(), DisplayInfoMessage(), Format(), g_Board_Editor_Hokeys_Descr, GetChars(), FP_LIB_TABLE::LoadGlobalTable(), PCB_EDIT_FRAME_NAME, ReadHotkeyConfig(), KIFACE_I::start_common(), and IO_ERROR::What().

312 {
313  // This is process level, not project level, initialization of the DSO.
314 
315  // Do nothing in here pertinent to a project!
316 
317  start_common( aCtlBits );
318 
319  // Must be called before creating the main frame in order to
320  // display the real hotkeys in menus or tool tips
322 
323  try
324  {
325  // The global table is not related to a specific project. All projects
326  // will use the same global table. So the KIFACE::OnKifaceStart() contract
327  // of avoiding anything project specific is not violated here.
328 
330  {
331  DisplayInfoMessage( NULL, _(
332  "You have run Pcbnew for the first time using the "
333  "new footprint library table method for finding footprints.\n"
334  "Pcbnew has either copied the default "
335  "table or created an empty table in the kicad configuration folder.\n"
336  "You must first configure the library "
337  "table to include all footprint libraries you want to use.\n"
338  "See the \"Footprint Library Table\" section of "
339  "the CvPcb or Pcbnew documentation for more information." ) );
340  }
341  }
342  catch( const IO_ERROR& ioe )
343  {
344  wxString msg = wxString::Format( _(
345  "An error occurred attempting to load the global footprint library "
346  "table:\n\n%s" ),
347  GetChars( ioe.What() )
348  );
349  DisplayError( NULL, msg );
350  return false;
351  }
352 
353 #if defined(KICAD_SCRIPTING)
354  scriptingSetup();
355 #endif
356 
357  return true;
358 }
void ReadHotkeyConfig(const wxString &Appname, struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfig Read hotkey configuration for a given app, possibly before the frame for th...
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_i.cpp:94
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:308
struct EDA_HOTKEY_CONFIG g_Board_Editor_Hokeys_Descr[]
static bool LoadGlobalTable(FP_LIB_TABLE &aTable)
Function LoadGlobalTable loads the global footprint library table into aTable.
void DisplayInfoMessage(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:89
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define PCB_EDIT_FRAME_NAME
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
Definition: wxPcbStruct.h:78
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
bool KIFACE_I::start_common ( int  aCtlBits)
protectedinherited

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

Definition at line 94 of file kiface_i.cpp.

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

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

95 {
96  m_start_flags = aCtlBits;
97  m_bm.Init();
99 
100  return true;
101 }
KIWAY::FACE_T m_id
Definition: kiface_i.h:128
void Init()
Definition: bin_mod.cpp:36
BIN_MOD m_bm
Definition: kiface_i.h:130
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_i.h:132
SEARCH_STACK m_search
Definition: bin_mod.h:61
static void setSearchPaths(SEARCH_STACK *aDst, KIWAY::FACE_T aId)
Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings.
Definition: kiface_i.cpp:38
int KIFACE_I::StartFlags ( ) const
inlineinherited

Function StartFlags returns whatever was passed as aCtlBits to OnKifaceStart()

Definition at line 107 of file kiface_i.h.

References KIFACE_I::m_start_flags.

107 { return m_start_flags; }
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_i.h:132

The documentation for this struct was generated from the following file: