You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

354 lines
9.4 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 1992-2018 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. * @file mocks.cpp
  25. * @brief Pcbnew main program for qa test.
  26. */
  27. #include <fctsys.h>
  28. #include <pgm_base.h>
  29. #include <kiface_i.h>
  30. #include <confirm.h>
  31. #include <macros.h>
  32. #include <class_drawpanel.h>
  33. #include <pcb_edit_frame.h>
  34. #include <eda_dde.h>
  35. #include <wx/stdpaths.h>
  36. #include <wx/file.h>
  37. #include <wx/snglinst.h>
  38. #include <wx/dir.h>
  39. #include <gestfich.h>
  40. #include <pcbnew.h>
  41. #include <hotkeys.h>
  42. #include <wildcards_and_files_ext.h>
  43. #include <class_board.h>
  44. #include <fp_lib_table.h>
  45. #include <footprint_edit_frame.h>
  46. #include <footprint_viewer_frame.h>
  47. #include <footprint_wizard_frame.h>
  48. #include <pcb_edit_frame.h>
  49. #include <class_board.h>
  50. #include <class_track.h>
  51. #include <class_drawsegment.h>
  52. #include <class_pcb_text.h>
  53. #include <class_pcb_target.h>
  54. #include <class_module.h>
  55. #include <class_dimension.h>
  56. #include <class_zone.h>
  57. #include <class_edge_mod.h>
  58. #include <tools/pcb_actions.h>
  59. #include <router/router_tool.h>
  60. #include "pcb_tool.h"
  61. #include <dialog_find.h>
  62. #include <dialog_block_options.h>
  63. bool g_Drc_On = true;
  64. bool g_AutoDeleteOldTrack = true;
  65. bool g_Raccord_45_Auto = true;
  66. bool g_Alternate_Track_Posture = false;
  67. bool g_Track_45_Only_Allowed = true; // True to allow horiz, vert. and 45deg only tracks
  68. bool g_Segments_45_Only; // True to allow horiz, vert. and 45deg only graphic segments
  69. bool g_TwoSegmentTrackBuild = true;
  70. PCB_LAYER_ID g_Route_Layer_TOP;
  71. PCB_LAYER_ID g_Route_Layer_BOTTOM;
  72. int g_MagneticPadOption;
  73. int g_MagneticTrackOption;
  74. wxPoint g_Offset_Module; // module offset used when moving a footprint
  75. /* Name of the document footprint list
  76. * usually located in share/modules/footprints_doc
  77. * this is of the responsibility to users to create this file
  78. * if they want to have a list of footprints
  79. */
  80. wxString g_DocModulesFileName = wxT( "footprints_doc/footprints.pdf" );
  81. /*
  82. * Used in track creation, a list of track segments currently being created,
  83. * with the newest track at the end of the list, sorted by new-ness. e.g. use
  84. * TRACK->Back() to get the next older track, TRACK->Next() to get the next
  85. * newer track.
  86. */
  87. DLIST<TRACK> g_CurrentTrackList;
  88. bool g_DumpZonesWhenFilling = false;
  89. static struct IFACE : public KIFACE_I
  90. {
  91. // Of course all are overloads, implementations of the KIFACE.
  92. IFACE( const char* aName, KIWAY::FACE_T aType ) :
  93. KIFACE_I( aName, aType )
  94. {}
  95. bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override
  96. {
  97. return true;
  98. }
  99. void OnKifaceEnd() override {}
  100. wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
  101. {
  102. assert( false );
  103. return nullptr;
  104. }
  105. /**
  106. * Function IfaceOrAddress
  107. * return a pointer to the requested object. The safest way to use this
  108. * is to retrieve a pointer to a static instance of an interface, similar to
  109. * how the KIFACE interface is exported. But if you know what you are doing
  110. * use it to retrieve anything you want.
  111. *
  112. * @param aDataId identifies which object you want the address of.
  113. *
  114. * @return void* - and must be cast into the know type.
  115. */
  116. void* IfaceOrAddress( int aDataId ) override
  117. {
  118. return NULL;
  119. }
  120. }
  121. kiface( "pcb_test_frame", KIWAY::FACE_PCB );
  122. static struct PGM_TEST_FRAME : public PGM_BASE
  123. {
  124. bool OnPgmInit();
  125. void OnPgmExit()
  126. {
  127. Kiway.OnKiwayEnd();
  128. // Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl
  129. // earlier than wxApp and earlier than static destruction would.
  130. PGM_BASE::Destroy();
  131. }
  132. void MacOpenFile( const wxString& aFileName ) override
  133. {
  134. wxFileName filename( aFileName );
  135. if( filename.FileExists() )
  136. {
  137. #if 0
  138. // this pulls in EDA_DRAW_FRAME type info, which we don't want in
  139. // the single_top link image.
  140. KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() );
  141. #else
  142. KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
  143. #endif
  144. if( frame )
  145. frame->OpenProjectFiles( std::vector<wxString>( 1, aFileName ) );
  146. }
  147. }
  148. }
  149. program;
  150. PGM_BASE& Pgm()
  151. {
  152. return program;
  153. }
  154. KIFACE_I& Kiface()
  155. {
  156. return kiface;
  157. }
  158. FP_LIB_TABLE GFootprintTable;
  159. void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset )
  160. {
  161. }
  162. // Initialize static member variables
  163. wxString DIALOG_FIND::prevSearchString;
  164. bool DIALOG_FIND::warpMouse = true;
  165. DIALOG_FIND::DIALOG_FIND( PCB_BASE_FRAME* aParent ) : DIALOG_FIND_BASE( aParent )
  166. {
  167. // these members are initialized to avoid warnings about non initialized vars
  168. parent = aParent;
  169. itemCount = markerCount = 0;
  170. foundItem = nullptr;
  171. }
  172. void DIALOG_FIND::OnInitDialog( wxInitDialogEvent& event )
  173. {
  174. }
  175. void DIALOG_FIND::EnableWarp( bool aEnabled )
  176. {
  177. }
  178. void DIALOG_FIND::onButtonCloseClick( wxCommandEvent& aEvent )
  179. {
  180. }
  181. void DIALOG_FIND::onButtonFindItemClick( wxCommandEvent& aEvent )
  182. {
  183. }
  184. void DIALOG_FIND::onButtonFindMarkerClick( wxCommandEvent& aEvent )
  185. {
  186. }
  187. void DIALOG_FIND::onClose( wxCloseEvent& aEvent )
  188. {
  189. }
  190. DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent,
  191. wxWindowID id,
  192. const wxString& title,
  193. const wxPoint& pos,
  194. const wxSize& size,
  195. long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
  196. {
  197. // these members are initialized only to avoid warnings about non initialized vars
  198. m_staticText1 = nullptr;
  199. m_SearchTextCtrl = nullptr;
  200. m_NoMouseWarpCheckBox = nullptr;
  201. m_button1 = nullptr;
  202. m_button2 = nullptr;
  203. m_button3 = nullptr;
  204. }
  205. DIALOG_FIND_BASE::~DIALOG_FIND_BASE()
  206. {
  207. }
  208. MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference()
  209. {
  210. return nullptr;
  211. }
  212. TOOL_ACTION PCB_ACTIONS::selectionModified( "pcbnew.InteractiveEdit.ModifiedSelection",
  213. AS_GLOBAL, 0,
  214. "", "", nullptr, AF_NOTIFY );
  215. TOOL_ACTION PCB_ACTIONS::flip( "pcbnew.InteractiveEdit.flip",
  216. AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_FLIP_ITEM ),
  217. _( "Flip" ), _( "Flips selected item(s)" ), nullptr );
  218. TOOL_ACTION PCB_ACTIONS::properties( "pcbnew.InteractiveEdit.properties",
  219. AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_ITEM ),
  220. _( "Properties..." ), _( "Displays item properties dialog" ), nullptr );
  221. TOOL_ACTION PCB_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet",
  222. AS_GLOBAL, 0,
  223. "", "" );
  224. DIALOG_BLOCK_OPTIONS_BASE::DIALOG_BLOCK_OPTIONS_BASE( wxWindow* parent,
  225. wxWindowID id,
  226. const wxString& title,
  227. const wxPoint& pos,
  228. const wxSize& size,
  229. long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
  230. {
  231. // these members are initialized only to avoid warnings about non initialized vars
  232. m_Include_Modules = nullptr;
  233. m_Include_PcbTextes = nullptr;
  234. m_IncludeLockedModules = nullptr;
  235. m_Include_Draw_Items = nullptr;
  236. m_Include_Tracks = nullptr;
  237. m_Include_Vias = nullptr;
  238. m_Include_Edges_Items = nullptr;
  239. m_Include_Zones = nullptr;
  240. m_DrawBlockItems = nullptr;
  241. m_staticline1 = nullptr;
  242. m_checkBoxIncludeInvisible = nullptr;
  243. m_sdbSizer1 = nullptr;
  244. m_sdbSizer1OK = nullptr;
  245. m_sdbSizer1Cancel = nullptr;
  246. }
  247. DIALOG_BLOCK_OPTIONS_BASE::~DIALOG_BLOCK_OPTIONS_BASE()
  248. {
  249. }
  250. TOOL_ACTION PCB_ACTIONS::rotateCw( "pcbnew.InteractiveEdit.rotateCw",
  251. AS_GLOBAL, MD_SHIFT + 'R',
  252. _( "Rotate Clockwise" ), _( "Rotates selected item(s) clockwise" ),
  253. nullptr, AF_NONE, (void*) -1 );
  254. TOOL_ACTION PCB_ACTIONS::rotateCcw( "pcbnew.InteractiveEdit.rotateCcw",
  255. AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROTATE_ITEM ),
  256. _( "Rotate Counterclockwise" ), _( "Rotates selected item(s) counterclockwise" ),
  257. nullptr, AF_NONE, (void*) 1 );
  258. DIALOG_BLOCK_OPTIONS::DIALOG_BLOCK_OPTIONS( PCB_BASE_FRAME* aParent,
  259. OPTIONS& aOptions, bool aShowLegacyOptions,
  260. const wxString& aTitle ) :
  261. DIALOG_BLOCK_OPTIONS_BASE( aParent, -1, aTitle ),
  262. m_options( aOptions )
  263. {
  264. // silence another compiler warning about m_options not being used
  265. if( m_options.includeModules )
  266. ;
  267. }
  268. void DIALOG_BLOCK_OPTIONS::checkBoxClicked( wxCommandEvent& aEvent )
  269. {
  270. }
  271. void DIALOG_BLOCK_OPTIONS::ExecuteCommand( wxCommandEvent& event )
  272. {
  273. }
  274. void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
  275. {
  276. }
  277. void ROUTER_TOOL::NeighboringSegmentFilter( const VECTOR2I&, GENERAL_COLLECTOR& )
  278. {
  279. }