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.

249 lines
11 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020 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. #include "wx/html/m_templ.h"
  24. #include "wx/html/styleparams.h"
  25. #include <erc.h>
  26. #include <erc_item.h>
  27. #include <i18n_utility.h>
  28. // These, being statically-defined, require specialized I18N handling. We continue to
  29. // use the _() macro so that string harvesting by the I18N framework doesn't have to be
  30. // specialized, but we don't translate on initialization and instead do it in the getters.
  31. #undef _
  32. #define _(s) s
  33. // NOTE: Avoid changing the settings key for an ERC item after it has been created
  34. ERC_ITEM ERC_ITEM::heading_connections( 0, _( "Connections" ), "" );
  35. ERC_ITEM ERC_ITEM::heading_conflicts( 0, _( "Conflicts" ), "" );
  36. ERC_ITEM ERC_ITEM::heading_misc( 0, _( "Miscellaneous" ), "" );
  37. ERC_ITEM ERC_ITEM::duplicateSheetName( ERCE_DUPLICATE_SHEET_NAME,
  38. _( "Duplicate sheet names within a given sheet" ),
  39. wxT( "duplicate_sheet_names" ) );
  40. ERC_ITEM ERC_ITEM::endpointOffGrid( ERCE_ENDPOINT_OFF_GRID,
  41. _( "Symbol pin or wire end off grid" ),
  42. wxT( "endpoint_off_grid" ) );
  43. ERC_ITEM ERC_ITEM::pinNotConnected( ERCE_PIN_NOT_CONNECTED,
  44. _( "Pin not connected" ),
  45. wxT( "pin_not_connected" ) );
  46. ERC_ITEM ERC_ITEM::pinNotDriven( ERCE_PIN_NOT_DRIVEN,
  47. _( "Input pin not driven by any Output pins" ),
  48. wxT( "pin_not_driven" ) );
  49. ERC_ITEM ERC_ITEM::powerpinNotDriven( ERCE_POWERPIN_NOT_DRIVEN,
  50. _( "Input Power pin not driven by any Output Power pins" ),
  51. wxT( "power_pin_not_driven" ) );
  52. ERC_ITEM ERC_ITEM::pinTableWarning( ERCE_PIN_TO_PIN_WARNING,
  53. _( "Conflict problem between pins" ),
  54. wxT( "pin_to_pin" ) );
  55. ERC_ITEM ERC_ITEM::pinTableError( ERCE_PIN_TO_PIN_ERROR,
  56. _( "Conflict problem between pins" ),
  57. wxT( "pin_to_pin" ) );
  58. ERC_ITEM ERC_ITEM::hierLabelMismatch( ERCE_HIERACHICAL_LABEL,
  59. _( "Mismatch between hierarchical labels and sheet pins" ),
  60. wxT( "hier_label_mismatch" ) );
  61. ERC_ITEM ERC_ITEM::noConnectConnected( ERCE_NOCONNECT_CONNECTED,
  62. _( "A pin with a \"no connection\" flag is connected" ),
  63. wxT( "no_connect_connected" ) );
  64. ERC_ITEM ERC_ITEM::noConnectDangling( ERCE_NOCONNECT_NOT_CONNECTED,
  65. _( "Unconnected \"no connection\" flag" ),
  66. wxT( "no_connect_dangling" ) );
  67. ERC_ITEM ERC_ITEM::labelDangling( ERCE_LABEL_NOT_CONNECTED,
  68. _( "Label not connected to anything" ),
  69. wxT( "label_dangling" ) );
  70. ERC_ITEM ERC_ITEM::globalLabelDangling( ERCE_GLOBLABEL,
  71. _( "Global label not connected anywhere else in the schematic" ),
  72. wxT( "global_label_dangling" ) );
  73. ERC_ITEM ERC_ITEM::similarLabels( ERCE_SIMILAR_LABELS,
  74. _( "Labels are similar (lower/upper case difference only)"),
  75. wxT( "similar_labels" ) );
  76. ERC_ITEM ERC_ITEM::differentUnitFootprint( ERCE_DIFFERENT_UNIT_FP,
  77. _( "Different footprint assigned in another unit of the symbol" ),
  78. wxT( "different_unit_footprint" ) );
  79. ERC_ITEM ERC_ITEM::differentUnitNet( ERCE_DIFFERENT_UNIT_NET,
  80. _( "Different net assigned to a shared pin in another unit of the symbol" ),
  81. wxT( "different_unit_net" ) );
  82. ERC_ITEM ERC_ITEM::busDefinitionConflict( ERCE_BUS_ALIAS_CONFLICT,
  83. _( "Conflict between bus alias definitions across schematic sheets" ),
  84. wxT( "bus_definition_conflict" ) );
  85. ERC_ITEM ERC_ITEM::multipleNetNames( ERCE_DRIVER_CONFLICT,
  86. _( "More than one name given to this bus or net" ),
  87. wxT( "multiple_net_names" ) );
  88. ERC_ITEM ERC_ITEM::netclassConflict( ERCE_NETCLASS_CONFLICT,
  89. _( "Conflicting netclass assignments" ),
  90. wxT( "conflicting_netclasses" ) );
  91. ERC_ITEM ERC_ITEM::netNotBusMember( ERCE_BUS_ENTRY_CONFLICT,
  92. _( "Net is graphically connected to a bus but not a bus member" ),
  93. wxT( "net_not_bus_member" ) );
  94. ERC_ITEM ERC_ITEM::busLabelSyntax( ERCE_BUS_LABEL_ERROR,
  95. _( "Label attached to bus item does not describe a bus" ),
  96. wxT( "bus_label_syntax" ) );
  97. ERC_ITEM ERC_ITEM::busToBusConflict( ERCE_BUS_TO_BUS_CONFLICT,
  98. _( "Buses are graphically connected but share no bus members" ),
  99. wxT( "bus_to_bus_conflict" ) );
  100. ERC_ITEM ERC_ITEM::busToNetConflict( ERCE_BUS_TO_NET_CONFLICT,
  101. _( "Invalid connection between bus and net items" ),
  102. wxT( "bus_to_net_conflict" ) );
  103. ERC_ITEM ERC_ITEM::unresolvedVariable( ERCE_UNRESOLVED_VARIABLE,
  104. _( "Unresolved text variable" ),
  105. wxT( "unresolved_variable" ) );
  106. ERC_ITEM ERC_ITEM::simulationModelIssues( ERCE_SIMULATION_MODEL,
  107. _( "SPICE model issue" ),
  108. wxT( "simulation_model_issue" ) );
  109. ERC_ITEM ERC_ITEM::wireDangling( ERCE_WIRE_DANGLING,
  110. _( "Wires not connected to anything" ),
  111. wxT( "wire_dangling" ) );
  112. ERC_ITEM ERC_ITEM::libSymbolIssues( ERCE_LIB_SYMBOL_ISSUES,
  113. _( "Library symbol issue" ),
  114. wxT( "lib_symbol_issues" ) );
  115. ERC_ITEM ERC_ITEM::unannotated( ERCE_UNANNOTATED,
  116. _( "Symbol is not annotated" ),
  117. wxT( "unannotated" ) );
  118. ERC_ITEM ERC_ITEM::extraUnits( ERCE_EXTRA_UNITS,
  119. _( "Symbol has more units than are defined" ),
  120. wxT( "extra_units" ) );
  121. ERC_ITEM ERC_ITEM::differentUnitValue( ERCE_DIFFERENT_UNIT_VALUE,
  122. _( "Units of same symbol have different values" ),
  123. wxT( "unit_value_mismatch" ) );
  124. ERC_ITEM ERC_ITEM::duplicateReference( ERCE_DUPLICATE_REFERENCE,
  125. _( "Duplicate reference designators" ),
  126. wxT( "duplicate_reference" ) );
  127. ERC_ITEM ERC_ITEM::busEntryNeeded( ERCE_BUS_ENTRY_NEEDED,
  128. _( "Bus Entry needed" ),
  129. wxT( "bus_entry_needed" ) );
  130. std::vector<std::reference_wrapper<RC_ITEM>> ERC_ITEM::allItemTypes( {
  131. ERC_ITEM::heading_connections,
  132. ERC_ITEM::pinNotConnected,
  133. ERC_ITEM::pinNotDriven,
  134. ERC_ITEM::powerpinNotDriven,
  135. ERC_ITEM::noConnectConnected,
  136. ERC_ITEM::noConnectDangling,
  137. ERC_ITEM::labelDangling,
  138. ERC_ITEM::globalLabelDangling,
  139. ERC_ITEM::wireDangling,
  140. ERC_ITEM::busEntryNeeded,
  141. ERC_ITEM::heading_conflicts,
  142. ERC_ITEM::duplicateReference,
  143. ERC_ITEM::pinTableWarning,
  144. ERC_ITEM::differentUnitValue,
  145. ERC_ITEM::differentUnitFootprint,
  146. ERC_ITEM::differentUnitNet,
  147. ERC_ITEM::duplicateSheetName,
  148. ERC_ITEM::hierLabelMismatch,
  149. ERC_ITEM::multipleNetNames,
  150. ERC_ITEM::busDefinitionConflict,
  151. ERC_ITEM::busToBusConflict,
  152. ERC_ITEM::busToNetConflict,
  153. ERC_ITEM::netNotBusMember,
  154. ERC_ITEM::heading_misc,
  155. ERC_ITEM::unannotated,
  156. ERC_ITEM::unresolvedVariable,
  157. ERC_ITEM::simulationModelIssues,
  158. ERC_ITEM::similarLabels,
  159. ERC_ITEM::busLabelSyntax,
  160. ERC_ITEM::libSymbolIssues,
  161. ERC_ITEM::extraUnits,
  162. } );
  163. std::shared_ptr<ERC_ITEM> ERC_ITEM::Create( int aErrorCode )
  164. {
  165. switch( aErrorCode )
  166. {
  167. case ERCE_DUPLICATE_SHEET_NAME: return std::make_shared<ERC_ITEM>( duplicateSheetName );
  168. case ERCE_ENDPOINT_OFF_GRID: return std::make_shared<ERC_ITEM>( endpointOffGrid );
  169. case ERCE_PIN_NOT_CONNECTED: return std::make_shared<ERC_ITEM>( pinNotConnected );
  170. case ERCE_PIN_NOT_DRIVEN: return std::make_shared<ERC_ITEM>( pinNotDriven );
  171. case ERCE_POWERPIN_NOT_DRIVEN: return std::make_shared<ERC_ITEM>( powerpinNotDriven );
  172. case ERCE_PIN_TO_PIN_WARNING: return std::make_shared<ERC_ITEM>( pinTableWarning );
  173. case ERCE_PIN_TO_PIN_ERROR: return std::make_shared<ERC_ITEM>( pinTableError );
  174. case ERCE_HIERACHICAL_LABEL: return std::make_shared<ERC_ITEM>( hierLabelMismatch );
  175. case ERCE_NOCONNECT_CONNECTED: return std::make_shared<ERC_ITEM>( noConnectConnected );
  176. case ERCE_NOCONNECT_NOT_CONNECTED: return std::make_shared<ERC_ITEM>( noConnectDangling );
  177. case ERCE_LABEL_NOT_CONNECTED: return std::make_shared<ERC_ITEM>( labelDangling );
  178. case ERCE_SIMILAR_LABELS: return std::make_shared<ERC_ITEM>( similarLabels );
  179. case ERCE_DIFFERENT_UNIT_FP: return std::make_shared<ERC_ITEM>( differentUnitFootprint );
  180. case ERCE_DIFFERENT_UNIT_NET: return std::make_shared<ERC_ITEM>( differentUnitNet );
  181. case ERCE_BUS_ALIAS_CONFLICT: return std::make_shared<ERC_ITEM>( busDefinitionConflict );
  182. case ERCE_DRIVER_CONFLICT: return std::make_shared<ERC_ITEM>( multipleNetNames );
  183. case ERCE_BUS_ENTRY_CONFLICT: return std::make_shared<ERC_ITEM>( netNotBusMember );
  184. case ERCE_BUS_LABEL_ERROR: return std::make_shared<ERC_ITEM>( busLabelSyntax );
  185. case ERCE_BUS_TO_BUS_CONFLICT: return std::make_shared<ERC_ITEM>( busToBusConflict );
  186. case ERCE_BUS_TO_NET_CONFLICT: return std::make_shared<ERC_ITEM>( busToNetConflict );
  187. case ERCE_NETCLASS_CONFLICT: return std::make_shared<ERC_ITEM>( netclassConflict );
  188. case ERCE_GLOBLABEL: return std::make_shared<ERC_ITEM>( globalLabelDangling );
  189. case ERCE_UNRESOLVED_VARIABLE: return std::make_shared<ERC_ITEM>( unresolvedVariable );
  190. case ERCE_SIMULATION_MODEL: return std::make_shared<ERC_ITEM>( simulationModelIssues );
  191. case ERCE_WIRE_DANGLING: return std::make_shared<ERC_ITEM>( wireDangling );
  192. case ERCE_LIB_SYMBOL_ISSUES: return std::make_shared<ERC_ITEM>( libSymbolIssues );
  193. case ERCE_UNANNOTATED: return std::make_shared<ERC_ITEM>( unannotated );
  194. case ERCE_EXTRA_UNITS: return std::make_shared<ERC_ITEM>( extraUnits );
  195. case ERCE_DIFFERENT_UNIT_VALUE: return std::make_shared<ERC_ITEM>( differentUnitValue );
  196. case ERCE_DUPLICATE_REFERENCE: return std::make_shared<ERC_ITEM>( duplicateReference );
  197. case ERCE_BUS_ENTRY_NEEDED: return std::make_shared<ERC_ITEM>( busEntryNeeded );
  198. case ERCE_UNSPECIFIED:
  199. default:
  200. wxFAIL_MSG( "Unknown ERC error code" );
  201. return nullptr;
  202. }
  203. return nullptr;
  204. }