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.

376 lines
13 KiB

16 years ago
16 years ago
16 years ago
16 years ago
  1. /***********************************************************/
  2. /* wxGerberFrame.h: */
  3. /***********************************************************/
  4. #ifndef WX_GERBER_STRUCT_H
  5. #define WX_GERBER_STRUCT_H
  6. #include "id.h"
  7. #include "class_gerbview_layer_widget.h"
  8. /**
  9. * Command IDs for the gerber file viewer.
  10. *
  11. * Please add IDs that are unique to the gerber file viewer here and not in the
  12. * global id.h file. This will prevent the entire project from being rebuilt
  13. * when adding new command to the gerber file viewer.
  14. */
  15. enum id_gerbview_frm
  16. {
  17. // A MenuItem ID of Zero does not work under Mac,first id = 1
  18. ID_GERBVIEW_SHOW_LIST_DCODES = 1,
  19. ID_GERBVIEW_LOAD_DRILL_FILE,
  20. ID_GERBVIEW_LOAD_DCODE_FILE,
  21. ID_TOOLBARH_GERBER_SELECT_TOOL,
  22. ID_MENU_INC_LAYER_AND_APPEND_FILE,
  23. ID_INC_LAYER_AND_APPEND_FILE,
  24. ID_GERBVIEW_SHOW_SOURCE,
  25. ID_GERBVIEW_EXPORT_TO_PCBNEW,
  26. ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS,
  27. };
  28. /******************************************************************
  29. class WinEDA_GerberFrame: this is the main window used in gerbview
  30. ******************************************************************/
  31. class WinEDA_GerberFrame : public WinEDA_BasePcbFrame
  32. {
  33. friend class PCB_LAYER_WIDGET;
  34. protected:
  35. GERBER_LAYER_WIDGET* m_LayersManager;
  36. public:
  37. WinEDAChoiceBox* m_SelLayerBox;
  38. WinEDAChoiceBox* m_SelLayerTool;
  39. private:
  40. bool m_show_layer_manager_tools;
  41. public:
  42. WinEDA_GerberFrame( wxWindow* father, const wxString& title,
  43. const wxPoint& pos, const wxSize& size,
  44. long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
  45. ~WinEDA_GerberFrame();
  46. void Update_config();
  47. void OnCloseWindow( wxCloseEvent& Event );
  48. /** Function IsGridVisible() , virtual
  49. * @return true if the grid must be shown
  50. */
  51. virtual bool IsGridVisible();
  52. /** Function SetGridVisibility() , virtual
  53. * It may be overloaded by derived classes
  54. * if you want to store/retrieve the grid visiblity in configuration.
  55. * @param aVisible = true if the grid must be shown
  56. */
  57. virtual void SetGridVisibility(bool aVisible);
  58. /** Function GetGridColor() , virtual
  59. * @return the color of the grid
  60. */
  61. virtual int GetGridColor();
  62. /** Function SetGridColor() , virtual
  63. * @param aColor = the new color of the grid
  64. */
  65. virtual void SetGridColor(int aColor);
  66. /**
  67. * Function IsElementVisible
  68. * tests whether a given element category is visible. Keep this as an
  69. * inline function.
  70. * @param aGERBER_VISIBLE is from the enum by the same name
  71. * @return bool - true if the element is visible.
  72. * @see enum PCB_VISIBLE
  73. */
  74. bool IsElementVisible( int aGERBER_VISIBLE )
  75. {
  76. return GetBoard()->IsElementVisible( aGERBER_VISIBLE );
  77. }
  78. /**
  79. * Function SetElementVisibility
  80. * changes the visibility of an element category
  81. * @param aGERBER_VISIBLE is from the enum by the same name
  82. * @param aNewState = The new visibility state of the element category
  83. * @see enum PCB_VISIBLE
  84. */
  85. void SetElementVisibility( int aGERBER_VISIBLE, bool aNewState );
  86. /**
  87. * Function SetVisibleAlls
  88. * Set the status of all visible element categories and layers to VISIBLE
  89. */
  90. void SetVisibleAlls( );
  91. /**
  92. * Function ReFillLayerWidget
  93. * changes out all the layers in m_Layers and may be called upon
  94. * loading a new BOARD.
  95. */
  96. void ReFillLayerWidget();
  97. /**
  98. * Function setActiveLayer
  99. * will change the currently active layer to \a aLayer and also
  100. * update the PCB_LAYER_WIDGET.
  101. */
  102. void setActiveLayer( int aLayer, bool doLayerWidgetUpdate = true )
  103. {
  104. ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
  105. if( doLayerWidgetUpdate )
  106. syncLayerWidget();
  107. }
  108. /**
  109. * Function getActiveLayer
  110. * returns the active layer
  111. */
  112. int getActiveLayer()
  113. {
  114. return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
  115. }
  116. /**
  117. * Function syncLayerWidget
  118. * updates the currently "selected" layer within the PCB_LAYER_WIDGET.
  119. * The currently active layer is defined by the return value of getActiveLayer().
  120. * <p>
  121. * This function cannot be inline without including layer_widget.h in
  122. * here and we do not want to do that.
  123. */
  124. void syncLayerWidget( );
  125. /**
  126. * Function syncLayerBox
  127. * updates the currently "selected" layer within m_SelLayerBox
  128. * The currently active layer, as defined by the return value of
  129. * getActiveLayer(). And updates the colored icon in the toolbar.
  130. */
  131. void syncLayerBox();
  132. /**
  133. * Load applications settings specific to the PCBNew.
  134. *
  135. * This overrides the base class WinEDA_BasePcbFrame::LoadSettings() to
  136. * handle settings specific common to the PCB layout application. It
  137. * calls down to the base class to load settings common to all PCB type
  138. * drawing frames. Please put your application settings for PCBNew here
  139. * to avoid having application settings loaded all over the place.
  140. */
  141. virtual void LoadSettings();
  142. /**
  143. * Save applications settings common to PCB draw frame objects.
  144. *
  145. * This overrides the base class WinEDA_BasePcbFrame::SaveSettings() to
  146. * save settings specific to the PCB layout application main window. It
  147. * calls down to the base class to save settings common to all PCB type
  148. * drawing frames. Please put your application settings for PCBNew here
  149. * to avoid having application settings saved all over the place.
  150. */
  151. virtual void SaveSettings();
  152. /** function SetLanguage
  153. * called on a language menu selection
  154. */
  155. virtual void SetLanguage( wxCommandEvent& event );
  156. void Process_Special_Functions( wxCommandEvent& event );
  157. void RedrawActiveWindow( wxDC* DC, bool EraseBg );
  158. void ReCreateHToolbar();
  159. void ReCreateVToolbar();
  160. void ReCreateOptToolbar();
  161. void ReCreateMenuBar();
  162. void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
  163. void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
  164. bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
  165. int BestZoom();
  166. void OnSelectOptionToolbar( wxCommandEvent& event );
  167. void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct );
  168. BOARD_ITEM* GerberGeneralLocateAndDisplay();
  169. BOARD_ITEM* Locate( int typeloc );
  170. void SetToolbars();
  171. void Process_Settings( wxCommandEvent& event );
  172. void Process_Config( wxCommandEvent& event );
  173. void InstallConfigFrame( const wxPoint& pos );
  174. void InstallGerberGeneralOptionsFrame( wxCommandEvent& event );
  175. void InstallGerberDisplayOptionsDialog( wxCommandEvent& event );
  176. void InstallPcbGlobalDeleteFrame( const wxPoint& pos );
  177. /* handlers for block commands */
  178. int ReturnBlockCommand( int key );
  179. virtual void HandleBlockPlace( wxDC* DC );
  180. virtual int HandleBlockEnd( wxDC* DC );
  181. /* Block operations: */
  182. /**
  183. * Function Block_Delete
  184. * deletes all tracks and segments within the selected block.
  185. * Defined separately in pcbnew and gerbview
  186. *
  187. * @param DC A device context to draw on.
  188. */
  189. void Block_Delete( wxDC* DC );
  190. void Block_Rotate( wxDC* DC );
  191. void Block_Invert( wxDC* DC );
  192. /**
  193. * Function Block_Move
  194. * moves all tracks and segments within the selected block.
  195. * New location is determined by the current offset from the selected
  196. * block's original location.
  197. * Defined separately in pcbnew and gerbview
  198. *
  199. * @param DC A device context to draw on.
  200. */
  201. void Block_Move( wxDC* DC );
  202. /**
  203. * Function Block_Mirror_X
  204. * mirrors all tracks and segments within the currently selected block
  205. * in the X axis.
  206. *
  207. * @param DC A device context to draw on.
  208. */
  209. void Block_Mirror_X( wxDC* DC );
  210. /**
  211. * Function Block_Duplicate
  212. * copies-and-moves all tracks and segments within the selected block.
  213. * New location is determined by the current offset from the selected
  214. * block's original location.
  215. * Defined separately in pcbnew and gerbview
  216. *
  217. * @param DC A device context to draw on.
  218. */
  219. void Block_Duplicate( wxDC* DC );
  220. void InstallDrillFrame( wxCommandEvent& event );
  221. void ToPostProcess( wxCommandEvent& event );
  222. /** Function ToPlotter
  223. * Open a dialog frame to create plot and drill files
  224. * relative to the current board
  225. */
  226. void ToPlotter( wxCommandEvent& event );
  227. /** Function ToPrinter
  228. * Open a dialog frame to print layers
  229. */
  230. void ToPrinter( wxCommandEvent& event );
  231. void Genere_HPGL( const wxString& FullFileName, int Layers );
  232. void Genere_GERBER( const wxString& FullFileName, int Layers );
  233. void Genere_PS( const wxString& FullFileName, int Layers );
  234. void Plot_Layer_HPGL( FILE* File, int masque_layer,
  235. int garde, bool trace_via,
  236. GRTraceMode trace_mode );
  237. void Plot_Layer_GERBER( FILE* File, int masque_layer,
  238. int garde, bool trace_via,
  239. GRTraceMode trace_mode );
  240. int Gen_D_CODE_File( const wxString& Name_File );
  241. void Plot_Layer_PS( FILE* File, int masque_layer,
  242. int garde, bool trace_via,
  243. GRTraceMode trace_mode );
  244. void Files_io( wxCommandEvent& event );
  245. void OnFileHistory( wxCommandEvent& event );
  246. bool LoadOneGerberFile( const wxString& FileName, int mode );
  247. int ReadGerberFile( FILE* File, bool Append );
  248. bool Read_GERBER_File( const wxString& GERBER_FullFileName,
  249. const wxString& D_Code_FullFileName );
  250. bool SaveGerberFile( const wxString& FileName );
  251. void GeneralControle( wxDC* DC, wxPoint Mouse );
  252. /**
  253. * Function Read_D_Code_File
  254. * reads in a dcode file assuming ALSPCB file format with ';' indicating
  255. * comments.
  256. * <p>
  257. * Format is like CSV but with optional ';' delineated comments:<br>
  258. * tool, Horiz, Vert, drill, vitesse, acc. ,Type ; [DCODE (commentaire)]<br>
  259. * ex: 1, 12, 12, 0, 0, 0, 3 ; D10
  260. * <p>
  261. * Format:<br>
  262. * Ver, Hor, Type, Tool [,Drill]<br>
  263. * example: 0.012, 0.012, L , D10<br>
  264. *
  265. * Categorize all found dcodes into a table of D_CODE instantiations.
  266. * @param D_CodeFullFileName The name of the file to read from.
  267. * @return int - <br>
  268. * -1 = file not found<br>
  269. * -2 = parsing problem<br>
  270. * 0 = the \a D_Code_FullFileName is empty, no reading
  271. * is done but an empty GERBER is put into
  272. * g_GERBER_List[]<br>
  273. * 1 = read OK<br>
  274. */
  275. int Read_D_Code_File( const wxString& D_Code_FullFileName );
  276. void CopyDCodesSizeToItems();
  277. void Liste_D_Codes( );
  278. void Trace_Gerber( wxDC* DC, int draw_mode, int printmasklayer );
  279. // PCB handling
  280. bool Clear_Pcb( bool query );
  281. void Erase_Current_Layer( bool query );
  282. void Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number );
  283. TRACK* Delete_Segment( wxDC* DC, TRACK* Track );
  284. // Conversion function
  285. void ExportDataInPcbnewFormat( wxCommandEvent& event );
  286. /* SaveCopyInUndoList() virtual
  287. * currently: do nothing in gerbview.
  288. * but but be defined because it is a pure virtual in WinEDA_BasePcbFrame
  289. */
  290. virtual void SaveCopyInUndoList(
  291. BOARD_ITEM* aItemToCopy,
  292. UndoRedoOpType aTypeCommand = UR_UNSPECIFIED,
  293. const wxPoint& aTransformPoint = wxPoint(0,0) ) { }
  294. /** Function SaveCopyInUndoList (overloaded).
  295. * Creates a new entry in undo list of commands.
  296. * add a list of pickers to handle a list of items
  297. * @param aItemsList = the list of items modified by the command to undo
  298. * @param aTypeCommand = command type (see enum UndoRedoOpType)
  299. * @param aTransformPoint = the reference point of the transformation,
  300. * for commands like move
  301. */
  302. virtual void SaveCopyInUndoList(
  303. PICKED_ITEMS_LIST& aItemsList,
  304. UndoRedoOpType aTypeCommand,
  305. const wxPoint& aTransformPoint = wxPoint(0,0) )
  306. {
  307. // currently: do nothing in gerbview.
  308. }
  309. /** Virtual function PrintPage
  310. * used to print a page
  311. * @param aDC = wxDC given by the calling print function
  312. * @param aPrint_Sheet_Ref = true to print page references
  313. * @param aPrintMask = not used here
  314. * @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
  315. * @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
  316. */
  317. virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref,
  318. int aPrintMask, bool aPrintMirrorMode,
  319. void * aData = NULL);
  320. DECLARE_EVENT_TABLE()
  321. };
  322. #endif /* WX_GERBER_STRUCT_H */