KiCad PCB EDA Suite
pcbnew.cpp File Reference

Pcbnew main program. More...

#include <pcbnew_scripting_helpers.h>
#include <pgm_base.h>
#include <kiface_base.h>
#include <kiface_ids.h>
#include <confirm.h>
#include <pcb_edit_frame.h>
#include <eda_dde.h>
#include <macros.h>
#include <wx/snglinst.h>
#include <gestfich.h>
#include <paths.h>
#include <pcbnew_settings.h>
#include <settings/settings_manager.h>
#include <class_draw_panel_gal.h>
#include <fp_lib_table.h>
#include <footprint_edit_frame.h>
#include <footprint_viewer_frame.h>
#include <footprint_wizard_frame.h>
#include <footprint_preview_panel.h>
#include <footprint_info_impl.h>
#include <dialogs/dialog_configure_paths.h>
#include <python_scripting.h>
#include "invoke_pcb_dialog.h"
#include "dialog_global_fp_lib_table_config.h"
#include <wildcards_and_files_ext.h>

Go to the source code of this file.


struct  PCB::IFACE




PyObject * PyInit__pcbnew (void)
 IFACE (const char *aName, KIWAY::FACE_T aType)
bool OnKifaceStart (PGM_BASE *aProgram, int aCtlBits) override
void OnKifaceEnd () override
wxWindow * CreateWindow (wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
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...
 Global KIFACE_BASE "get" accessor. More...


static PGM_BASEprocess
int aKiwayVersion
int PGM_BASEaProgram
return & kiface
FP_LIB_TABLE GFootprintTable
 The global footprint library table. More...
 The global footprint info table. More...

Detailed Description

Pcbnew main program.

Definition in file pcbnew.cpp.

Function Documentation

◆ CreateWindow()

wxWindow* kiface::CreateWindow ( wxWindow *  aParent,
int  aClassId,
KIWAY aKiway,
int  aCtlBits = 0 

Definition at line 293 of file pcbnew.cpp.

302  {
303  if( destFile.GetName() == aSrcProjectName )
304  destFile.SetName( aNewProjectName );
306  KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
307  }
308  else if( ext == LegacyPcbFileExtension )
309  {
310  if( destFile.GetName() == aSrcProjectName )
311  destFile.SetName( aNewProjectName );
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 );
339  for( unsigned i = 0; i < fpLibTable.GetCount(); i++ )
340  {
341  LIB_TABLE_ROW& row = fpLibTable.At( i );
342  wxString uri = row.GetFullURI();
344  uri.Replace( wxT( "/" ) + aSrcProjectName + wxT( ".pretty" ),
345  wxT( "/" ) + aNewProjectName + wxT( ".pretty" ) );
347  row.SetFullURI( uri );
348  }
350  fpLibTable.Save( destFile.GetFullPath() );
351  }
352  catch( ... )
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
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 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
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.

References KiCopyFile().


kiface::IFACE ( const char *  aName,

Definition at line 285 of file pcbnew.cpp.

285 {
286  wxFileName destFile( aSrcFilePath );
287  wxString destPath = destFile.GetPathWithSep();

◆ IfaceOrAddress()

void* kiface::IfaceOrAddress ( int  aDataId)

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.

aDataIdidentifies which object you want the address of.
the object which must be cast into the know type.

Definition at line 364 of file pcbnew.cpp.

364  {
365  wxFAIL_MSG( wxT( "Unexpected filetype for Pcbnew::SaveFileAs()" ) );
366  }
367 }

◆ Kiface()

KIFACE_BASE& Kiface ( )

Global KIFACE_BASE "get" accessor.

Definition at line 192 of file pcbnew.cpp.

192 { return kiface; }
return & kiface
Definition: pcbnew.cpp:200

References PCB::kiface().

Referenced by PCB::IFACE::CreateWindow().

◆ MY_API()


◆ OnKifaceEnd()

void kiface::OnKifaceEnd ( )

Definition at line 47 of file mocks_eeschema.cpp.

47  {
48  return true;
49  }

◆ OnKifaceStart()

bool kiface::OnKifaceStart ( PGM_BASE aProgram,
int  aCtlBits 

Definition at line 40 of file common_mocks.cpp.

40 {
41  static PGM_TEST_FRAME program;
42  return program;
43 }

References PGM_TEST_FRAME::OnPgmInit(), and program.

◆ PyInit__pcbnew()

PyObject* PyInit__pcbnew ( void  )

◆ SaveFileAs()

void kiface::SaveFileAs ( const wxString &  aProjectBasePath,
const wxString &  aSrcProjectName,
const wxString &  aNewProjectBasePath,
const wxString &  aNewProjectName,
const wxString &  aSrcFilePath,
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).

Variable Documentation

◆ aKiwayVersion

int aKiwayVersion

Definition at line 197 of file pcbnew.cpp.

◆ aProgram

int PGM_BASE* aProgram
Initial value:
static PGM_BASE * process
Definition: pcbnew.cpp:189
int PGM_BASE * aProgram
Definition: pcbnew.cpp:198

Definition at line 198 of file pcbnew.cpp.

Referenced by PCB::IFACE::OnKifaceStart().

◆ GFootprintList


The global footprint info table.

This is performance-intensive to build so we keep a hash-stamped global version. Any deviation from the request vs. stored hash will result in it being rebuilt.

Definition at line 228 of file pcbnew.cpp.

Referenced by PCB_BASE_EDIT_FRAME::doCloseWindow(), FOOTPRINT_EDIT_FRAME::doCloseWindow(), FP_TREE_MODEL_ADAPTER::getFootprints(), PCB::IFACE::IfaceOrAddress(), FOOTPRINT_EDIT_FRAME::initLibraryTree(), PCB_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::SelectFootprintFromLibTree(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().

◆ GFootprintTable

FP_LIB_TABLE GFootprintTable

The global footprint library table.

This is not dynamically allocated because in a multiple project environment we must keep its address constant (since it is the fallback table for multiple projects).

Definition at line 223 of file pcbnew.cpp.

Referenced by PCB::IFACE::IfaceOrAddress(), and PCB::IFACE::OnKifaceStart().

◆ kiface

return& kiface

Definition at line 200 of file pcbnew.cpp.

◆ process

PGM_BASE* process

Definition at line 189 of file pcbnew.cpp.