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

Public Member Functions

 IFACE (const char *aName, KIWAY::FACE_T aType)
 
bool OnKifaceStart (PGM_BASE *aProgram, int aCtlBits) override
 Typically start_common() is called from here. More...
 
void OnKifaceEnd () override
 Called just once just before the DSO is to be unloaded. More...
 
wxWindow * CreateWindow (wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
 Create a wxWindow for the current project. More...
 
void * IfaceOrAddress (int aDataId) override
 Return a pointer to the requested object. More...
 
void SaveFileAs (const wxString &aProjectBasePath, const wxString &aSrcProjectName, const wxString &aNewProjectBasePath, const wxString &aNewProjectName, const wxString &aSrcFilePath, wxString &aErrors) override
 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...
 
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...
 

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

Constructor & Destructor Documentation

◆ IFACE()

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

Definition at line 69 of file pcbnew.cpp.

69  :
70  KIFACE_BASE( aName, aType )
71  {}
KIFACE_BASE(const char *aKifaceName, KIWAY::FACE_T aId)
Definition: kiface_base.h:64

Member Function Documentation

◆ CreateWindow()

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

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

Definition at line 77 of file pcbnew.cpp.

79  {
80  switch( aClassId )
81  {
82  case FRAME_PCB_EDITOR:
83  {
84  auto frame = new PCB_EDIT_FRAME( aKiway, aParent );
85 
86  // give the scripting helpers access to our frame
87  ScriptingSetPcbEditFrame( frame );
88 
89  if( Kiface().IsSingle() )
90  {
91  // only run this under single_top, not under a project manager.
92  frame->CreateServer( KICAD_PCB_PORT_SERVICE_NUMBER );
93  }
94 
95  return frame;
96  }
97 
99  return new FOOTPRINT_EDIT_FRAME( aKiway, aParent );
100 
103  return new FOOTPRINT_VIEWER_FRAME( aKiway, aParent, FRAME_T( aClassId ) );
104 
106  return new FOOTPRINT_WIZARD_FRAME( aKiway, aParent, FRAME_T( aClassId ) );
107 
109  return dynamic_cast< wxWindow* >( FOOTPRINT_PREVIEW_PANEL::New( aKiway, aParent ) );
110 
112  {
113  DIALOG_CONFIGURE_PATHS dlg( aParent, aKiway->Prj().Get3DFilenameResolver() );
114 
115  // The dialog's constructor probably failed to set its Kiway because the
116  // dynamic_cast fails when aParent was allocated by a separate compilation
117  // module. So set it directly.
118  dlg.SetKiway( &dlg, aKiway );
119 
120  // Use QuasiModal so that HTML help window will work
121  if( dlg.ShowQuasiModal() == wxID_OK )
122  aKiway->CommonSettingsChanged( true, false );
123 
124  // Dialog has completed; nothing to return.
125  return nullptr;
126  }
127 
129  InvokePcbLibTableEditor( aKiway, aParent );
130  // Dialog has completed; nothing to return.
131  return nullptr;
132 
133  default:
134  return nullptr;
135  }
136  }
void SetKiway(wxWindow *aDest, KIWAY *aKiway)
It is only used for debugging, since "this" is not a wxWindow*.
#define KICAD_PCB_PORT_SERVICE_NUMBER
< Pcbnew listens on this port for commands from Eeschema
Definition: eda_dde.h:40
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:32
Component library viewer main window.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition: pcbnew.cpp:192
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)
The main frame for Pcbnew.
bool IsSingle() const
Is this KIFACE running under single_top?
Definition: kiface_base.h:104

References KIWAY::CommonSettingsChanged(), DIALOG_CONFIGUREPATHS, DIALOG_PCB_LIBRARY_TABLE, FRAME_FOOTPRINT_EDITOR, FRAME_FOOTPRINT_PREVIEW, FRAME_FOOTPRINT_VIEWER, FRAME_FOOTPRINT_VIEWER_MODAL, FRAME_FOOTPRINT_WIZARD, FRAME_PCB_EDITOR, InvokePcbLibTableEditor(), KIFACE_BASE::IsSingle(), KICAD_PCB_PORT_SERVICE_NUMBER, Kiface(), FOOTPRINT_PREVIEW_PANEL::New(), KIWAY::Prj(), ScriptingSetPcbEditFrame(), and KIWAY_HOLDER::SetKiway().

◆ end_common()

void KIFACE_BASE::end_common ( )
protectedinherited

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 }
BIN_MOD m_bm
Definition: kiface_base.h:118
void End()
Definition: bin_mod.cpp:50

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

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

◆ GetHelpFileName()

const wxString& KIFACE_BASE::GetHelpFileName ( ) const
inlineinherited

Return just the basename portion of the current help file.

Definition at line 109 of file kiface_base.h.

109 { return m_bm.m_help_file; }
BIN_MOD m_bm
Definition: kiface_base.h:118
wxString m_help_file
Definition: bin_mod.h:58

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

Referenced by EDA_BASE_FRAME::help_name().

◆ IfaceOrAddress()

void* PCB::IFACE::IfaceOrAddress ( int  aDataId)
inlineoverridevirtual

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
the object which must be cast into the know type.

Implements KIFACE_BASE.

Definition at line 148 of file pcbnew.cpp.

149  {
150  switch( aDataId )
151  {
152  // Return a pointer to the global instance of the footprint list.
154  return (void*) &GFootprintList;
155 
156  // Return a new FP_LIB_TABLE with the global table installed as a fallback.
158  return (void*) new FP_LIB_TABLE( &GFootprintTable );
159 
160  // Return a pointer to the global instance of the global footprint table.
162  return (void*) &GFootprintTable;
163 
165  return reinterpret_cast<void*>( PyInit__pcbnew );
166 
167  default:
168  return nullptr;
169  }
170  }
Return the global FP_LIB_TABLE.
Definition: kiface_ids.h:53
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:223
PyObject * PyInit__pcbnew(void)
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:228
Return a pointer to the global instance of FOOTPRINT_LIST from pcbnew.
Definition: kiface_ids.h:39

References GFootprintList, GFootprintTable, KIFACE_FOOTPRINT_LIST, KIFACE_GLOBAL_FOOTPRINT_TABLE, KIFACE_NEW_FOOTPRINT_TABLE, KIFACE_SCRIPTING_LEGACY, and PyInit__pcbnew().

◆ InitSettings()

void KIFACE_BASE::InitSettings ( APP_SETTINGS_BASE aSettings)
inlineinherited

Definition at line 94 of file kiface_base.h.

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

References BIN_MOD::InitSettings(), and KIFACE_BASE::m_bm.

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

◆ IsSingle()

◆ KifaceSearch()

SEARCH_STACK& KIFACE_BASE::KifaceSearch ( )
inlineinherited

Only for DSO specific 'non-library' files.

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

Definition at line 113 of file kiface_base.h.

113 { return m_bm.m_search; }
BIN_MOD m_bm
Definition: kiface_base.h:118
SEARCH_STACK m_search
Definition: bin_mod.h:60

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

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

◆ KifaceSettings()

◆ Name()

const wxString KIFACE_BASE::Name ( )
inlineinherited

Definition at line 87 of file kiface_base.h.

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

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

◆ OnKifaceEnd()

void IFACE::OnKifaceEnd ( )
overridevirtual

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.

Reimplemented from KIFACE_BASE.

Definition at line 276 of file pcbnew.cpp.

277 {
278  end_common();
279 }
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.

References KIFACE_BASE::end_common().

◆ OnKifaceStart()

bool IFACE::OnKifaceStart ( PGM_BASE aProgram,
int  aCtlBits 
)
overridevirtual

Typically start_common() is called from here.

Implements KIFACE_BASE.

Definition at line 231 of file pcbnew.cpp.

232 {
233  // This is process-level-initialization, not project-level-initialization of the DSO.
234  // Do nothing in here pertinent to a project!
237 
238  start_common( aCtlBits );
239 
240  wxFileName fn = FP_LIB_TABLE::GetGlobalTableFileName();
241 
242  if( !fn.FileExists() )
243  {
244  DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG fpDialog( nullptr );
245 
246  fpDialog.ShowModal();
247  }
248  else
249  {
250  try
251  {
252  // The global table is not related to a specific project. All projects
253  // will use the same global table. So the KIFACE::OnKifaceStart() contract
254  // of avoiding anything project specific is not violated here.
256  return false;
257  }
258  catch( const IO_ERROR& ioe )
259  {
260  // if we are here, a incorrect global footprint library table was found.
261  // Incorrect global symbol library table is not a fatal error:
262  // the user just has to edit the (partially) loaded table.
263  wxString msg = _( "An error occurred attempting to load the global footprint library "
264  "table.\n"
265  "Please edit this global footprint library table in Preferences "
266  "menu." );
267 
268  DisplayErrorMessage( nullptr, msg, ioe.What() );
269  }
270  }
271 
272  return true;
273 }
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:129
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Takes ownership of the pointer passed in.
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:223
void InitSettings(APP_SETTINGS_BASE *aSettings)
Definition: kiface_base.h:94
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
static bool LoadGlobalTable(FP_LIB_TABLE &aTable)
Load the global footprint library table into aTable.
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_base.cpp:97
#define _(s)
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:92
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
static wxString GetGlobalTableFileName()
int PGM_BASE * aProgram
Definition: pcbnew.cpp:198

References _, aProgram, DisplayErrorMessage(), FP_LIB_TABLE::GetGlobalTableFileName(), PGM_BASE::GetSettingsManager(), GFootprintTable, KIFACE_BASE::InitSettings(), KIFACE_BASE::KifaceSettings(), FP_LIB_TABLE::LoadGlobalTable(), SETTINGS_MANAGER::RegisterSettings(), KIFACE_BASE::start_common(), and IO_ERROR::What().

◆ SaveFileAs()

void IFACE::SaveFileAs ( const wxString &  aProjectBasePath,
const wxString &  aSrcProjectName,
const wxString &  aNewProjectBasePath,
const wxString &  aNewProjectName,
const wxString &  aSrcFilePath,
wxString &  aErrors 
)
overridevirtual

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

Definition at line 282 of file pcbnew.cpp.

285 {
286  wxFileName destFile( aSrcFilePath );
287  wxString destPath = destFile.GetPathWithSep();
288  wxUniChar pathSep = wxFileName::GetPathSeparator();
289  wxString ext = destFile.GetExt();
290 
291  if( destPath.StartsWith( aProjectBasePath + pathSep ) )
292  destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
293 
294  wxString srcProjectFootprintLib = pathSep + aSrcProjectName + wxT( ".pretty" ) + pathSep;
295  wxString newProjectFootprintLib = pathSep + aNewProjectName + wxT( ".pretty" ) + pathSep;
296 
297  destPath.Replace( srcProjectFootprintLib, newProjectFootprintLib, true );
298 
299  destFile.SetPath( destPath );
300 
302  {
303  if( destFile.GetName() == aSrcProjectName )
304  destFile.SetName( aNewProjectName );
305 
306  KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
307  }
308  else if( ext == LegacyPcbFileExtension )
309  {
310  if( destFile.GetName() == aSrcProjectName )
311  destFile.SetName( aNewProjectName );
312 
313  KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
314  }
316  {
317  // Footprints are not project-specific. Keep their source names.
318  KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
319  }
320  else if( ext == FootprintAssignmentFileExtension )
321  {
322  // JEY TODO
323  }
324  else if( ext == wxT( "rpt" ) )
325  {
326  // DRC must be the "gold standard". Since we can't guarantee that there aren't
327  // any non-deterministic cases in the save-as algorithm, we don't want to certify
328  // the result with the source's DRC report. Therefore copy it under the old
329  // name.
330  KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
331  }
332  else if( destFile.GetName() == wxT( "fp-lib-table" ) )
333  {
334  try
335  {
336  FP_LIB_TABLE fpLibTable;
337  fpLibTable.Load( aSrcFilePath );
338 
339  for( unsigned i = 0; i < fpLibTable.GetCount(); i++ )
340  {
341  LIB_TABLE_ROW& row = fpLibTable.At( i );
342  wxString uri = row.GetFullURI();
343 
344  uri.Replace( wxT( "/" ) + aSrcProjectName + wxT( ".pretty" ),
345  wxT( "/" ) + aNewProjectName + wxT( ".pretty" ) );
346 
347  row.SetFullURI( uri );
348  }
349 
350  fpLibTable.Save( destFile.GetFullPath() );
351  }
352  catch( ... )
353  {
354  wxString msg;
355 
356  if( !aErrors.empty() )
357  aErrors += wxT( "\n" );
358 
359  msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
360  aErrors += msg;
361  }
362  }
363  else
364  {
365  wxFAIL_MSG( wxT( "Unexpected filetype for Pcbnew::SaveFileAs()" ) );
366  }
367 }
const std::string LegacyFootprintLibPathExtension
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
const std::string KiCadFootprintFileExtension
const std::string LegacyPcbFileExtension
const std::string BackupFileSuffix
unsigned GetCount() const
Get the number of rows contained in the table.
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
Definition: gestfich.cpp:214
const std::string KiCadPcbFileExtension
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const std::string FootprintAssignmentFileExtension
#define _(s)
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
void SetFullURI(const wxString &aFullURI)
Change the full URI for the library.
LIB_TABLE_ROW & At(unsigned aIndex)
Get the 'n'th LIB_TABLE_ROW object.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.

◆ start_common()

bool KIFACE_BASE::start_common ( int  aCtlBits)
protectedinherited

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 }
BIN_MOD m_bm
Definition: kiface_base.h:118
void Init()
Definition: bin_mod.cpp:38
static void setSearchPaths(SEARCH_STACK *aDst, KIWAY::FACE_T aId)
Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings.
Definition: kiface_base.cpp:33
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_base.h:120
SEARCH_STACK m_search
Definition: bin_mod.h:60
KIWAY::FACE_T m_id
Definition: kiface_base.h:116

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

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

◆ StartFlags()

int KIFACE_BASE::StartFlags ( ) const
inlineinherited

Return whatever was passed as aCtlBits to OnKifaceStart().

Definition at line 99 of file kiface_base.h.

99 { return m_start_flags; }
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_base.h:120

References KIFACE_BASE::m_start_flags.


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