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.

163 lines
6.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007 KiCad Developers, see change_log.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. /******************************************************************/
  24. /* class_drc_erc_item.cpp - DRC_ITEM class functions for eeschema */
  25. /******************************************************************/
  26. #include <fctsys.h>
  27. #include <common.h>
  28. #include <drc_item.h>
  29. #include <erc.h>
  30. #include <base_units.h>
  31. wxString DRC_ITEM::GetErrorText() const
  32. {
  33. switch( m_ErrorCode )
  34. {
  35. case ERCE_UNSPECIFIED:
  36. return wxString( _("ERC err unspecified") );
  37. case ERCE_DUPLICATE_SHEET_NAME:
  38. return wxString( _("Duplicate sheet names within a given sheet") );
  39. case ERCE_PIN_NOT_CONNECTED:
  40. return wxString( _("Pin not connected (use a \"no connection\" flag to suppress this error)") );
  41. case ERCE_PIN_NOT_DRIVEN:
  42. return wxString( _( "Pin connected to other pins, but not driven by any pin" ) );
  43. case ERCE_PIN_TO_PIN_WARNING:
  44. return wxString( _("Conflict problem between pins. Severity: warning") );
  45. case ERCE_PIN_TO_PIN_ERROR:
  46. return wxString( _("Conflict problem between pins. Severity: error") );
  47. case ERCE_HIERACHICAL_LABEL:
  48. return wxString( _("Mismatch between hierarchical labels and pins sheets") );
  49. case ERCE_NOCONNECT_CONNECTED:
  50. return wxString( _("A pin with a \"no connection\" flag is connected") );
  51. case ERCE_NOCONNECT_NOT_CONNECTED:
  52. return wxString( _("A \"no connection\" flag is not connected to anything") );
  53. case ERCE_LABEL_NOT_CONNECTED:
  54. return wxString( _("Label not connected anywhere else in the schematic") );
  55. case ERCE_SIMILAR_LABELS:
  56. return wxString( _("Labels are similar (lower/upper case difference only)" ) );
  57. case ERCE_SIMILAR_GLBL_LABELS:
  58. return wxString( _("Global labels are similar (lower/upper case difference only)" ) );
  59. case ERCE_DIFFERENT_UNIT_FP:
  60. return wxString( _("Different footprint assigned in another unit of the same component" ) );
  61. case ERCE_DIFFERENT_UNIT_NET:
  62. return wxString( _("Different net assigned to a shared pin in another unit of the same component" ) );
  63. case ERCE_BUS_ALIAS_CONFLICT:
  64. return wxString( _("Conflict between bus alias definitions across schematic sheets") );
  65. case ERCE_DRIVER_CONFLICT:
  66. return wxString( _( "More than one name given to this bus or net" ) );
  67. case ERCE_BUS_ENTRY_CONFLICT:
  68. return wxString( _( "Net is graphically connected to a bus but not a bus member" ) );
  69. case ERCE_BUS_LABEL_ERROR:
  70. return wxString( _( "Label attached to bus item does not describe a bus" ) );
  71. case ERCE_BUS_TO_BUS_CONFLICT:
  72. return wxString( _( "No nets are shared between two bus items" ) );
  73. case ERCE_BUS_TO_NET_CONFLICT:
  74. return wxString( _( "Invalid connection between bus and net items" ) );
  75. case ERCE_GLOBLABEL:
  76. return wxString( _( "Global label not connected anywhere else in the schematic" ) );
  77. default:
  78. wxFAIL_MSG( "Missing ERC error description" );
  79. return wxString( wxT("Unknown.") );
  80. }
  81. }
  82. wxString DRC_ITEM::ShowCoord( EDA_UNITS aUnits, const wxPoint& aPos )
  83. {
  84. return wxString::Format( "@(%s, %s)",
  85. MessageTextFromValue( aUnits, aPos.x ),
  86. MessageTextFromValue( aUnits, aPos.y ) );
  87. }
  88. wxString DRC_ITEM::ShowHtml( EDA_UNITS aUnits ) const
  89. {
  90. wxString mainText = m_MainText;
  91. // a wxHtmlWindows does not like < and > in the text to display
  92. // because these chars have a special meaning in html
  93. mainText.Replace( wxT("<"), wxT("&lt;") );
  94. mainText.Replace( wxT(">"), wxT("&gt;") );
  95. wxString errText = GetErrorText();
  96. errText.Replace( wxT("<"), wxT("&lt;") );
  97. errText.Replace( wxT(">"), wxT("&gt;") );
  98. wxColour hrefColour = wxSystemSettings::GetColour( wxSYS_COLOUR_HOTLIGHT );
  99. if( m_noCoordinate )
  100. {
  101. // omit the coordinate, a NETCLASS has no location
  102. return wxString::Format( "<p><b>%s</b><br>&nbsp;&nbsp; %s", errText, mainText );
  103. }
  104. else if( m_hasSecondItem )
  105. {
  106. wxString auxText = m_AuxiliaryText;
  107. auxText.Replace( wxT("<"), wxT("&lt;") );
  108. auxText.Replace( wxT(">"), wxT("&gt;") );
  109. // an html fragment for the entire message in the listbox. feel free
  110. // to add color if you want:
  111. return wxString::Format( "<p><b>%s</b><br>&nbsp;&nbsp; <font color='%s'><a href=''>%s</a></font>: %s<br>&nbsp;&nbsp; %s: %s",
  112. errText,
  113. hrefColour.GetAsString( wxC2S_HTML_SYNTAX ),
  114. ShowCoord( aUnits, m_MainPosition ),
  115. mainText,
  116. ShowCoord( aUnits, m_AuxiliaryPosition ),
  117. auxText );
  118. }
  119. else
  120. {
  121. return wxString::Format( "<p><b>%s</b><br>&nbsp;&nbsp; <font color='%s'><a href=''>%s</a></font>: %s",
  122. errText,
  123. hrefColour.GetAsString( wxC2S_HTML_SYNTAX ),
  124. ShowCoord( aUnits, m_MainPosition ),
  125. mainText );
  126. }
  127. }
  128. wxString DRC_ITEM::ShowReport( EDA_UNITS aUnits ) const
  129. {
  130. if( m_hasSecondItem )
  131. {
  132. return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ),
  133. m_ErrorCode,
  134. GetErrorText(),
  135. ShowCoord( aUnits, m_MainPosition ),
  136. m_MainText,
  137. ShowCoord( aUnits, m_AuxiliaryPosition ),
  138. m_AuxiliaryText );
  139. }
  140. else
  141. {
  142. return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n" ),
  143. m_ErrorCode,
  144. GetErrorText(),
  145. ShowCoord( aUnits, m_MainPosition ),
  146. m_MainText );
  147. }
  148. }