KiCad PCB EDA Suite
pcb_calculator.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KICAD, a free EDA CAD application.
3 *
4 * Copyright (C) 2015 jean-pierre.charras
5 * Copyright (C) 2015-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <pgm_base.h>
22#include <kiface_base.h>
24
27
28// Pcb_calculator data file extension:
29const wxString PcbCalcDataFileExt( wxT( "pcbcalc" ) );
30
31
32namespace PCBCALC {
33
34static struct IFACE : public KIFACE_BASE
35{
36 // Of course all are virtual overloads, implementations of the KIFACE.
37
38 IFACE( const char* aName, KIWAY::FACE_T aType ) :
39 KIFACE_BASE( aName, aType )
40 {}
41
42 bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
43
44 void OnKifaceEnd() override;
45
46 wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway,
47 int aCtlBits = 0 ) override
48 {
49 return new PCB_CALCULATOR_FRAME( aKiway, aParent );
50 }
51
62 void* IfaceOrAddress( int aDataId ) override
63 {
64 return nullptr;
65 }
66
67} kiface( "pcb_calculator", KIWAY::FACE_PCB_CALCULATOR );
68
69
70} // namespace
71
72
73using namespace PCBCALC;
74
76
77
79
80
81// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
82// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
83MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
84{
86 return &kiface;
87}
88
89
91{
92 wxASSERT( process ); // KIFACE_GETTER has already been called.
93 return *process;
94}
95
96
97// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
99{
100 return process;
101}
102
104{
107 start_common( aCtlBits );
108
109 return true;
110}
111
112
114{
115 end_common();
116}
A KIFACE implementation.
Definition: kiface_base.h:39
void InitSettings(APP_SETTINGS_BASE *aSettings)
Definition: kiface_base.h:95
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:93
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_base.cpp:97
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:273
FACE_T
Known KIFACE implementations.
Definition: kiway.h:279
@ FACE_PCB_CALCULATOR
Definition: kiway.h:285
PCB calculator the main frame.
Container for data for KiCad programs.
Definition: pgm_base.h:94
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:134
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Takes ownership of the pointer passed in.
#define KIFACE_GETTER
Definition: kiway.h:111
PCBCALC::IFACE KIFACE_BASE kiface("pcb_calculator", KIWAY::FACE_PCB_CALCULATOR)
return & kiface
MY_API(KIFACE *) KIFACE_GETTER(int *aKIFACEversion
int aKiwayVersion
static PGM_BASE * process
int PGM_BASE * aProgram
PGM_BASE & Pgm()
The global Program "get" accessor.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
const wxString PcbCalcDataFileExt(wxT("pcbcalc"))
see class PGM_BASE
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Typically start_common() is called from here.
Implement a participant in the KIWAY alchemy.
Definition: kiway.h:151
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Typically start_common() is called from here.
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
IFACE(const char *aName, KIWAY::FACE_T aType)
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.