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

114  : public KIFACE_I
115 {
116  // Of course all are virtual overloads, implementations of the KIFACE.
117 
118  IFACE( const char* aName, KIWAY::FACE_T aType ) :
119  KIFACE_I( aName, aType )
120  {}
121 
122  bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
123 
124  void OnKifaceEnd() override;
125 
126  wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
127  {
128  switch( aClassId )
129  {
130  case FRAME_SCH:
131  {
132  SCH_EDIT_FRAME* frame = new SCH_EDIT_FRAME( aKiway, aParent );
133 
134  if( Kiface().IsSingle() )
135  {
136  // only run this under single_top, not under a project manager.
138  }
139 
140  return frame;
141  }
142 
144  {
145  SYMBOL_EDIT_FRAME* frame = new SYMBOL_EDIT_FRAME( aKiway, aParent );
146  return frame;
147  }
148 
149 #ifdef KICAD_SPICE
150  case FRAME_SIMULATOR:
151  {
152  SIM_PLOT_FRAME* frame = new SIM_PLOT_FRAME( aKiway, aParent );
153  return frame;
154  }
155 #endif
156  case FRAME_SCH_VIEWER:
158  {
A KIFACE (I)mplementation.
Definition: kiface_i.h:37
Container for data for KiCad programs.
Definition: pgm_base.h:93
Schematic editor (Eeschema) main window.
void CreateServer(int service, bool local=true)
Definition: eda_dde.cpp:49
int PGM_BASE * aProgram
Definition: eeschema.cpp:217
void OnKifaceEnd() override
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition: eeschema.cpp:104
#define KICAD_SCH_PORT_SERVICE_NUMBER
Scripting window listens for commands for other apps.
Definition: eda_dde.h:43
wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Definition: eeschema.cpp:112
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:258
Implementing SIM_PLOT_FRAME_BASE.
FACE_T
Known KIFACE implementations.
Definition: kiway.h:264
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: eeschema.cpp:211
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 104 of file eeschema.cpp.

114  : 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 168 of file eeschema.cpp.

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

◆ Kiface()

KIFACE_I& Kiface ( )

Global KIFACE_I "get" accessor.

Definition at line 211 of file eeschema.cpp.

211 { return kiface; }
return & kiface
Definition: eeschema.cpp:219

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

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

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

232 {
233  return process;
234 }
static PGM_BASE * process
Definition: eeschema.cpp:208

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

289 {
290  aVisitor( aNode );
291 
292  if( aNode->IsList() )
293  {
294  for( unsigned i = 0; i < aNode->GetNumberOfChildren(); i++ )
295  traverseSEXPR( aNode->GetChild( i ), aVisitor );
296  }
297 }
static void traverseSEXPR(SEXPR::SEXPR *aNode, const std::function< void(SEXPR::SEXPR *)> &aVisitor)
Definition: eeschema.cpp:287
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 216 of file eeschema.cpp.

◆ aProgram

int PGM_BASE* aProgram
Initial value:
{
int PGM_BASE * aProgram
Definition: eeschema.cpp:217
static PGM_BASE * process
Definition: eeschema.cpp:208

Definition at line 217 of file eeschema.cpp.

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

◆ DefaultTransform

◆ g_RootSheet

SCH_SHEET* g_RootSheet = NULL

Definition at line 53 of file eeschema.cpp.

◆ kiface

return& kiface

Definition at line 219 of file eeschema.cpp.

◆ process

PGM_BASE* process
static

Definition at line 208 of file eeschema.cpp.

Referenced by Pgm(), and PgmOrNull().