KiCad PCB EDA Suite
mocks.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) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include <fctsys.h>
25 #include <pgm_base.h>
26 #include <kiface_i.h>
27 #include <confirm.h>
28 #include <pcb_edit_frame.h>
29 #include <eda_dde.h>
30 #include <wx/file.h>
31 #include <wx/snglinst.h>
32 #include <class_board.h>
33 #include <fp_lib_table.h>
34 #include <footprint_viewer_frame.h>
35 #include <footprint_wizard_frame.h>
36 #include <class_drawsegment.h>
37 #include <class_pcb_text.h>
38 #include <class_pcb_target.h>
39 #include <class_module.h>
40 #include <class_dimension.h>
41 #include <class_zone.h>
42 #include <class_edge_mod.h>
43 #include <tools/pcb_actions.h>
44 #include <router/router_tool.h>
45 #include <dialog_find.h>
47 
48 
49 static struct IFACE : public KIFACE_I
50 {
51  // Of course all are 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  return true;
60  }
61 
62  void OnKifaceEnd() override {}
63 
64  wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
65  {
66  assert( false );
67  return nullptr;
68  }
69 
81  void* IfaceOrAddress( int aDataId ) override
82  {
83  return NULL;
84  }
85 }
86 kiface( "pcb_test_frame", KIWAY::FACE_PCB );
87 
88 static struct PGM_TEST_FRAME : public PGM_BASE
89 {
90  bool OnPgmInit();
91 
92  void OnPgmExit()
93  {
94  Kiway.OnKiwayEnd();
95 
96  // Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl
97  // earlier than wxApp and earlier than static destruction would.
99  }
100 
101  void MacOpenFile( const wxString& aFileName ) override
102  {
103  wxFileName filename( aFileName );
104 
105  if( filename.FileExists() )
106  {
107  #if 0
108  // this pulls in EDA_DRAW_FRAME type info, which we don't want in
109  // the single_top link image.
110  KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() );
111  #else
112  KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
113  #endif
114 
115  if( frame )
116  frame->OpenProjectFiles( std::vector<wxString>( 1, aFileName ) );
117  }
118  }
119 }
120 program;
121 
123 {
124  return program;
125 }
126 
127 
128 // Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face
129 // is run from a python script, mot from a Kicad application
131 {
132  return nullptr; //&program;
133 }
134 
137 {
138  return kiface;
139 }
140 
141 
143 
145 {
146  // these members are initialized to avoid warnings about non initialized vars
147  m_frame = aParent;
148  m_hitList.clear();
149  m_it = m_hitList.begin();
150  m_upToDate = false;
151 }
152 
153 void DIALOG_FIND::onFindNextClick( wxCommandEvent& aEvent )
154 {
155 }
156 
157 void DIALOG_FIND::onFindPreviousClick( wxCommandEvent& aEvent )
158 {
159 }
160 
161 void DIALOG_FIND::onSearchAgainClick( wxCommandEvent& aEvent )
162 {
163 }
164 
165 void DIALOG_FIND::onTextEnter( wxCommandEvent& event )
166 {
167 }
168 
169 void DIALOG_FIND::onClose( wxCommandEvent& aEvent )
170 {
171 }
172 
173 
174 DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, wxWindowID id, const wxString& title,
175  const wxPoint& pos, const wxSize& size, long style ) :
176  DIALOG_SHIM( parent, id, title, pos, size, style )
177 {
178  // these members are initialized only to avoid warnings about non initialized vars
179  searchStringLabel = nullptr;
180  m_searchCombo = nullptr;
181  m_matchCase = nullptr;
182  m_matchWords = nullptr;
183  m_wildcards = nullptr;
184  m_wrap = nullptr;
185  m_includeValues = nullptr;
186  m_includeReferences = nullptr;
187  m_includeTexts = nullptr;
188  m_includeMarkers = nullptr;
189  m_includeVias = nullptr;
190  m_findNext = nullptr;
191  m_findPrevious = nullptr;
192  m_searchAgain = nullptr;
193  m_closeButton = nullptr;
194  m_status = nullptr;
195 }
196 
197 
199 {
200 }
201 
202 
204 {
205  return nullptr;
206 }
207 
208 
209 DIALOG_FILTER_SELECTION_BASE::DIALOG_FILTER_SELECTION_BASE( wxWindow* parent, wxWindowID id,
210  const wxString& title,
211  const wxPoint& pos, const wxSize& size,
212  long style ) :
213  DIALOG_SHIM( parent, id, title, pos, size, style )
214 {
215  // these members are initialized only to avoid warnings about non initialized vars
216  m_Include_Modules = nullptr;
217  m_Include_PcbTextes = nullptr;
218  m_IncludeLockedModules = nullptr;
219  m_Include_Draw_Items = nullptr;
220  m_Include_Tracks = nullptr;
221  m_Include_Vias = nullptr;
222  m_Include_Edges_Items = nullptr;
223  m_Include_Zones = nullptr;
224  m_sdbSizer1 = nullptr;
225  m_staticLine = nullptr;
226  m_sdbSizer1OK = nullptr;
227  m_sdbSizer1Cancel = nullptr;
228 }
229 
230 
232 {
233 }
234 
235 
237  DIALOG_FILTER_SELECTION_BASE( aParent ),
238  m_options( aOptions )
239 {
240  // silence another compiler warning about m_options not being used
241  if( m_options.includeModules )
242  {
243  }
244 }
245 
246 
247 void DIALOG_FILTER_SELECTION::checkBoxClicked( wxCommandEvent& aEvent )
248 {
249 }
250 
251 
252 void DIALOG_FILTER_SELECTION::ExecuteCommand( wxCommandEvent& event )
253 {
254 }
255 
256 
258 {
259 }
260 
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
Definition: kiway_player.h:118
KIFACE_I is a KIFACE (I)mplementation, with some features useful for DSOs which implement a KIFACE.
Definition: kiface_i.h:37
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
void checkBoxClicked(wxCommandEvent &aEvent) override
Reference to the options struct to fill.
DDE server & client.
TEXTE_PCB class definition.
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Function OnKifaceStart is called just once shortly after the DSO is loaded.
Definition: mocks.cpp:57
void MacOpenFile(const wxString &aFileName) override
Function MacOpenFile is specific to MacOSX (not used under Linux or Windows).
Definition: mocks.cpp:101
This file is part of the common library.
PGM_BASE keeps program (whole process) data for KiCad programs.
Definition: pgm_base.h:137
VTBL_ENTRY wxApp & App()
Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP,...
Definition: pgm_base.cpp:129
void Destroy()
Definition: pgm_base.cpp:118
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: mocks.cpp:136
wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Function CreateWindow creates a wxWindow for the current project.
Definition: mocks.cpp:64
void OnKifaceEnd() override
Function OnKifaceEnd is called just once just before the DSO is to be unloaded.
Definition: mocks.cpp:62
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:83
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition: mocks.cpp:53
void OnKiwayEnd()
Definition: kiway.cpp:600
DIALOG_FIND_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE)
void onTextEnter(wxCommandEvent &event) override
Definition: dialog_find.cpp:94
IFACE KIFACE_I kiface("pcb_test_frame", KIWAY::FACE_PCB)
DIMENSION class definition.
Class DIALOG_FILTER_SELECTION_BASE.
PGM_TEST_FRAME program
void onFindNextClick(wxCommandEvent &event) override
Definition: dialog_find.cpp:99
#define NULL
void onFindPreviousClick(wxCommandEvent &event) override
void OnPgmExit()
Definition: mocks.cpp:92
FP_LIB_TABLE GFootprintTable
!!!!!!!!!!!!!! This code is obsolete because of the merge into pcbnew, don't bother with it.
Definition: mocks.cpp:142
DIALOG_FIND(PCB_BASE_FRAME *aParent)
Definition: dialog_find.cpp:53
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
pcbnew DSO
Definition: kiway.h:282
int PGM_BASE * aProgram
Definition: cvpcb/cvpcb.cpp:97
void * IfaceOrAddress(int aDataId) override
Function IfaceOrAddress return a pointer to the requested object.
Definition: mocks.cpp:81
FACE_T
Known KIFACE implementations.
Definition: kiway.h:279
void onClose(wxCommandEvent &event) override
see class PGM_BASE
Class to handle a graphic segment.
PGM_BASE * PgmOrNull()
similat to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
Definition: mocks.cpp:130
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: mocks.cpp:122
DIALOG_FILTER_SELECTION(PCB_BASE_FRAME *aParent, OPTIONS &aOptions)
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
PCB_TARGET class definition.
MODULE * GetFootprintFromBoardByReference()
Function GetFootprintFromBoardByReference.
void ExecuteCommand(wxCommandEvent &event) override
void onSearchAgainClick(wxCommandEvent &event) override
EDGE_MODULE class definition.
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
DIALOG_FILTER_SELECTION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Filter Selection"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
Class DIALOG_FIND_BASE.
KIWAY Kiway