KiCad PCB EDA Suite
pcbnew/pcbnew.cpp File Reference
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <kiface_ids.h>
#include <confirm.h>
#include <macros.h>
#include <pcb_edit_frame.h>
#include <eda_dde.h>
#include <wx/file.h>
#include <wx/snglinst.h>
#include <gestfich.h>
#include <pcbnew.h>
#include <pcbnew_settings.h>
#include <settings/settings_manager.h>
#include <class_board.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 <dialog_configure_paths.h>
#include "invoke_pcb_dialog.h"
#include "dialog_global_fp_lib_table_config.h"

Go to the source code of this file.

Classes

struct  PCB::IFACE
 

Namespaces

 PCB
 

Functions

bool IsWxPythonLoaded ()
 
PCB::IFACE KIFACE_I PCB::kiface ("pcbnew", KIWAY::FACE_PCB)
 
 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
 Function IfaceOrAddress 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
 Function SaveFileAs 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...
 
KIFACE_IKiface ()
 Global KIFACE_I "get" accessor. More...
 
 MY_API (KIFACE *) KIFACE_GETTER(int *aKIFACEversion
 
void PythonPluginsReloadBase ()
 Helper function PythonPluginsReloadBase Reload Python plugins if they are newer than the already loaded, and load new plugins if any It calls the LoadPlugins(bundlepath) Python method see kicadplugins.i. More...
 

Variables

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

Function Documentation

◆ CreateWindow()

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

Definition at line 397 of file pcbnew/pcbnew.cpp.

406  {
407  if( destFile.GetName() == aSrcProjectName )
408  destFile.SetName( aNewProjectName );
409 
410  CopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
411  }
412  else if( ext == "brd" )
413  {
414  if( destFile.GetName() == aSrcProjectName )
415  destFile.SetName( aNewProjectName );
416 
417  CopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
418  }
419  else if( ext == "mod" || ext == "kicad_mod" )
420  {
421  // Footprints are not project-specific. Keep their source names.
422  CopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
423  }
424  else if( ext == "cmp" )
425  {
426  // JEY TODO
427  }
428  else if( ext == "rpt" )
429  {
430  // DRC must be the "gold standard". Since we can't gaurantee that there aren't
431  // any non-deterministic cases in the save-as algorithm, we don't want to certify
432  // the result with the source's DRC report. Therefore copy it under the old
433  // name.
434  CopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
435  }
436  else if( destFile.GetName() == "fp-lib-table" )
437  {
438  try
439  {
440  FP_LIB_TABLE fpLibTable;
441  fpLibTable.Load( aSrcFilePath );
442 
443  for( unsigned i = 0; i < fpLibTable.GetCount(); i++ )
444  {
445  LIB_TABLE_ROW& row = fpLibTable.At( i );
446  wxString uri = row.GetFullURI();
447 
448  uri.Replace( "/" + aSrcProjectName + ".pretty", "/" + aNewProjectName + ".pretty" );
449 
450  row.SetFullURI( uri );
451  }
452 
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
unsigned GetCount() const
Get the number of rows contained in the table.
void CopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
Function CopyFile.
Definition: gestfich.cpp:363
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...
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.

References CopyFile().

◆ IFACE()

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

Definition at line 389 of file pcbnew/pcbnew.cpp.

389 {
390  wxFileName destFile( aSrcFilePath );
391  wxString destPath = destFile.GetPathWithSep();

◆ IfaceOrAddress()

void* kiface::IfaceOrAddress ( int  aDataId)
override

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.

Definition at line 462 of file pcbnew/pcbnew.cpp.

467  {
468  wxFAIL_MSG( "Unexpected filetype for Pcbnew::SaveFileAs()" );
469  }
470 }
471 

◆ IsWxPythonLoaded()

bool IsWxPythonLoaded ( )

Definition at line 69 of file python_scripting.cpp.

70 {
71  return wxPythonLoaded;
72 }
static bool wxPythonLoaded
True if the wxPython scripting layer was successfully loaded.

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

◆ Kiface()

KIFACE_I& Kiface ( )

Global KIFACE_I "get" accessor.

Definition at line 183 of file pcbnew/pcbnew.cpp.

183 { return kiface; }
return & kiface

References PCB::kiface().

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

◆ MY_API()

MY_API ( KIFACE )

◆ OnKifaceEnd()

void kiface::OnKifaceEnd ( )
override

Definition at line 47 of file mocks_eeschema.cpp.

51  {

◆ OnKifaceStart()

bool kiface::OnKifaceStart ( PGM_BASE aProgram,
int  aCtlBits 
)
override

Definition at line 40 of file common_mocks.cpp.

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

References program.

◆ PythonPluginsReloadBase()

void PythonPluginsReloadBase ( )

Helper function PythonPluginsReloadBase Reload Python plugins if they are newer than the already loaded, and load new plugins if any It calls the LoadPlugins(bundlepath) Python method see kicadplugins.i.

Definition at line 290 of file pcbnew/pcbnew.cpp.

291 {
292 #if defined( KICAD_SCRIPTING )
293  // Reload plugin list: reload Python plugins if they are newer than the already loaded,
294  // and load new plugins
295  char cmd[1024];
296 
297  snprintf( cmd, sizeof( cmd ), "pcbnew.LoadPlugins(\"%s\")", TO_UTF8( PyScriptingPath() ) );
298 
299  PyLOCK lock;
300 
301  // ReRun the Python method pcbnew.LoadPlugins (already called when starting Pcbnew)
302  int retv = PyRun_SimpleString( cmd );
303 
304  if( retv != 0 )
305  wxLogError( "Python error %d occurred running command:\n\n`%s`", retv, cmd );
306 #endif
307 }
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
wxString PyScriptingPath()
Find the Python scripting path.

References PyScriptingPath(), and TO_UTF8.

Referenced by PCB_EDIT_FRAME::PythonPluginsReload().

◆ SaveFileAs()

void kiface::SaveFileAs ( const wxString &  aProjectBasePath,
const wxString &  aSrcProjectName,
const wxString &  aNewProjectBasePath,
const wxString &  aNewProjectName,
const wxString &  aSrcFilePath,
wxString &  aErrors 
)
override

Function SaveFileAs 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 188 of file pcbnew/pcbnew.cpp.

◆ aProgram

int PGM_BASE* aProgram
Initial value:
{
static PGM_BASE * process
int PGM_BASE * aProgram

Definition at line 189 of file pcbnew/pcbnew.cpp.

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

◆ GFootprintList

FOOTPRINT_LIST_IMPL 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 318 of file pcbnew/pcbnew.cpp.

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

◆ GFootprintTable

FP_LIB_TABLE GFootprintTable

The global footprint library table.

!!!!!!!!!!!!!! This code is obsolete because of the merge into pcbnew, don't bother with it.

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

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

◆ kiface

return& kiface

Definition at line 191 of file pcbnew/pcbnew.cpp.

◆ process

PGM_BASE* process
static

Definition at line 180 of file pcbnew/pcbnew.cpp.