KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eeschema.cpp File Reference
#include <algorithm>
#include <api/api_handler_sch.h>
#include <api/api_handler_sch_libraries.h>
#include <api/api_handler_symbol.h>
#include <api/api_server.h>
#include <api/api_utils.h>
#include <api/cross_probe_client.h>
#include <api/headless_sch_context.h>
#include <api/headless_symbol_editor_context.h>
#include <core/json_serializers.h>
#include <pgm_base.h>
#include <kiface_base.h>
#include <background_jobs_monitor.h>
#include <cli_progress_reporter.h>
#include <confirm.h>
#include <gestfich.h>
#include "eeschema_jobs_handler.h"
#include "eeschema_helpers.h"
#include <diff_merge/diff_doc_kind.h>
#include <reporter.h>
#include "git/kigit_sch_merge.h"
#include "git/kigit_sym_lib_merge.h"
#include <git/kigit_driver_registry.h>
#include <eeschema_settings.h>
#include <footprint_filter.h>
#include <sch_edit_frame.h>
#include <libraries/symbol_library_adapter.h>
#include <symbol_edit_frame.h>
#include <symbol_viewer_frame.h>
#include <symbol_chooser_frame.h>
#include <dialogs/panel_grid_settings.h>
#include <dialogs/panel_snapping.h>
#include <dialogs/panel_simulator_preferences.h>
#include <dialogs/panel_design_block_lib_table.h>
#include <dialogs/panel_sym_lib_table.h>
#include <kiway.h>
#include <project_sch.h>
#include <richio.h>
#include <settings/settings_manager.h>
#include <symbol_editor_settings.h>
#include <sexpr/sexpr.h>
#include <sexpr/sexpr_parser.h>
#include <string_utils.h>
#include <trace_helpers.h>
#include <thread_pool.h>
#include <kiface_ids.h>
#include <symbol_library_query.h>
#include <widgets/kistatusbar.h>
#include <netlist_exporters/netlist_exporter_kicad.h>
#include <wx/ffile.h>
#include <wx/tokenzr.h>
#include <wildcards_and_files_ext.h>
#include <schematic.h>
#include <connection_graph.h>
#include <panel_template_fieldnames.h>
#include <panel_eeschema_color_settings.h>
#include <panel_sch_data_sources.h>
#include <panel_sym_color_settings.h>
#include <panel_eeschema_editing_options.h>
#include <panel_eeschema_annotation_options.h>
#include <panel_sym_editing_options.h>
#include <dialogs/panel_base_display_options.h>
#include <panel_eeschema_display_options.h>
#include <panel_sym_display_options.h>
#include <sim/simulator_frame.h>
#include <dialogs/panel_toolbar_customization.h>
#include <toolbars_sch_editor.h>
#include <toolbars_symbol_editor.h>
#include <sch_io/sch_io.h>
#include <sch_io/sch_io_mgr.h>
#include <wx/crt.h>

Go to the source code of this file.

Classes

struct  SCH::IFACE
 

Namespaces

namespace  SCH
 

Functions

static int SCH::eeschemaMergeExport (int aKind, const wxString &aAncestor, const wxString &aOurs, const wxString &aTheirs, const wxString &aOutput, bool aInteractive, bool aSingleFile, REPORTER *aReporter)
 
static int SCH::eeschemaOpenDiffDialogExport (int aKind, const wxString &aFileA, const wxString &aFileB, const wxString &aLabelA, const wxString &aLabelB, wxWindow *aParent, REPORTER *aReporter)
 
static KICAD_DIFF::DIFF_CANVAS_CONTEXT * SCH::eeschemaAttachDiffCanvasesExport (int aKind, const wxString &aFileA, const wxString &aFileB, WIDGET_DIFF_CANVAS *aBefore, WIDGET_DIFF_CANVAS *aAfter, KICAD_DIFF::DOCUMENT_DIFF *aDiff, REPORTER *aReporter)
 
static std::unique_ptr< SCHEMATIC > SCH::readSchematicFromFile (const std::string &aFilename)
 
bool SCH::generateSchematicNetlist (const wxString &aFilename, std::string &aNetlist, KIWAY *aKiway)
 
static PROJECT * SCH::symbolLibraryProject ()
 Return the project whose symbol libraries the kiface-level symbol services work with.
 
static bool SCH::footprintReferenceMatches (const LIB_ID &aReference, const LIB_ID &aFootprint)
 Whether a footprint reference names aFootprint.
 
static bool SCH::symbolFilterMatchesFootprint (const LIB_SYMBOL &aSymbol, const LIB_ID &aFootprint, FOOTPRINT_USER_MATCH &aMatch)
 Whether any footprint filter of a symbol selects a given footprint.
 
static wxString SCH::effectiveFootprintText (const LIB_SYMBOL &aSymbol)
 Return the footprint field text in effect for a symbol.
 
static bool SCH::symbolPinMapsBindFootprint (const LIB_SYMBOL &aSymbol, const LIB_ID &aFootprint, FOOTPRINT_USER_MATCH &aMatch)
 Whether one of the pin maps of aSymbol is bound to aFootprint; collects the names of the bound maps in aMatch.
 
static bool SCH::symbolFootprintFieldNamesFootprint (const LIB_SYMBOL &aSymbol, const LIB_ID &aFootprint, FOOTPRINT_USER_MATCH &aMatch)
 Whether the footprint field of aSymbol names aFootprint; sets the footprint field flag in aMatch.
 
static std::optional< FOOTPRINT_USER_MATCH > SCH::symbolUsesFootprint (const LIB_SYMBOL &aSymbol, const LIB_ID &aFootprint)
 Return how aSymbol uses aFootprint, or nothing when it doesn't.
 
static wxString SCH::filterFootprintUsers (const wxString &aQueryJson)
 Find the symbols that select a given footprint somehow (but FP field, filters or pin maps)
 
static bool SCH::startSymbolLibraryLoad ()
 Start loading the symbol libraries in the background.
 
static float SCH::symbolLibraryLoadProgress ()
 Return how far a background load has got.
 
SCH::IFACE KIFACE_BASE, UNITS_PROVIDER SCH::kiface ("eeschema", KIWAY::FACE_SCH)
 
 IFACE (const char *aName, KIWAY::FACE_T aType)
 
bool OnKifaceStart (PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
 
void Reset () override
 
void OnKifaceEnd () override
 
wxWindow * CreateKiWindow (wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
 
void * IfaceOrAddress (int aDataId) override
 Return a pointer to the requested object.
 
EESCHEMA_JOBS_HANDLER * JobHandler () const
 Accessor for the non-job diff/merge exports (eeschemaMergeExport etc.).
 
void SaveFileAs (const wxString &aProjectBasePath, const wxString &aProjectName, const wxString &aNewProjectBasePath, const wxString &aNewProjectName, const wxString &aSrcFilePath, wxString &aErrors) override
 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).
 
int HandleJob (JOB *aJob, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter) override
 
bool HandleJobConfig (JOB *aJob, wxWindow *aParent) override
 
bool HandleApiOpenDocument (const DOCUMENT_SPEC &aSpec, KICAD_API_SERVER *aServer, wxString *aError) override
 
bool handleCreateSchematic (const wxString &aPath, KICAD_API_SERVER *aServer, wxString *aError)
 
bool handleOpenSymbol (const wxString &aProjectPath, const wxString &aLibIdStr, KICAD_API_SERVER *aServer, wxString *aError)
 
bool HandleApiCloseDocument (const DOCUMENT_SPEC &aSpec, KICAD_API_SERVER *aServer, wxString *aError) override
 
void PreloadLibraries (KIWAY *aKiway) override
 
void CancelPreload (bool aBlock=true) override
 
void ProjectChanged () override
 
void RegisterLibraryHandlers (KICAD_API_SERVER *aServer) override
 
bool LoadAllLibraries () override
 
void closeSchematic (KICAD_API_SERVER *aServer)
 
void closeSymbol (KICAD_API_SERVER *aServer)
 
KIFACE_BASE & Kiface ()
 Global KIFACE_BASE "get" accessor.
 
KIFACE_API KIFACE * KIFACE_GETTER (int *aKIFACEversion, int aKiwayVersion, PGM_BASE *aProgram)
 No name mangling. Each KIFACE (DSO/DLL) will implement this once.
 

Variables

SCH_SHEET * g_RootSheet = nullptr
 
std::unique_ptr< EESCHEMA_JOBS_HANDLER > m_jobHandler
 
std::shared_ptr< BACKGROUND_JOB > m_libraryPreloadBackgroundJob
 
std::future< void > m_libraryPreloadReturn
 
std::atomic_bool m_libraryPreloadInProgress
 
std::atomic_bool m_libraryPreloadAbort
 
KIWAY * m_kiway = nullptr
 
SCHEMATIC * m_openSchematic = nullptr
 
std::shared_ptr< HEADLESS_SCH_CONTEXT > m_openContext
 
std::shared_ptr< HEADLESS_SYMBOL_EDITOR_CONTEXT > m_openSymbolContext
 
std::unique_ptr< API_HANDLER_SYMBOL > m_openSymbolHandler
 
std::unique_ptr< API_HANDLER_SCH > m_openHandler
 
std::unique_ptr< API_HANDLER_SCH_LIBRARIES > m_apiHandlerSchLibs
 

Function Documentation

◆ CancelPreload()

void kiface::CancelPreload ( bool aBlock = true)
override

◆ closeSchematic()

void kiface::closeSchematic ( KICAD_API_SERVER * aServer)
private

◆ closeSymbol()

void kiface::closeSymbol ( KICAD_API_SERVER * aServer)
private

◆ CreateKiWindow()

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

Definition at line 14 of file eeschema.cpp.

◆ HandleApiCloseDocument()

bool kiface::HandleApiCloseDocument ( const DOCUMENT_SPEC & aSpec,
KICAD_API_SERVER * aServer,
wxString * aError )
override

◆ HandleApiOpenDocument()

bool kiface::HandleApiOpenDocument ( const DOCUMENT_SPEC & aSpec,
KICAD_API_SERVER * aServer,
wxString * aError )
override

References filter.

◆ handleCreateSchematic()

bool kiface::handleCreateSchematic ( const wxString & aPath,
KICAD_API_SERVER * aServer,
wxString * aError )

◆ HandleJob()

int kiface::HandleJob ( JOB * aJob,
REPORTER * aReporter,
PROGRESS_REPORTER * aProgressReporter )
override

◆ HandleJobConfig()

bool kiface::HandleJobConfig ( JOB * aJob,
wxWindow * aParent )
override

◆ handleOpenSymbol()

bool kiface::handleOpenSymbol ( const wxString & aProjectPath,
const wxString & aLibIdStr,
KICAD_API_SERVER * aServer,
wxString * aError )

◆ IFACE()

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

Definition at line 2 of file eeschema.cpp.

◆ IfaceOrAddress()

void * kiface::IfaceOrAddress ( int aDataId)
override

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
the object requested and must be cast into the know type.

Definition at line 233 of file eeschema.cpp.

◆ JobHandler()

EESCHEMA_JOBS_HANDLER * kiface::JobHandler ( ) const

Accessor for the non-job diff/merge exports (eeschemaMergeExport etc.).

Definition at line 262 of file eeschema.cpp.

◆ Kiface()

KIFACE_BASE & Kiface ( )

Global KIFACE_BASE "get" accessor.

Definition at line 864 of file eeschema.cpp.

References SCH::kiface().

◆ KIFACE_GETTER()

KIFACE_API KIFACE * KIFACE_GETTER ( int * aKIFACEversion,
int aKiwayVersion,
PGM_BASE * aProgram )

No name mangling. Each KIFACE (DSO/DLL) will implement this once.

Definition at line 869 of file eeschema.cpp.

References SCH::kiface(), and KIFACE_API.

◆ LoadAllLibraries()

bool kiface::LoadAllLibraries ( )
override

◆ OnKifaceEnd()

void kiface::OnKifaceEnd ( )
override

Definition at line 11 of file test_app_main.cpp.

◆ OnKifaceStart()

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

Definition at line 6 of file test_app_main.cpp.

◆ PreloadLibraries()

void kiface::PreloadLibraries ( KIWAY * aKiway)
override

◆ ProjectChanged()

void kiface::ProjectChanged ( )
override

◆ RegisterLibraryHandlers()

void kiface::RegisterLibraryHandlers ( KICAD_API_SERVER * aServer)
override

◆ Reset()

◆ SaveFileAs()

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

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).

References filter.

Variable Documentation

◆ g_RootSheet

SCH_SHEET* g_RootSheet = nullptr

Definition at line 100 of file eeschema.cpp.

◆ m_apiHandlerSchLibs

std::unique_ptr<API_HANDLER_SCH_LIBRARIES> m_apiHandlerSchLibs
private

Definition at line 312 of file eeschema.cpp.

◆ m_jobHandler

std::unique_ptr<EESCHEMA_JOBS_HANDLER> m_jobHandler
private

Definition at line 297 of file eeschema.cpp.

◆ m_kiway

KIWAY* m_kiway = nullptr
private

Definition at line 306 of file eeschema.cpp.

◆ m_libraryPreloadAbort

std::atomic_bool m_libraryPreloadAbort
private

Definition at line 301 of file eeschema.cpp.

◆ m_libraryPreloadBackgroundJob

std::shared_ptr<BACKGROUND_JOB> m_libraryPreloadBackgroundJob
private

Definition at line 298 of file eeschema.cpp.

◆ m_libraryPreloadInProgress

std::atomic_bool m_libraryPreloadInProgress
private

Definition at line 300 of file eeschema.cpp.

◆ m_libraryPreloadReturn

std::future<void> m_libraryPreloadReturn
private

Definition at line 299 of file eeschema.cpp.

◆ m_openContext

std::shared_ptr<HEADLESS_SCH_CONTEXT> m_openContext
private

Definition at line 308 of file eeschema.cpp.

◆ m_openHandler

std::unique_ptr<API_HANDLER_SCH> m_openHandler
private

Definition at line 311 of file eeschema.cpp.

◆ m_openSchematic

SCHEMATIC* m_openSchematic = nullptr
private

Definition at line 307 of file eeschema.cpp.

◆ m_openSymbolContext

std::shared_ptr<HEADLESS_SYMBOL_EDITOR_CONTEXT> m_openSymbolContext
private

Definition at line 309 of file eeschema.cpp.

◆ m_openSymbolHandler

std::unique_ptr<API_HANDLER_SYMBOL> m_openSymbolHandler
private

Definition at line 310 of file eeschema.cpp.