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 // Colors for layers and items
40 
41 
42 const wxChar* g_GerberPageSizeList[] = {
43  wxT( "GERBER" ), // index 0: full size page selection, and do not show page limits
44  wxT( "GERBER" ), // index 1: full size page selection, and show page limits
45  wxT( "A4" ),
46  wxT( "A3" ),
47  wxT( "A2" ),
48  wxT( "A" ),
49  wxT( "B" ),
50  wxT( "C" ),
51 };
52 
53 
54 namespace GERBV {
55 
56 static struct IFACE : public KIFACE_I
57 {
58  // Of course all are virtual overloads, implementations of the KIFACE.
59 
60  IFACE( const char* aName, KIWAY::FACE_T aType ) :
61  KIFACE_I( aName, aType )
62  {}
63 
64  bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
65 
66  void OnKifaceEnd() override;
67 
68  wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
69  {
70  switch( aClassId )
71  {
72  case FRAME_GERBER:
73  {
74  GERBVIEW_FRAME* frame = new GERBVIEW_FRAME( aKiway, aParent );
75  return frame;
76  }
77  break;
78 
79  default:
80  ;
81  }
82 
83  return NULL;
84  }
85 
97  void* IfaceOrAddress( int aDataId ) override
98  {
99  return NULL;
100  }
101 
102 } kiface( "gerbview", KIWAY::FACE_GERBVIEW );
103 
104 } // namespace
105 
106 using namespace GERBV;
107 
109 
110 KIFACE_I& Kiface() { return kiface; }
111 
112 
113 // KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
114 // KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
115 MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
116 {
117  process = aProgram;
118  return &kiface;
119 }
120 
121 
123 {
124  wxASSERT( process ); // KIFACE_GETTER has already been called.
125  return *process;
126 }
127 
128 
129 bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
130 {
131  start_common( aCtlBits );
132 
133  // Must be called before creating the main frame in order to
134  // display the real hotkeys in menus or tool tips
136 
137  return true;
138 }
139 
140 
142 {
143  end_common();
144 }
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Function OnKifaceStart is called just once shortly after the DSO is loaded.
Definition: gerbview.cpp:129
void ReadHotkeyConfig(const wxString &Appname, struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfig Read hotkey configuration for a given app, possibly before the frame for th...
wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Function CreateWindow creates a wxWindow for the current project.
Definition: gerbview.cpp:68
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:94
void OnKifaceEnd() override
Function OnKifaceEnd is called just once just before the DSO is to be unloaded.
Definition: gerbview.cpp:141
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: gerbview.cpp:110
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: gerbview.cpp:122
Class PGM_BASE keeps program (whole process) data for KiCad programs.
Definition: pgm_base.h:107
int PGM_BASE * aProgram
Definition: gerbview.cpp:116
COLORS_DESIGN_SETTINGS g_ColorsSettings
Definition: gerbview.cpp:39
static PGM_BASE * process
Definition: gerbview.cpp:108
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition: gerbview.cpp:60
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:104
int aKiwayVersion
Definition: gerbview.cpp:115
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
#define GERBVIEW_FRAME_NAME
Class GERBVIEW_FRAME is the main window used in GerbView.
FACE_T
Known KIFACE implementations.
Definition: kiway.h:263
void * IfaceOrAddress(int aDataId) override
Function IfaceOrAddress return a pointer to the requested object.
Definition: gerbview.cpp:97
see class PGM_BASE
Class KIFACE is used by a participant in the KIWAY alchemy.
Definition: kiway.h:150
struct EDA_HOTKEY_CONFIG GerbviewHokeysDescr[]
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Eeschema, Pcbnew and GerbView...
MY_API(KIFACE *) KIFACE_GETTER(int *aKIFACEversion
const wxChar * g_GerberPageSizeList[]
List of page sizes.
Definition: gerbview.cpp:42