KiCad PCB EDA Suite
gerbview.cpp
Go to the documentation of this file.
1 
6 /*
7  * This program source code file is part of KiCad, a free EDA CAD application.
8  *
9  * Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, you may find one here:
23  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
24  * or you may search the http://www.gnu.org website for the version 2 license,
25  * or you may write to the Free Software Foundation, Inc.,
26  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
27  */
28 
29 #include <fctsys.h>
30 #include <kiface_i.h>
31 #include <pgm_base.h>
32 #include <class_drawpanel.h>
33 
34 #include <gerbview.h>
35 #include <hotkeys.h>
36 #include <gerbview_frame.h>
37 
38 const wxChar* g_GerberPageSizeList[] =
39 {
40  wxT( "GERBER" ), // index 0: full size page selection
41  wxT( "A4" ),
42  wxT( "A3" ),
43  wxT( "A2" ),
44  wxT( "A" ),
45  wxT( "B" ),
46  wxT( "C" ),
47 };
48 
49 
50 namespace GERBV {
51 
52 static struct IFACE : public KIFACE_I
53 {
54  // Of course all are virtual overloads, implementations of the KIFACE.
55 
56  IFACE( const char* aName, KIWAY::FACE_T aType ) :
57  KIFACE_I( aName, aType )
58  {}
59 
60  bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
61 
62  void OnKifaceEnd() override;
63 
64  wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
65  {
66  switch( aClassId )
67  {
68  case FRAME_GERBER:
69  {
70  GERBVIEW_FRAME* frame = new GERBVIEW_FRAME( aKiway, aParent );
71  return frame;
72  }
73  break;
74 
75  default:
76  ;
77  }
78 
79  return NULL;
80  }
81 
93  void* IfaceOrAddress( int aDataId ) override
94  {
95  return NULL;
96  }
97 
98 } kiface( "gerbview", KIWAY::FACE_GERBVIEW );
99 
100 } // namespace
101 
102 using namespace GERBV;
103 
105 
106 KIFACE_I& Kiface() { return kiface; }
107 
108 
109 // KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
110 // KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
111 MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
112 {
113  process = aProgram;
114  return &kiface;
115 }
116 
117 
119 {
120  wxASSERT( process ); // KIFACE_GETTER has already been called.
121  return *process;
122 }
123 
124 
125 bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
126 {
127  start_common( aCtlBits );
128 
129  // Must be called before creating the main frame in order to
130  // display the real hotkeys in menus or tool tips
132 
133  return true;
134 }
135 
136 
138 {
139  end_common();
140 }
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Function OnKifaceStart is called just once shortly after the DSO is loaded.
Definition: gerbview.cpp:125
wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Function CreateWindow creates a wxWindow for the current project.
Definition: gerbview.cpp:64
Class KIFACE_I is a KIFACE (I)mplementation, with some features useful for DSOs which implement a KIF...
Definition: kiface_i.h:37
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_i.cpp:90
void OnKifaceEnd() override
Function OnKifaceEnd is called just once just before the DSO is to be unloaded.
Definition: gerbview.cpp:137
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: gerbview.cpp:106
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: gerbview.cpp:118
Class PGM_BASE keeps program (whole process) data for KiCad programs.
Definition: pgm_base.h:149
int PGM_BASE * aProgram
Definition: gerbview.cpp:112
static PGM_BASE * process
Definition: gerbview.cpp:104
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition: gerbview.cpp:56
GERBV::IFACE KIFACE_I kiface("gerbview", KIWAY::FACE_GERBVIEW)
KIFACE * KIFACE_GETTER(int *aKIFACEversion, int aKIWAYversion, PGM_BASE *aProgram)
No name mangling. Each KIFACE (DSO/DLL) will implement this once.
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
Definition: kiface_i.cpp:100
int aKiwayVersion
Definition: gerbview.cpp:111
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
#define GERBVIEW_FRAME_NAME
Class GERBVIEW_FRAME is the main window used in GerbView.
FACE_T
Known KIFACE implementations.
Definition: kiway.h:264
void * IfaceOrAddress(int aDataId) override
Function IfaceOrAddress return a pointer to the requested object.
Definition: gerbview.cpp:93
int ReadHotkeyConfig(const wxString &aAppname, struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfig Read configuration data and fill the current hotkey list with hotkeys...
see class PGM_BASE
Class KIFACE is used by a participant in the KIWAY alchemy.
Definition: kiway.h:151
struct EDA_HOTKEY_CONFIG GerbviewHokeysDescr[]
MY_API(KIFACE *) KIFACE_GETTER(int *aKIFACEversion
const wxChar * g_GerberPageSizeList[]
List of page sizes.
Definition: gerbview.cpp:38