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.

262 lines
9.8 KiB

18 years ago
18 years ago
18 years ago
9 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com
  5. * Copyright (C) 2015-2018 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. #include <fctsys.h>
  25. #include <common.h>
  26. #include <pcbnew.h>
  27. #include <drc.h>
  28. #include <drc_item.h>
  29. #include <class_board.h>
  30. #include <base_units.h>
  31. wxString DRC_ITEM::GetErrorText() const
  32. {
  33. switch( m_ErrorCode )
  34. {
  35. case DRCE_UNCONNECTED_ITEMS:
  36. return wxString( _( "Unconnected items" ) );
  37. case DRCE_TRACK_NEAR_THROUGH_HOLE:
  38. return wxString( _( "Track too close to thru-hole" ) );
  39. case DRCE_TRACK_NEAR_PAD:
  40. return wxString( _( "Track too close to pad" ) );
  41. case DRCE_TRACK_NEAR_VIA:
  42. return wxString( _( "Track too close to via" ) );
  43. case DRCE_VIA_NEAR_VIA:
  44. return wxString( _( "Via too close to via" ) );
  45. case DRCE_VIA_NEAR_TRACK:
  46. return wxString( _( "Via too close to track" ) );
  47. case DRCE_TRACK_ENDS1:
  48. case DRCE_TRACK_ENDS2:
  49. case DRCE_TRACK_ENDS3:
  50. case DRCE_TRACK_ENDS4:
  51. case DRCE_ENDS_PROBLEM1:
  52. case DRCE_ENDS_PROBLEM2:
  53. case DRCE_ENDS_PROBLEM3:
  54. case DRCE_ENDS_PROBLEM4:
  55. case DRCE_ENDS_PROBLEM5:
  56. return wxString( _( "Two track ends too close" ) );
  57. case DRCE_TRACK_SEGMENTS_TOO_CLOSE:
  58. return wxString( _( "Two parallel track segments too close" ) );
  59. case DRCE_TRACKS_CROSSING:
  60. return wxString( _( "Tracks crossing" ) );
  61. case DRCE_TRACK_NEAR_ZONE:
  62. return wxString( _( "Track too close to copper area" ) );
  63. case DRCE_PAD_NEAR_PAD1:
  64. return wxString( _( "Pad too close to pad" ) );
  65. case DRCE_VIA_HOLE_BIGGER:
  66. return wxString( _( "Via hole > diameter" ) );
  67. case DRCE_MICRO_VIA_INCORRECT_LAYER_PAIR:
  68. return wxString( _( "Micro Via: incorrect layer pairs (not adjacent)" ) );
  69. case DRCE_MICRO_VIA_NOT_ALLOWED:
  70. return wxString( _( "Micro Via: not allowed" ) );
  71. case DRCE_BURIED_VIA_NOT_ALLOWED:
  72. return wxString( _( "Buried Via: not allowed" ) );
  73. case DRCE_DISABLED_LAYER_ITEM:
  74. return wxString( _( "Item on a disabled layer" ) );
  75. case DRCE_ZONES_INTERSECT:
  76. return wxString( _( "Copper area inside copper area" ) );
  77. case DRCE_ZONES_TOO_CLOSE:
  78. return wxString( _( "Copper areas intersect or are too close" ) );
  79. case DRCE_SUSPICIOUS_NET_FOR_ZONE_OUTLINE:
  80. return wxString( _( "Copper area belongs to a net which has no pads" ) );
  81. case DRCE_HOLE_NEAR_PAD:
  82. return wxString( _( "Hole too close to pad" ) );
  83. case DRCE_HOLE_NEAR_TRACK:
  84. return wxString( _( "Hole too close to track" ) );
  85. case DRCE_TOO_SMALL_TRACK_WIDTH:
  86. return wxString( _( "Track width too small" ) );
  87. case DRCE_TOO_SMALL_VIA:
  88. return wxString( _( "Via size too small" ) );
  89. case DRCE_TOO_SMALL_MICROVIA:
  90. return wxString( _( "Micro via size too small" ) );
  91. case DRCE_TOO_SMALL_VIA_DRILL:
  92. return wxString( _( "Via drill too small" ) );
  93. case DRCE_TOO_SMALL_MICROVIA_DRILL:
  94. return wxString( _( "Micro via drill too small" ) );
  95. case DRCE_DRILLED_HOLES_TOO_CLOSE:
  96. return wxString( _( "Drilled holes too close together" ) );
  97. case DRCE_TRACK_NEAR_EDGE:
  98. return wxString( _( "Track too close to board edge" ) );
  99. case DRCE_INVALID_OUTLINE:
  100. return wxString( _( "Board outline does not form a closed polygon" ) );
  101. // use &lt; since this is text ultimately embedded in HTML
  102. case DRCE_NETCLASS_TRACKWIDTH:
  103. return wxString( _( "NetClass Track Width &lt; global limit" ) );
  104. case DRCE_NETCLASS_CLEARANCE:
  105. return wxString( _( "NetClass Clearance &lt; global limit" ) );
  106. case DRCE_NETCLASS_VIASIZE:
  107. return wxString( _( "NetClass Via Dia &lt; global limit" ) );
  108. case DRCE_NETCLASS_VIADRILLSIZE:
  109. return wxString( _( "NetClass Via Drill &lt; global limit" ) );
  110. case DRCE_NETCLASS_uVIASIZE:
  111. return wxString( _( "NetClass uVia Dia &lt; global limit" ) );
  112. case DRCE_NETCLASS_uVIADRILLSIZE:
  113. return wxString( _( "NetClass uVia Drill &lt; global limit" ) );
  114. case DRCE_VIA_INSIDE_KEEPOUT:
  115. return wxString( _( "Via inside keepout area" ) );
  116. case DRCE_TRACK_INSIDE_KEEPOUT:
  117. return wxString( _( "Track inside keepout area" ) );
  118. case DRCE_PAD_INSIDE_KEEPOUT:
  119. return wxString( _( "Pad inside keepout area" ) );
  120. case DRCE_VIA_NEAR_COPPER:
  121. return wxString( _( "Via too close to copper item" ) );
  122. case DRCE_TRACK_NEAR_COPPER:
  123. return wxString( _( "Track too close to copper item" ) );
  124. case DRCE_PAD_NEAR_COPPER:
  125. return wxString( _( "Pad too close to copper item" ) );
  126. case DRCE_OVERLAPPING_FOOTPRINTS:
  127. return wxString( _( "Courtyards overlap" ) );
  128. case DRCE_MISSING_COURTYARD_IN_FOOTPRINT:
  129. return wxString( _( "Footprint has no courtyard defined" ) );
  130. case DRCE_MALFORMED_COURTYARD_IN_FOOTPRINT:
  131. return wxString( _( "Footprint has incorrect courtyard (not a closed shape)" ) );
  132. case DRCE_DUPLICATE_FOOTPRINT:
  133. return wxString( _( "Duplicate footprints" ) );
  134. case DRCE_MISSING_FOOTPRINT:
  135. return wxString( _( "Missing footprint" ) );
  136. case DRCE_EXTRA_FOOTPRINT:
  137. return wxString( _( "Extra footprint" ) );
  138. case DRCE_SHORT:
  139. return wxString( _( "Remove track shorting two nets" ) );
  140. case DRCE_REDUNDANT_VIA:
  141. return wxString( _( "Remove redundant via" ) );
  142. case DRCE_DUPLICATE_TRACK:
  143. return wxString( _( "Remove duplicate track" ) );
  144. case DRCE_MERGE_TRACKS:
  145. return wxString( _( "Merge co-linear tracks" ) );
  146. case DRCE_DANGLING_TRACK:
  147. return wxString( _( "Remove dangling track" ) );
  148. case DRCE_DANGLING_VIA:
  149. return wxString( _( "Remove dangling via" ) );
  150. case DRCE_ZERO_LENGTH_TRACK:
  151. return wxString( _( "Remove zero-length track" ) );
  152. case DRCE_TRACK_IN_PAD:
  153. return wxString( _( "Remove track inside pad" ) );
  154. default:
  155. return wxString::Format( _( "Unknown DRC error code %d" ), m_ErrorCode );
  156. }
  157. }
  158. wxString DRC_ITEM::ShowCoord( EDA_UNITS_T aUnits, const wxPoint& aPos )
  159. {
  160. return wxString::Format( wxT( "@(%s, %s)" ),
  161. MessageTextFromValue( aUnits, aPos.x ),
  162. MessageTextFromValue( aUnits, aPos.y ) );
  163. }
  164. wxString DRC_ITEM::ShowHtml( EDA_UNITS_T aUnits ) const
  165. {
  166. wxString mainText = m_MainText;
  167. // a wxHtmlWindows does not like < and > in the text to display
  168. // because these chars have a special meaning in html
  169. mainText.Replace( wxT("<"), wxT("&lt;") );
  170. mainText.Replace( wxT(">"), wxT("&gt;") );
  171. wxString errText = GetErrorText();
  172. errText.Replace( wxT("<"), wxT("&lt;") );
  173. errText.Replace( wxT(">"), wxT("&gt;") );
  174. if( m_noCoordinate )
  175. {
  176. // omit the coordinate, a NETCLASS has no location
  177. return wxString::Format( wxT( "<b>%s</b><br>&nbsp;&nbsp; %s" ),
  178. errText,
  179. mainText );
  180. }
  181. else if( m_hasSecondItem )
  182. {
  183. wxString auxText = m_AuxiliaryText;
  184. auxText.Replace( wxT("<"), wxT("&lt;") );
  185. auxText.Replace( wxT(">"), wxT("&gt;") );
  186. // an html fragment for the entire message in the listbox. feel free
  187. // to add color if you want:
  188. return wxString::Format( wxT( "<b>%s</b><br>&nbsp;&nbsp; %s: %s<br>&nbsp;&nbsp; %s: %s" ),
  189. errText,
  190. ShowCoord( aUnits, m_MainPosition ),
  191. mainText,
  192. ShowCoord( aUnits, m_AuxiliaryPosition ),
  193. auxText );
  194. }
  195. else
  196. {
  197. return wxString::Format( wxT( "<b>%s</b><br>&nbsp;&nbsp; %s: %s" ),
  198. errText,
  199. ShowCoord( aUnits, m_MainPosition ),
  200. mainText );
  201. }
  202. }
  203. wxString DRC_ITEM::ShowReport( EDA_UNITS_T aUnits ) const
  204. {
  205. if( m_hasSecondItem )
  206. {
  207. return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ),
  208. m_ErrorCode,
  209. GetErrorText(),
  210. ShowCoord( aUnits, m_MainPosition ),
  211. m_MainText,
  212. ShowCoord( aUnits, m_AuxiliaryPosition ),
  213. m_AuxiliaryText );
  214. }
  215. else
  216. {
  217. return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n" ),
  218. m_ErrorCode,
  219. GetErrorText(),
  220. ShowCoord( aUnits, m_MainPosition ),
  221. m_MainText );
  222. }
  223. }
  224. BOARD_ITEM* DRC_ITEM::GetMainItem( BOARD* aBoard ) const
  225. {
  226. return aBoard->GetItem( m_mainItemWeakRef );
  227. }
  228. BOARD_ITEM* DRC_ITEM::GetAuxiliaryItem( BOARD* aBoard ) const
  229. {
  230. return aBoard->GetItem( m_auxItemWeakRef );
  231. }