KiCad PCB EDA Suite
eeschema/eeschema.cpp File Reference
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <confirm.h>
#include <gestfich.h>
#include <eda_dde.h>
#include <eeschema_settings.h>
#include <sch_edit_frame.h>
#include <lib_edit_frame.h>
#include <lib_view_frame.h>
#include <general.h>
#include <class_libentry.h>
#include <transform.h>
#include <symbol_lib_table.h>
#include <dialogs/dialog_global_sym_lib_table_config.h>
#include <dialogs/panel_sym_lib_table.h>
#include <kiway.h>
#include <sim/sim_plot_frame.h>
#include <settings/settings_manager.h>
#include <sexpr/sexpr.h>
#include <sexpr/sexpr_parser.h>

Go to the source code of this file.

Classes

struct  SCH::IFACE
 

Namespaces

 SCH
 

Functions

SCH::IFACE KIFACE_I SCH::kiface ("eeschema", KIWAY::FACE_SCH)
 
 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 &aProjectName, 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
 
PGM_BASEPgm ()
 The global Program "get" accessor. More...
 
PGM_BASEPgmOrNull ()
 similat to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from a script, not from a kicad appl More...
 
static void traverseSEXPR (SEXPR::SEXPR *aNode, const std::function< void(SEXPR::SEXPR *)> &aVisitor)
 

Variables

SCH_SHEETg_RootSheet = NULL
 
TRANSFORM DefaultTransform = TRANSFORM( 1, 0, 0, -1 )
 
static PGM_BASEprocess
 
int aKiwayVersion
 
int PGM_BASEaProgram
 
return & kiface
 

Function Documentation

◆ CreateWindow()

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

Definition at line 248 of file eeschema/eeschema.cpp.

252  {
253  if( destFile.GetName() == aProjectName )
254  destFile.SetName( aNewProjectName );
255 
256  // Sheet paths when auto-generated are relative to the root, so those will stay
257  // pointing to whatever they were pointing at.
258  // The author can create their own absolute and relative sheet paths. Absolute
259  // sheet paths aren't an issue, and relative ones will continue to work as long
260  // as the author didn't include any '..'s. If they did, it's still not clear
261  // whether they should be adjusted or not (as the author may be duplicating an
262  // entire tree with several projects within it), so we leave this as an exercise
263  // to the author.
264 
265  CopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
266  }
267  else if( ext == "sym" )
268  {
269  // Symbols are not project-specific. Keep their source names.
270  CopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
271  }
272  else if( ext == "lib" || ext == "dcm" || ext == "kicad_sym" )
273  {
274  if( destFile.GetName() == aProjectName + "-cache" )
275  destFile.SetName( aNewProjectName + "-cache" );
276 
277  CopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
278  }
279  else if( ext == "net" )
280  {
281  bool success = false;
282 
283  if( destFile.GetName() == aProjectName )
284  destFile.SetName( aNewProjectName );
285 
286  try
287  {
288  SEXPR::PARSER parser;
289  std::unique_ptr<SEXPR::SEXPR> sexpr( parser.ParseFromFile( TO_UTF8( aSrcFilePath ) ) );
290 
291  traverseSEXPR( sexpr.get(), [&]( SEXPR::SEXPR* node )
292  {
293  if( node->IsList() && node->GetNumberOfChildren() > 1
void CopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
Function CopyFile.
Definition: gestfich.cpp:353
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:100
static void traverseSEXPR(SEXPR::SEXPR *aNode, const std::function< void(SEXPR::SEXPR *)> &aVisitor)
std::unique_ptr< SEXPR > ParseFromFile(const std::string &aFilename)

References CopyFile().

◆ IFACE()

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

Definition at line 240 of file eeschema/eeschema.cpp.

240 {
241  wxFileName destFile( aSrcFilePath );
242  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 303 of file eeschema/eeschema.cpp.

◆ Kiface()

KIFACE_I& Kiface ( )

Global KIFACE_I "get" accessor.

Definition at line 148 of file eeschema/eeschema.cpp.

148 { return kiface; }
return & kiface

References SCH::kiface().

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

◆ MY_API()

MY_API ( KIFACE )

◆ OnKifaceEnd()

void kiface::OnKifaceEnd ( )
override

Definition at line 45 of file mocks_eeschema.cpp.

49  {

◆ 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

◆ Pgm()

PGM_BASE& Pgm ( )

The global Program "get" accessor.

Implemented in: 1) common/single_top.cpp, 2) kicad/kicad.cpp, and 3) scripting/kiway.i

Definition at line 160 of file eeschema/eeschema.cpp.

161 {
162  wxASSERT( process ); // KIFACE_GETTER has already been called.
163  return *process;
164 }
static PGM_BASE * process

References process.

◆ PgmOrNull()

PGM_BASE* PgmOrNull ( )

similat to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from a script, not from a kicad appl

Definition at line 168 of file eeschema/eeschema.cpp.

169 {
170  return process;
171 }
static PGM_BASE * process

References process.

◆ SaveFileAs()

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

◆ traverseSEXPR()

static void traverseSEXPR ( SEXPR::SEXPR aNode,
const std::function< void(SEXPR::SEXPR *)> &  aVisitor 
)
static

Definition at line 224 of file eeschema/eeschema.cpp.

226 {
227  aVisitor( aNode );
228 
229  if( aNode->IsList() )
230  {
231  for( unsigned i = 0; i < aNode->GetNumberOfChildren(); i++ )
232  traverseSEXPR( aNode->GetChild( i ), aVisitor );
233  }
234 }
bool IsList() const
Definition: sexpr.h:54
SEXPR * GetChild(size_t aIndex) const
Definition: sexpr.cpp:48
static void traverseSEXPR(SEXPR::SEXPR *aNode, const std::function< void(SEXPR::SEXPR *)> &aVisitor)
size_t GetNumberOfChildren() const
Definition: sexpr.cpp:70

References SEXPR::SEXPR::GetChild(), SEXPR::SEXPR::GetNumberOfChildren(), and SEXPR::SEXPR::IsList().

Variable Documentation

◆ aKiwayVersion

int aKiwayVersion

Definition at line 153 of file eeschema/eeschema.cpp.

◆ aProgram

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

Definition at line 154 of file eeschema/eeschema.cpp.

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

◆ DefaultTransform

◆ g_RootSheet

SCH_SHEET* g_RootSheet = NULL

Definition at line 49 of file eeschema/eeschema.cpp.

◆ kiface

return& kiface

Definition at line 156 of file eeschema/eeschema.cpp.

◆ process

PGM_BASE* process
static

Definition at line 145 of file eeschema/eeschema.cpp.

Referenced by Pgm(), and PgmOrNull().