KiCad PCB EDA Suite
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 <symbol_viewer_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 <wx/ffile.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 ()
 similar 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 111 of file eeschema.cpp.

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

◆ IFACE()

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

Definition at line 103 of file eeschema.cpp.

113  : public KIFACE_I
A KIFACE (I)mplementation.
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 167 of file eeschema.cpp.

168  :
169  return NULL;
170  }
171  }
172 
#define NULL

◆ Kiface()

KIFACE_I& Kiface ( )

Global KIFACE_I "get" accessor.

Definition at line 210 of file eeschema.cpp.

210 { return kiface; }
return & kiface
Definition: eeschema.cpp:218

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 222 of file eeschema.cpp.

223 {
224  wxASSERT( process ); // KIFACE_GETTER has already been called.
225  return *process;
226 }
static PGM_BASE * process
Definition: eeschema.cpp:207

References process.

Referenced by SCH::readSchematicFromFile().

◆ PgmOrNull()

PGM_BASE* PgmOrNull ( )

similar 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 230 of file eeschema.cpp.

231 {
232  return process;
233 }
static PGM_BASE * process
Definition: eeschema.cpp:207

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 286 of file eeschema.cpp.

288 {
289  aVisitor( aNode );
290 
291  if( aNode->IsList() )
292  {
293  for( unsigned i = 0; i < aNode->GetNumberOfChildren(); i++ )
294  traverseSEXPR( aNode->GetChild( i ), aVisitor );
295  }
296 }
static void traverseSEXPR(SEXPR::SEXPR *aNode, const std::function< void(SEXPR::SEXPR *)> &aVisitor)
Definition: eeschema.cpp:286
bool IsList() const
Definition: sexpr.h:54
SEXPR * GetChild(size_t aIndex) const
Definition: sexpr.cpp:48
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 215 of file eeschema.cpp.

◆ aProgram

int PGM_BASE* aProgram
Initial value:
{
int PGM_BASE * aProgram
Definition: eeschema.cpp:216
static PGM_BASE * process
Definition: eeschema.cpp:207

Definition at line 216 of file eeschema.cpp.

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

◆ DefaultTransform

◆ g_RootSheet

SCH_SHEET* g_RootSheet = NULL

Definition at line 52 of file eeschema.cpp.

◆ kiface

return& kiface

Definition at line 218 of file eeschema.cpp.

◆ process

PGM_BASE* process
static

Definition at line 207 of file eeschema.cpp.

Referenced by Pgm(), and PgmOrNull().