KiCad PCB EDA Suite
pcbnew.cpp File Reference
#include <pcbnew_scripting_helpers.h>
#include <pgm_base.h>
#include <kiface_base.h>
#include <kiface_ids.h>
#include <confirm.h>
#include <pcb_edit_frame.h>
#include <eda_dde.h>
#include <macros.h>
#include <wx/snglinst.h>
#include <gestfich.h>
#include <paths.h>
#include <pcbnew_settings.h>
#include <footprint_editor_settings.h>
#include <settings/settings_manager.h>
#include <fp_lib_table.h>
#include <footprint_edit_frame.h>
#include <footprint_viewer_frame.h>
#include <footprint_wizard_frame.h>
#include <footprint_preview_panel.h>
#include <footprint_info_impl.h>
#include <dialogs/dialog_configure_paths.h>
#include <dialog_global_fp_lib_table_config.h>
#include <panel_display_options.h>
#include <panel_edit_options.h>
#include <panel_fp_editor_defaults.h>
#include <panel_fp_editor_color_settings.h>
#include <panel_pcbnew_color_settings.h>
#include <panel_pcbnew_action_plugins.h>
#include <panel_pcbnew_display_origin.h>
#include <panel_3D_display_options.h>
#include <panel_3D_opengl_options.h>
#include <panel_3D_raytracing_options.h>
#include <panel_3D_colors.h>
#include <python_scripting.h>
#include "invoke_pcb_dialog.h"
#include <wildcards_and_files_ext.h>
#include "pcbnew_jobs_handler.h"
#include <wx/crt.h>

Go to the source code of this file.

Classes

struct  PCB::IFACE
 

Namespaces

namespace  PCB
 

Functions

PyObject * PyInit__pcbnew (void)
 
PCB::IFACE KIFACE_BASE, UNITS_PROVIDER PCB::kiface ("pcbnew", KIWAY::FACE_PCB)
 
 IFACE (const char *aName, KIWAY::FACE_T aType)
 
bool OnKifaceStart (PGM_BASE *aProgram, int aCtlBits) 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. More...
 
void SaveFileAs (const wxString &aProjectBasePath, const wxString &aSrcProjectName, 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). More...
 
int HandleJob (JOB *aJob) override
 
KIFACE_BASEKiface ()
 Global KIFACE_BASE "get" accessor. More...
 
 MY_API (KIFACE *) KIFACE_GETTER(int *aKIFACEversion
 

Variables

std::unique_ptr< PCBNEW_JOBS_HANDLERm_jobHandler
 
static PGM_BASEprocess
 
int aKiwayVersion
 
int PGM_BASEaProgram
 
return & kiface
 
FP_LIB_TABLE GFootprintTable
 The global footprint library table. More...
 
FOOTPRINT_LIST_IMPL GFootprintList
 The global footprint info table. More...
 

Function Documentation

◆ CreateKiWindow()

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

Definition at line 11 of file pcbnew.cpp.

19 :
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
27#include <pgm_base.h>
28#include <kiface_base.h>
29#include <kiface_ids.h>
30#include <confirm.h>
31#include <pcb_edit_frame.h>
32#include <eda_dde.h>
33#include <macros.h>
34#include <wx/snglinst.h>
35#include <gestfich.h>
36#include <paths.h>
37#include <pcbnew_settings.h>
40#include <fp_lib_table.h>
45#include <footprint_info_impl.h>
49#include <panel_edit_options.h>
58#include <panel_3D_colors.h>
59#include <python_scripting.h>
60
61#include "invoke_pcb_dialog.h"
63#include "pcbnew_jobs_handler.h"
64
65#include <wx/crt.h>
66
67/* init functions defined by swig */
68
69extern "C" PyObject* PyInit__pcbnew( void );
70
71namespace PCB {
72
73static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
74{
75 // Of course all are virtual overloads, implementations of the KIFACE.
76
77 IFACE( const char* aName, KIWAY::FACE_T aType ) :
78 KIFACE_BASE( aName, aType ),
80 {}
81
82 bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
83
84 void OnKifaceEnd() override;
85
86 wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway,
87 int aCtlBits = 0 ) override
88 {
89 switch( aClassId )
90 {
92 {
93 auto frame = new PCB_EDIT_FRAME( aKiway, aParent );
94
95 // give the scripting helpers access to our frame
97
98 if( Kiface().IsSingle() )
99 {
100 // only run this under single_top, not under a project manager.
101 frame->CreateServer( KICAD_PCB_PORT_SERVICE_NUMBER );
102 }
103
104 return frame;
105 }
106
108 return new FOOTPRINT_EDIT_FRAME( aKiway, aParent );
109
112 return new FOOTPRINT_VIEWER_FRAME( aKiway, aParent, FRAME_T( aClassId ) );
113
115 return new FOOTPRINT_WIZARD_FRAME( aKiway, aParent, FRAME_T( aClassId ) );
116
118 return dynamic_cast< wxWindow* >( FOOTPRINT_PREVIEW_PANEL::New( aKiway, aParent ) );
119
121 {
122 DIALOG_CONFIGURE_PATHS dlg( aParent );
123
124 // The dialog's constructor probably failed to set its Kiway because the
125 // dynamic_cast fails when aParent was allocated by a separate compilation
126 // module. So set it directly.
127 dlg.SetKiway( &dlg, aKiway );
128
129 // Use QuasiModal so that HTML help window will work
130 if( dlg.ShowQuasiModal() == wxID_OK )
131 aKiway->CommonSettingsChanged( true, false );
132
133 // Dialog has completed; nothing to return.
134 return nullptr;
135 }
136
138 InvokePcbLibTableEditor( aKiway, aParent );
139 // Dialog has completed; nothing to return.
140 return nullptr;
141
143 {
144 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
146
147 return new PANEL_DISPLAY_OPTIONS( aParent, cfg );
148 }
149
151 {
152 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
153
154 if( !frame )
155 frame = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
156
157 if( !frame )
158 frame = aKiway->Player( FRAME_PCB_EDITOR, false );
159
160 if( frame )
161 return new PANEL_EDIT_OPTIONS( aParent, frame, frame, true );
162 else
163 return new PANEL_EDIT_OPTIONS( aParent, this, nullptr, true );
164 }
165
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:110
The base frame for deriving all KiCad main window classes.
static FOOTPRINT_PREVIEW_PANEL * New(KIWAY *aKiway, wxWindow *aParent)
Component library viewer main window.
A KIFACE implementation.
Definition: kiface_base.h:39
bool IsSingle() const
Is this KIFACE running under single_top?
Definition: kiface_base.h:105
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:274
virtual void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition: kiway.cpp:575
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
FACE_T
Known KIFACE implementations.
Definition: kiway.h:280
The main frame for Pcbnew.
Container for data for KiCad programs.
Definition: pgm_base.h:95
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
This file is part of the common library.
DDE server & client.
#define KICAD_PCB_PORT_SERVICE_NUMBER
< Pcbnew listens on this port for commands from Eeschema
Definition: eda_dde.h:40
EDA_UNITS
Definition: eda_units.h:43
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:33
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ FRAME_FOOTPRINT_VIEWER_MODAL
Definition: frame_type.h:43
@ FRAME_FOOTPRINT_VIEWER
Definition: frame_type.h:42
@ FRAME_FOOTPRINT_WIZARD
Definition: frame_type.h:44
@ PANEL_FP_DISPLAY_OPTIONS
Definition: frame_type.h:78
@ DIALOG_PCB_LIBRARY_TABLE
Definition: frame_type.h:105
@ FRAME_FOOTPRINT_PREVIEW
Definition: frame_type.h:46
@ DIALOG_CONFIGUREPATHS
Definition: frame_type.h:103
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
@ PANEL_FP_EDIT_OPTIONS
Definition: frame_type.h:79
@ PANEL_FP_DEFAULT_VALUES
Definition: frame_type.h:81
This file contains miscellaneous commonly used macros and functions.
void InvokePcbLibTableEditor(KIWAY *aKiway, wxWindow *aCaller)
Function InvokePcbLibTableEditor shows the modal DIALOG_FP_LIB_TABLE for purposes of editing the glob...
PyObject * PyInit__pcbnew(void)
int PGM_BASE * aProgram
Definition: pcbnew.cpp:308
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition: pcbnew.cpp:302
void ScriptingSetPcbEditFrame(PCB_EDIT_FRAME *aPcbEditFrame)
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Typically start_common() is called from here.
Definition: pcbnew.cpp:341
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
Definition: pcbnew.cpp:86
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition: pcbnew.cpp:77
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
Definition: pcbnew.cpp:391
Definition of file extensions used in Kicad.

◆ HandleJob()

int kiface::HandleJob ( JOB aJob)
override

◆ IFACE()

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

Definition at line 2 of file pcbnew.cpp.

19 :
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html

◆ 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 which must be cast into the know type.

Definition at line 178 of file pcbnew.cpp.

182 :
183 return new PANEL_FP_EDITOR_COLOR_SETTINGS( aParent );
184
186 {
187 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
189
190 return new PANEL_DISPLAY_OPTIONS( aParent, cfg );
191 }
192
194 {
195 EDA_BASE_FRAME* frame = aKiway->Player( FRAME_PCB_EDITOR, false );
196
197 if( !frame )
198 frame = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
199
200 if( !frame )
@ PANEL_PCB_EDIT_OPTIONS
Definition: frame_type.h:84
@ PANEL_PCB_DISPLAY_OPTIONS
Definition: frame_type.h:83

◆ Kiface()

KIFACE_BASE & Kiface ( )

Global KIFACE_BASE "get" accessor.

Definition at line 302 of file pcbnew.cpp.

302{ return kiface; }
return & kiface
Definition: pcbnew.cpp:310

References kiface.

Referenced by PCB::IFACE::CreateKiWindow().

◆ MY_API()

MY_API ( KIFACE )

◆ OnKifaceEnd()

void kiface::OnKifaceEnd ( )
override

Definition at line 11 of file test_app_main.cpp.

18:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html

◆ OnKifaceStart()

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

Definition at line 6 of file test_app_main.cpp.

18 :
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html

◆ PyInit__pcbnew()

PyObject * PyInit__pcbnew ( void  )

◆ SaveFileAs()

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

Variable Documentation

◆ aKiwayVersion

int aKiwayVersion

Definition at line 307 of file pcbnew.cpp.

◆ aProgram

int PGM_BASE* aProgram
Initial value:
{
static PGM_BASE * process
Definition: pcbnew.cpp:299

Definition at line 307 of file pcbnew.cpp.

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

◆ GFootprintList

FOOTPRINT_LIST_IMPL GFootprintList

The global footprint info table.

This is performance-intensive to build so we keep a hash-stamped global version. Any deviation from the request vs. stored hash will result in it being rebuilt.

Definition at line 338 of file pcbnew.cpp.

Referenced by FOOTPRINT_EDIT_FRAME::doCloseWindow(), PCB_BASE_EDIT_FRAME::doCloseWindow(), FP_TREE_MODEL_ADAPTER::getFootprints(), PCB::IFACE::IfaceOrAddress(), FOOTPRINT_EDIT_FRAME::initLibraryTree(), PCB_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::SelectFootprintFromLibTree(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().

◆ GFootprintTable

FP_LIB_TABLE GFootprintTable

The global footprint library table.

This is not dynamically allocated because in a multiple project environment we must keep its address constant (since it is the fallback table for multiple projects).

Definition at line 333 of file pcbnew.cpp.

Referenced by PCB::IFACE::IfaceOrAddress(), and PCB::IFACE::OnKifaceStart().

◆ kiface

return& kiface

Definition at line 310 of file pcbnew.cpp.

Referenced by Kiface().

◆ m_jobHandler

std::unique_ptr<PCBNEW_JOBS_HANDLER> m_jobHandler
private

Definition at line 214 of file pcbnew.cpp.

◆ process

PGM_BASE* process
static

Definition at line 299 of file pcbnew.cpp.