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.

260 lines
9.7 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. default:
  153. return wxString::Format( _( "Unknown DRC error code %d" ), m_ErrorCode );
  154. }
  155. }
  156. wxString DRC_ITEM::ShowCoord( EDA_UNITS_T aUnits, const wxPoint& aPos )
  157. {
  158. return wxString::Format( wxT( "@(%s, %s)" ),
  159. MessageTextFromValue( aUnits, aPos.x ),
  160. MessageTextFromValue( aUnits, aPos.y ) );
  161. }
  162. wxString DRC_ITEM::ShowHtml( EDA_UNITS_T aUnits ) const
  163. {
  164. wxString mainText = m_MainText;
  165. // a wxHtmlWindows does not like < and > in the text to display
  166. // because these chars have a special meaning in html
  167. mainText.Replace( wxT("<"), wxT("&lt;") );
  168. mainText.Replace( wxT(">"), wxT("&gt;") );
  169. wxString errText = GetErrorText();
  170. errText.Replace( wxT("<"), wxT("&lt;") );
  171. errText.Replace( wxT(">"), wxT("&gt;") );
  172. if( m_noCoordinate )
  173. {
  174. // omit the coordinate, a NETCLASS has no location
  175. return wxString::Format( wxT( "<b>%s</b><br>&nbsp;&nbsp; %s" ),
  176. errText,
  177. mainText );
  178. }
  179. else if( m_hasSecondItem )
  180. {
  181. wxString auxText = m_AuxiliaryText;
  182. auxText.Replace( wxT("<"), wxT("&lt;") );
  183. auxText.Replace( wxT(">"), wxT("&gt;") );
  184. // an html fragment for the entire message in the listbox. feel free
  185. // to add color if you want:
  186. return wxString::Format( wxT( "<b>%s</b><br>&nbsp;&nbsp; %s: %s<br>&nbsp;&nbsp; %s: %s" ),
  187. errText,
  188. ShowCoord( aUnits, m_MainPosition ),
  189. mainText,
  190. ShowCoord( aUnits, m_AuxiliaryPosition ),
  191. auxText );
  192. }
  193. else
  194. {
  195. return wxString::Format( wxT( "<b>%s</b><br>&nbsp;&nbsp; %s: %s" ),
  196. errText,
  197. ShowCoord( aUnits, m_MainPosition ),
  198. mainText );
  199. }
  200. }
  201. wxString DRC_ITEM::ShowReport( EDA_UNITS_T aUnits ) const
  202. {
  203. if( m_hasSecondItem )
  204. {
  205. return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ),
  206. m_ErrorCode,
  207. GetErrorText(),
  208. ShowCoord( aUnits, m_MainPosition ),
  209. m_MainText,
  210. ShowCoord( aUnits, m_AuxiliaryPosition ),
  211. m_AuxiliaryText );
  212. }
  213. else
  214. {
  215. return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n" ),
  216. m_ErrorCode,
  217. GetErrorText(),
  218. ShowCoord( aUnits, m_MainPosition ),
  219. m_MainText );
  220. }
  221. }
  222. BOARD_ITEM* DRC_ITEM::GetMainItem( BOARD* aBoard ) const
  223. {
  224. return aBoard->GetItem( m_mainItemWeakRef );
  225. }
  226. BOARD_ITEM* DRC_ITEM::GetAuxiliaryItem( BOARD* aBoard ) const
  227. {
  228. return aBoard->GetItem( m_auxItemWeakRef );
  229. }