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 <gerbview.h>
33 #include <gerbview_frame.h>
34 
35 const wxChar* g_GerberPageSizeList[] =
36 {
37  wxT( "GERBER" ), // index 0: full size page selection
38  wxT( "A4" ),
39  wxT( "A3" ),
40  wxT( "A2" ),
41  wxT( "A" ),
42  wxT( "B" ),
43  wxT( "C" ),
44 };
45 
46 
47 namespace GERBV {
48 
49 static struct IFACE : public KIFACE_I
50 {
51  // Of course all are virtual overloads, implementations of the KIFACE.
52 
53  IFACE( const char* aName, KIWAY::FACE_T aType ) :
54  KIFACE_I( aName, aType )
55  {}
56 
57  bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
58 
59  void OnKifaceEnd() override;
60 
61  wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
62  {
63  switch( aClassId )
64  {
65  case FRAME_GERBER:
66  {
67  GERBVIEW_FRAME* frame = new GERBVIEW_FRAME( aKiway, aParent );
68  return frame;
69  }
70  break;
71 
72  default:
73  ;
74  }
75 
76  return NULL;
77  }
78 
90  void* IfaceOrAddress( int aDataId ) override
91  {
92  return NULL;
93  }
94 
95 } kiface( "gerbview", KIWAY::FACE_GERBVIEW );
96 
97 } // namespace
98 
99 using namespace GERBV;
100 
102 
103 KIFACE_I& Kiface() { return kiface; }
104 
105 
106 // KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
107 // KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
108 MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
109 {
110  process = aProgram;
111  return &kiface;
112 }
113 
114 
116 {
117  wxASSERT( process ); // KIFACE_GETTER has already been called.
118  return *process;
119 }
120 
121 
122 bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
123 {
124  start_common( aCtlBits );
125  return true;
126 }
127 
128 
130 {
131  end_common();
132 }
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Function OnKifaceStart is called just once shortly after the DSO is loaded.
Definition: gerbview.cpp:122
wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Function CreateWindow creates a wxWindow for the current project.
Definition: gerbview.cpp:61
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:129
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: gerbview.cpp:103
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: gerbview.cpp:115
Class PGM_BASE keeps program (whole process) data for KiCad programs.
Definition: pgm_base.h:166
int PGM_BASE * aProgram
Definition: gerbview.cpp:109
static PGM_BASE * process
Definition: gerbview.cpp:101
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition: gerbview.cpp:53
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:108
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
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:90
see class PGM_BASE
Class KIFACE is used by a participant in the KIWAY alchemy.
Definition: kiway.h:151
MY_API(KIFACE *) KIFACE_GETTER(int *aKIFACEversion
const wxChar * g_GerberPageSizeList[]
List of page sizes.
Definition: gerbview.cpp:35