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.

308 lines
11 KiB

* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2011-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #ifndef CLASS_EXCELLON_H
  25. #define CLASS_EXCELLON_H
  26. enum drill_M_code_t {
  27. DRILL_M_UNKNOWN,
  28. DRILL_M_END,
  29. DRILL_M_ENDREWIND,
  30. DRILL_M_MESSAGE,
  31. DRILL_M_LONGMESSAGE,
  32. DRILL_M_HEADER,
  33. DRILL_M_ENDHEADER,
  34. DRILL_M_BEGINPATTERN,
  35. DRILL_M_ENDPATTERN,
  36. DRILL_M_CANNEDTEXT,
  37. DRILL_M_TIPCHECK,
  38. DRILL_M_METRIC,
  39. DRILL_M_IMPERIAL,
  40. DRILL_METRICHEADER,
  41. DRILL_IMPERIALHEADER,
  42. DRILL_DETECT_BROKEN,
  43. DRILL_INCREMENTALHEADER,
  44. DRILL_REWIND_STOP,
  45. DRILL_TOOL_CHANGE_STOP,
  46. DRILL_AUTOMATIC_SPEED,
  47. DRILL_AXIS_VERSION,
  48. DRILL_RESET_CMD,
  49. DRILL_AUTOMATIC_TOOL_CHANGE,
  50. DRILL_FMT,
  51. DRILL_SKIP,
  52. DRILL_TOOL_INFORMATION
  53. };
  54. enum drill_G_code_t {
  55. DRILL_G_UNKNOWN,
  56. DRILL_G_ABSOLUTE,
  57. DRILL_G_INCREMENTAL,
  58. DRILL_G_ZEROSET,
  59. DRILL_G_ROUT,
  60. DRILL_G_DRILL,
  61. DRILL_G_SLOT,
  62. DRILL_G_ZERO_SET,
  63. DRILL_G_LINEARMOVE,
  64. DRILL_G_CWMOVE,
  65. DRILL_G_CCWMOVE
  66. };
  67. // Helper struct to analyse Excellon commands
  68. struct EXCELLON_CMD
  69. {
  70. std::string m_Name; // key string
  71. int m_Code; // internal code, used as id in functions
  72. int m_asParams; // 0 = no param, -1 = skip params, 1 = read params
  73. };
  74. /* EXCELLON_IMAGE handle a drill image
  75. * It is derived from GERBER_IMAGE because there is a lot of likeness
  76. * between EXCELLON files and GERBER files
  77. * DCode aperture are also similat to T Codes.
  78. * So we can reuse GERBER_IMAGE to handle EXCELLON_IMAGE with very few new functions
  79. */
  80. class EXCELLON_IMAGE : public GERBER_IMAGE
  81. {
  82. private:
  83. enum excellon_state {
  84. READ_HEADER_STATE, // When we are in this state, we are reading header
  85. READ_PROGRAM_STATE // When we are in this state, we are reading drill data
  86. };
  87. excellon_state m_State; // state of excellon file analysis
  88. bool m_SlotOn; // true during an oval driil definition
  89. public: EXCELLON_IMAGE( GERBVIEW_FRAME* aParent, int layer ) :
  90. GERBER_IMAGE( aParent, layer )
  91. {
  92. m_State = READ_HEADER_STATE;
  93. m_SlotOn = false;
  94. }
  95. ~EXCELLON_IMAGE() {};
  96. virtual void ResetDefaultValues()
  97. {
  98. GERBER_IMAGE::ResetDefaultValues();
  99. SelectUnits( false );
  100. }
  101. bool Read_EXCELLON_File( FILE* aFile, const wxString& aFullFileName );
  102. private:
  103. bool Execute_HEADER_Command( char*& text );
  104. bool Select_Tool( char*& text );
  105. bool Execute_EXCELLON_G_Command( char*& text );
  106. bool Execute_Drill_Command( char*& text );
  107. int TCodeNumber( char*& Text )
  108. {
  109. return DCodeNumber( Text );
  110. }
  111. void SelectUnits( bool aMetric );
  112. };
  113. /*
  114. * EXCELLON commands are given here.
  115. * Pcbnew uses only few excellon commands
  116. */
  117. /*
  118. * see http://www.excellon.com/manuals/program.htm
  119. */
  120. /* coordintes units:
  121. * Coordinates are measured either in inch or metric (millimeters).
  122. * Inch coordinates are in six digits (00.0000) with increments as small as 0.0001 (1/10,000).
  123. * Metric coordinates can be measured in microns (thousandths of a millimeter)
  124. * in one of the following three ways:
  125. * Five digit 10 micron resolution (000.00)
  126. * Six digit 10 micron resolution (0000.00)
  127. * Six digit micron resolution (000.000)
  128. *
  129. * Leading and trailing zeros:
  130. * Excellon (CNC-7) uses inches in six digits and metric in five or six digits.
  131. * The zeros to the left of the coordinate are called leading zeros (LZ).
  132. * The zeros to right of the coordinate are called trailing zeros (TZ).
  133. * The CNC-7 uses leading zeros unless you specify otherwise through a part program.
  134. * You can do so with the INCH/METRIC command.
  135. * With leading zeros, the leading zeros must always be included.
  136. * Trailing zeros are unneeded and may be left off.
  137. * For trailing zeros, the reverse of the above is true.
  138. */
  139. /*
  140. * EXCELLON Commands Used in a Header
  141. * The following table provides you with a list of commands which
  142. * are the most used in a part program header.
  143. * COMMAND DESCRIPTION
  144. * AFS Automatic Feeds and Speeds
  145. * ATC Automatic Tool Change
  146. * BLKD Delete all Blocks starting with a slash (/)
  147. * CCW Clockwise or Counter-clockwise Routing
  148. * CP Cutter Compensation
  149. * DETECT Broken Tool Detection
  150. * DN Down Limit Set
  151. * DTMDIST Maximum Rout Distance Before Toolchange
  152. * EXDA Extended Drill Area
  153. * FMAT Format 1 or 2
  154. * FSB Turns the Feed/Speed Buttons off
  155. * HPCK Home Pulse Check
  156. * ICI Incremental Input of Part Program Coordinates
  157. * INCH Measure Everything in Inches
  158. * METRIC Measure Everything in Metric
  159. * M48 Beginning of Part Program Header
  160. * M95 End of Header
  161. * NCSL NC Slope Enable/Disable
  162. * OM48 Override Part Program Header
  163. * OSTOP Optional Stop Switch
  164. * OTCLMP Override Table Clamp
  165. * PCKPARAM Set up pecking tool,depth,infeed and retract parameters
  166. * PF Floating Pressure Foot Switch
  167. * PPR Programmable Plunge Rate Enable
  168. * PVS Pre-vacuum Shut-off Switch
  169. * R,C Reset Clocks
  170. * R,CP Reset Program Clocks
  171. * R,CR Reset Run Clocks
  172. * R,D Reset All Cutter Distances
  173. * R,H Reset All Hit Counters
  174. * R,T Reset Tool Data
  175. * SBK Single Block Mode Switch
  176. * SG Spindle Group Mode
  177. * SIXM Input From External Source
  178. * T Tool Information
  179. * TCST Tool Change Stop
  180. * UP Upper Limit Set
  181. * VER Selection of X and Y Axis Version
  182. * Z Zero Set
  183. * ZA Auxiliary Zero
  184. * ZC Zero Correction
  185. * ZS Zero Preset
  186. * Z+# or Z-# Set Depth Offset
  187. * % Rewind Stop
  188. * #/#/# Link Tool for Automatic Tool Change
  189. * / Clear Tool Linking
  190. */
  191. /*
  192. * Beyond The Header: The Part Program Body
  193. * COMMAND DESCRIPTION
  194. * A# Arc Radius
  195. * B# Retract Rate
  196. * C# Tool Diameter
  197. * F# Table Feed Rate;Z Axis Infeed Rate
  198. * G00X#Y# Route Mode
  199. * G01 Linear (Straight Line) Mode
  200. * G02 Circular CW Mode
  201. * G03 Circular CCW Mode
  202. * G04 X# Variable Dwell
  203. * G05 Drill Mode
  204. * G07 Override current tool feed or speed
  205. * G32X#Y#A# Routed Circle Canned Cycle
  206. * CW G33X#Y#A# Routed Circle Canned Cycle
  207. * CCW G34,#(,#) Select Vision Tool
  208. * G35(X#Y#) Single Point Vision Offset (Relative to Work Zero)
  209. * G36(X#Y#) Multipoint Vision Translation (Relative to Work Zero)
  210. * G37 Cancel Vision Translation or Offset (From G35 or G36)
  211. * G38(X#Y#) Vision Corrected Single Hole Drilling (Relative to Work Zero)
  212. * G39(X#Y#) Vision System Autocalibration
  213. * G40 Cutter Compensation Off
  214. * G41 Cutter Compensation Left
  215. * G42 Cutter Compensation Right
  216. * G45(X#Y#) Single Point Vision Offset (Relative to G35 or G36)
  217. * G46(X#Y#) Multipoint Vision Translation (Relative to G35 or G36)
  218. * G47 Cancel Vision Translation or Offset (From G45 or G46)
  219. * G48(X#Y#) Vision Corrected Single Hole Drilling (Relative to G35 or G36)
  220. * G82(G81) Dual In Line Package
  221. * G83 Eight Pin L Pack
  222. * G84 Circle
  223. * G85 Slot
  224. * G87 Routed Step Slot Canned Cycle
  225. * G90 Absolute Mode
  226. * G91 Incremental Input Mode
  227. * G93X#Y# Zero Set
  228. * H# Maximum hit count
  229. * I#J# Arc Center Offset
  230. * M00(X#Y#) End of Program - No Rewind
  231. * M01 End of Pattern
  232. * M02X#Y# Repeat Pattern Offset
  233. * M06(X#Y#) Optional Stop
  234. * M08 End of Step and Repeat
  235. * M09(X#Y#) Stop for Inspection
  236. * M14 Z Axis Route Position With Depth Controlled Contouring
  237. * M15 Z Axis Route Position
  238. * M16 Retract With Clamping
  239. * M17 Retract Without Clamping
  240. * M18 Command tool tip check
  241. * M25 Beginning of Pattern
  242. * M30(X#Y#) End of Program Rewind
  243. * M45,long message\ Long Operator message on multiple\ part program lines
  244. * M47,text Operator Message
  245. * M50,# Vision Step and Repeat Pattern Start
  246. * M51,# Vision Step and Repeat Rewind
  247. * M52(#) Vision Step and Repeat Offset Counter Control
  248. * M02XYM70 Swap Axes
  249. * M60 Reference Scaling enable
  250. * M61 Reference Scaling disable
  251. * M62 Turn on peck drilling
  252. * M63 Turn off peck drilling
  253. * M71 Metric Measuring Mode
  254. * M72 Inch Measuring Mode
  255. * M02XYM80 Mirror Image X Axis
  256. * M02XYM90 Mirror Image Y Axis
  257. * M97,text Canned Text
  258. * M98,text Canned Text
  259. * M99,subprogram User Defined Stored Pattern
  260. * P#X#(Y#) Repeat Stored Pattern
  261. * R#M02X#Y# Repeat Pattern (S&R)
  262. * R#(X#Y#) Repeat Hole
  263. * S# Spindle RPM
  264. * T# Tool Selection; Cutter Index
  265. * Z+# or Z-# Depth Offset
  266. * % Beginning of Pattern (see M25 command)
  267. * / Block Delete
  268. */
  269. /*
  270. * Example of a Header
  271. * COMMAND PURPOSE
  272. * M48 The beginning of a header
  273. * INCH,LZ Use the inch measuring system with leading zeros
  274. * VER,1 Use Version 1 X and Y axis layout
  275. * FMAT,2 Use Format 2 commands
  276. * 1/2/3 Link tools 1, 2, and 3
  277. * T1C.04F200S65 Set Tool 1 for 0.040" with infeed rate of 200 inch/min Speed of 65,000 RPM
  278. * DETECT,ON Detect broken tools
  279. * M95 End of the header
  280. */
  281. #endif // CLASS_EXCELLON_H