KiCad PCB EDA Suite
eeschema/eeschema.cpp File Reference
#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 <symbol_edit_frame.h>
#include <lib_view_frame.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>
#include <kiface_ids.h>
#include <netlist_exporters/netlist_exporter_kicad.h>
#include <schematic.h>
#include <connection_graph.h>

Go to the source code of this file.

Classes

struct  SCH::IFACE
 

Namespaces

 SCH
 

Functions

static std::unique_ptr< SCHEMATICSCH::readSchematicFromFile (const std::string &aFilename)
 
bool SCH::generateSchematicNetlist (const wxString &aFilename, wxString &aNetlist)
 
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 110 of file eeschema/eeschema.cpp.

112  : public KIFACE_I
113 {
114  // Of course all are virtual overloads, implementations of the KIFACE.
115 
116  IFACE( const char* aName, KIWAY::FACE_T aType ) :
117  KIFACE_I( aName, aType )
118  {}
119 
120  bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
121 
122  void OnKifaceEnd() override;
123 
124  wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
125  {
126  switch( aClassId )
127  {
128  case FRAME_SCH:
129  {
130  SCH_EDIT_FRAME* frame = new SCH_EDIT_FRAME( aKiway, aParent );
131 
132  if( Kiface().IsSingle() )
133  {
134  // only run this under single_top, not under a project manager.
136  }
137 
138  return frame;
139  }
140 
142  {
143  SYMBOL_EDIT_FRAME* frame = new SYMBOL_EDIT_FRAME( aKiway, aParent );
144  return frame;
145  }
146 
147 #ifdef KICAD_SPICE
148  case FRAME_SIMULATOR:
149  {
150  SIM_PLOT_FRAME* frame = new SIM_PLOT_FRAME( aKiway, aParent );
151  return frame;
152  }
153 #endif
154  case FRAME_SCH_VIEWER:
KIFACE_I is a KIFACE (I)mplementation, with some features useful for DSOs which implement a KIFACE.
Definition: kiface_i.h:37
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
PGM_BASE keeps program (whole process) data for KiCad programs.
Definition: pgm_base.h:137
wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Schematic editor (Eeschema) main window.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
IFACE(const char *aName, KIWAY::FACE_T aType)
int PGM_BASE * aProgram
#define KICAD_SCH_PORT_SERVICE_NUMBER
Definition: eda_dde.h:42
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
Implementing SIM_PLOT_FRAME_BASE.
FACE_T
Known KIFACE implementations.
Definition: kiway.h:279
void CreateServer(int service, bool local=true)
Definition: eda_dde.cpp:48
void OnKifaceEnd() override
The symbol library editor main window.

◆ IFACE()

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

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

112  : public KIFACE_I
KIFACE_I is a KIFACE (I)mplementation, with some features useful for DSOs which implement a KIFACE.
Definition: kiface_i.h:37

◆ 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 165 of file eeschema/eeschema.cpp.

166  :
167  return NULL;
168  }
169  }
170 
#define NULL

◆ Kiface()

KIFACE_I& Kiface ( )

Global KIFACE_I "get" accessor.

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

208 { 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 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

◆ 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 220 of file eeschema/eeschema.cpp.

221 {
222  wxASSERT( process ); // KIFACE_GETTER has already been called.
223  return *process;
224 }
static PGM_BASE * process

References process.

Referenced by SCH::readSchematicFromFile().

◆ 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 228 of file eeschema/eeschema.cpp.

229 {
230  return process;
231 }
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 284 of file eeschema/eeschema.cpp.

286 {
287  aVisitor( aNode );
288 
289  if( aNode->IsList() )
290  {
291  for( unsigned i = 0; i < aNode->GetNumberOfChildren(); i++ )
292  traverseSEXPR( aNode->GetChild( i ), aVisitor );
293  }
294 }
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().

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

Variable Documentation

◆ aKiwayVersion

int aKiwayVersion

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

◆ aProgram

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

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

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

◆ DefaultTransform

◆ g_RootSheet

SCH_SHEET* g_RootSheet = NULL

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

◆ kiface

return& kiface

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

◆ process

PGM_BASE* process
static

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

Referenced by Pgm(), and PgmOrNull().