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...
 
FILE_HISTORYGetFileHistory ()
 
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 96 of file pcbnew.cpp.

Constructor & Destructor Documentation

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

Definition at line 100 of file pcbnew.cpp.

References aProgram, OnKifaceEnd(), and OnKifaceStart().

100  :
101  KIFACE_I( aName, aType )
102  {}
KIFACE_I(const char *aKifaceName, KIWAY::FACE_T aId)
Constructor.
Definition: kiface_i.h:78

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 108 of file pcbnew.cpp.

References DIALOG_PCB_LIBRARY_TABLE, FRAME_PCB, FRAME_PCB_FOOTPRINT_PREVIEW, FRAME_PCB_FOOTPRINT_WIZARD, FRAME_PCB_MODULE_EDITOR, FRAME_PCB_MODULE_VIEWER, FRAME_PCB_MODULE_VIEWER_MODAL, EDA_DRAW_PANEL_GAL::GetBackend(), EDA_DRAW_FRAME::GetGalCanvas(), InvokePcbLibTableEditor(), KIFACE_I::IsSingle(), KICAD_PCB_PORT_SERVICE_NUMBER, Kiface(), EDA_DRAW_FRAME::LoadCanvasTypeSetting(), FOOTPRINT_PREVIEW_PANEL::New(), and ScriptingSetPcbEditFrame().

109  {
110  switch( aClassId )
111  {
112  case FRAME_PCB:
113  {
114  auto frame = new PCB_EDIT_FRAME( aKiway, aParent );
115 
116 #if defined( KICAD_SCRIPTING )
117  // give the scripting helpers access to our frame
118  ScriptingSetPcbEditFrame( frame );
119 #endif
120 
121  if( Kiface().IsSingle() )
122  {
123  // only run this under single_top, not under a project manager.
124  frame->CreateServer( KICAD_PCB_PORT_SERVICE_NUMBER );
125  }
126 
127  return frame;
128  }
129 
133  {
135  auto pcbFrame = static_cast<PCB_EDIT_FRAME*>( wxWindow::FindWindowByName( wxT( "Pcbnew" ) ) );
136 
137  if( pcbFrame )
138  backend = pcbFrame->GetGalCanvas()->GetBackend();
139  else
141 
142  switch( aClassId )
143  {
145  return new FOOTPRINT_EDIT_FRAME( aKiway, aParent, backend );
148  return new FOOTPRINT_VIEWER_FRAME( aKiway, aParent, FRAME_T( aClassId ) );
149  }
150  }
151 
153  return new FOOTPRINT_WIZARD_FRAME( aKiway, aParent, FRAME_T( aClassId ) );
154 
156  return dynamic_cast< wxWindow* >( FOOTPRINT_PREVIEW_PANEL::New( aKiway, aParent ) );
157 
159  InvokePcbLibTableEditor( aKiway, aParent );
160 
161  // Dialog has completed; nothing to return.
162  return nullptr;
163 
164  default:
165  return nullptr;
166  }
167  }
Class FOOTPRINT_WIZARD_FRAME.
#define KICAD_PCB_PORT_SERVICE_NUMBER
< Pcbnew listens on this port for commands from Eeschema
Definition: eda_dde.h:39
GAL_TYPE GetBackend() const
Function GetBackend Returns the type of backend currently used by GAL canvas.
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.
static EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
void ScriptingSetPcbEditFrame(PCB_EDIT_FRAME *aPcbEditFrame)
void InvokePcbLibTableEditor(KIWAY *aKiway, wxWindow *aCaller)
Function InvokePcbLibTableEditor shows the modal DIALOG_FP_LIB_TABLE for purposes of editing the glob...
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:115
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:928
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: pcbnew.cpp:211
void KIFACE_I::end_common ( )
protectedinherited

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

Definition at line 100 of file kiface_i.cpp.

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

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

101 {
102  m_bm.End();
103 }
BIN_MOD m_bm
Definition: kiface_i.h:132
void End()
Definition: bin_mod.cpp:63
const wxString& KIFACE_I::GetHelpFileName ( ) const
inlineinherited

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

Definition at line 121 of file kiface_i.h.

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

Referenced by EDA_BASE_FRAME::help_name().

121 { return m_bm.m_help_file; }
BIN_MOD m_bm
Definition: kiface_i.h:132
wxString m_help_file
Definition: bin_mod.h:60
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 180 of file pcbnew.cpp.

References KIWAY::FACE_PCB, GFootprintList, GFootprintTable, PCB::kiface(), KIFACE_FOOTPRINT_LIST, KIFACE_GLOBAL_FOOTPRINT_TABLE, and KIFACE_NEW_FOOTPRINT_TABLE.

181  {
182  switch( aDataId )
183  {
184  // Return a pointer to the global instance of the footprint list.
186  return (void*) &GFootprintList;
187 
188  // Return a new FP_LIB_TABLE with the global table installed as a fallback.
190  return (void*) new FP_LIB_TABLE( &GFootprintTable );
191 
192  // Return a pointer to the global instance of the global footprint table.
194  return (void*) &GFootprintTable;
195 
196  default:
197  return nullptr;
198  }
199  }
Return the global FP_LIB_TABLE.
Definition: kiface_ids.h:53
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:333
Return a new FP_LIB_TABLE with the global table installed as a fallback.
Definition: kiface_ids.h:46
FOOTPRINT_LIST_IMPL GFootprintList
The global footprint info table.
Definition: pcbnew.cpp:338
Return a pointer to the global instance of FOOTPRINT_LIST from pcbnew.
Definition: kiface_ids.h:39
bool KIFACE_I::IsSingle ( ) const
inlineinherited

Function IsSingle is this KIFACE_I running under single_top?

Definition at line 115 of file kiface_i.h.

References KFCTL_STANDALONE, and KIFACE_I::m_start_flags.

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

115 { return m_start_flags & KFCTL_STANDALONE; }
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_i.h:134
#define KFCTL_STANDALONE
Am running as a standalone Top.
Definition: kiway.h:159
SEARCH_STACK& KIFACE_I::KifaceSearch ( )
inlineinherited
wxConfigBase* KIFACE_I::KifaceSettings ( ) const
inlineinherited

Definition at line 103 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_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC(), DIALOG_EXPORT_3DFILE::DIALOG_EXPORT_3DFILE(), DIALOG_EXPORT_IDF3::DIALOG_EXPORT_IDF3(), DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP(), DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG(), DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR(), DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR(), DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST(), DIALOG_GENDRILL::DIALOG_GENDRILL(), DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX(), DIALOG_KEEPOUT_AREA_PROPERTIES::DIALOG_KEEPOUT_AREA_PROPERTIES(), DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE(), DIALOG_NETLIST::DIALOG_NETLIST(), DIALOG_PLOT::DIALOG_PLOT(), DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC(), DIALOG_PRINT_GERBVIEW::DIALOG_PRINT_GERBVIEW(), DIALOG_PRINT_PCBNEW::DIALOG_PRINT_PCBNEW(), DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH(), DIALOG_UPDATE_PCB::DIALOG_UPDATE_PCB(), EDA_DRAW_PANEL::EDA_DRAW_PANEL(), FOOTPRINT_EDIT_FRAME::Export_Module(), FOOTPRINT_EDIT_FRAME::Import_Module(), DIALOG_GEN_FOOTPRINT_POSITION::initDialog(), DIALOG_ANNOTATE::InitValues(), EDA_DRAW_FRAME::LoadCanvasTypeSetting(), NETLIST_DIALOG::NETLIST_DIALOG(), FOOTPRINT_PREVIEW_PANEL::New(), LAYERS_MAP_DIALOG::OnGetSetup(), SCH::IFACE::OnKifaceEnd(), SCH::IFACE::OnKifaceStart(), LAYERS_MAP_DIALOG::OnStoreSetup(), SCH_EDIT_FRAME::OpenProjectFiles(), EDA_DRAW_FRAME::saveCanvasTypeSetting(), and DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataFromWindow().

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

Definition at line 101 of file kiface_i.h.

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

101 { return wxString::FromUTF8( m_bm.m_name ); }
BIN_MOD m_bm
Definition: kiface_i.h:132
const char * m_name
name of this binary module, static C string.
Definition: bin_mod.h:56
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 395 of file pcbnew.cpp.

Referenced by IFACE().

396 {
397 #if defined( KICAD_SCRIPTING_WXPYTHON )
398  // Restore the thread state and tell Python to cleanup after itself.
399  // wxPython will do its own cleanup as part of that process.
400  // This should only be called if python was setup correctly.
401 
402  if( IsWxPythonLoaded() )
404 #endif
405 
406  end_common();
407 }
void pcbnewFinishPythonScripting()
bool IsWxPythonLoaded()
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
Definition: kiface_i.cpp:100
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 342 of file pcbnew.cpp.

References DisplayErrorMessage(), DisplayInfoMessage(), g_Board_Editor_Hotkeys_Descr, FP_LIB_TABLE::LoadGlobalTable(), PCB_EDIT_FRAME_NAME, ReadHotkeyConfig(), KIFACE_I::start_common(), and IO_ERROR::What().

Referenced by IFACE().

343 {
344  // This is process level, not project level, initialization of the DSO.
345 
346  // Do nothing in here pertinent to a project!
347 
348  start_common( aCtlBits );
349 
350  // Must be called before creating the main frame in order to
351  // display the real hotkeys in menus or tool tips
353 
354  try
355  {
356  // The global table is not related to a specific project. All projects
357  // will use the same global table. So the KIFACE::OnKifaceStart() contract
358  // of avoiding anything project specific is not violated here.
359 
361  {
362  DisplayInfoMessage( NULL, _(
363  "You have run Pcbnew for the first time using the "
364  "new footprint library table method for finding footprints.\n"
365  "Pcbnew has either copied the default "
366  "table or created an empty table in the kicad configuration folder.\n"
367  "You must first configure the library "
368  "table to include all footprint libraries you want to use.\n"
369  "See the \"Footprint Library Table\" section of "
370  "the CvPcb or Pcbnew documentation for more information." ) );
371  }
372  }
373  catch( const IO_ERROR& ioe )
374  {
375  // if we are here, a incorrect global footprint library table was found.
376  // Incorrect global footprint library table is not a fatal error:
377  // the user just has to edit the (partially) loaded table.
378 
379  wxString msg = _(
380  "An error occurred attempting to load the global footprint library table:\n"
381  "Please edit this global footprint library table in Preferences menu"
382  );
383 
384  DisplayErrorMessage( NULL, msg, ioe.What() );
385  }
386 
387 #if defined(KICAD_SCRIPTING)
388  scriptingSetup();
389 #endif
390 
391  return true;
392 }
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_i.cpp:90
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:259
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:333
#define PCB_EDIT_FRAME_NAME
Definition: draw_frame.h:56
static bool LoadGlobalTable(FP_LIB_TABLE &aTable)
Function LoadGlobalTable loads the global footprint library table into aTable.
struct EDA_HOTKEY_CONFIG g_Board_Editor_Hotkeys_Descr[]
int ReadHotkeyConfig(const wxString &aAppname, struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfig Read configuration data and fill the current hotkey list with hotkeys...
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:277
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
bool KIFACE_I::start_common ( int  aCtlBits)
protectedinherited

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

Definition at line 90 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 KIFACE_I::KIFACE_I(), PGE::IFACE::OnKifaceStart(), GERBV::IFACE::OnKifaceStart(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), and OnKifaceStart().

91 {
92  m_start_flags = aCtlBits;
93  m_bm.Init();
95 
96  return true;
97 }
KIWAY::FACE_T m_id
Definition: kiface_i.h:130
void Init()
Definition: bin_mod.cpp:38
BIN_MOD m_bm
Definition: kiface_i.h:132
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_i.h:134
SEARCH_STACK m_search
Definition: bin_mod.h:62
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 109 of file kiface_i.h.

References KIFACE_I::m_start_flags.

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

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