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.

233 lines
7.5 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2009-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.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_MARKER_BASE_H
  25. #define _CLASS_MARKER_BASE_H
  26. #include <class_drc_item.h>
  27. #include <gr_basic.h>
  28. /* Marker are mainly used to show a DRC or ERC error or warning
  29. */
  30. class MARKER_BASE
  31. {
  32. public:
  33. enum TYPEMARKER { // Marker type: can be used to identify the purpose of the marker
  34. MARKER_UNSPEC,
  35. MARKER_ERC,
  36. MARKER_PCB,
  37. MARKER_SIMUL
  38. };
  39. enum MARKER_SEVERITY { // Severity of the marker: this is the level of error
  40. MARKER_SEVERITY_UNSPEC,
  41. MARKER_SEVERITY_INFO,
  42. MARKER_SEVERITY_WARNING,
  43. MARKER_SEVERITY_ERROR
  44. };
  45. wxPoint m_Pos; ///< position of the marker
  46. protected:
  47. TYPEMARKER m_MarkerType; ///< The type of marker (useful to filter markers)
  48. MARKER_SEVERITY m_ErrorLevel; ///< Specify the severity of the error
  49. COLOR4D m_Color; ///< color
  50. EDA_RECT m_ShapeBoundingBox; ///< Bounding box of the graphic symbol, relative
  51. ///< to the position of the shape, used for Hit
  52. ///< Tests
  53. int m_ScalingFactor; ///< Scaling factor for m_Size and m_Corners (can
  54. ///< set the physical size
  55. DRC_ITEM m_drc;
  56. void init();
  57. public:
  58. MARKER_BASE();
  59. /**
  60. * Constructor
  61. * @param aErrorCode The categorizing identifier for an error
  62. * @param aMarkerPos The position of the MARKER on the BOARD
  63. * @param aText Text describing the first of two objects
  64. * @param aPos The position of the first of two objects
  65. * @param bText Text describing the second of the two conflicting objects
  66. * @param bPos The position of the second of two objects
  67. */
  68. MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
  69. const wxString& aText, const wxPoint& aPos,
  70. const wxString& bText, const wxPoint& bPos );
  71. /**
  72. * Constructor
  73. * @param aErrorCode The categorizing identifier for an error
  74. * @param aMarkerPos The position of the MARKER on the BOARD
  75. * @param aText Text describing the object
  76. * @param aPos The position of the object
  77. */
  78. MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
  79. const wxString& aText, const wxPoint& aPos );
  80. /**
  81. * Contructor
  82. * makes a copy of \a aMarker but does not copy the DRC_ITEM.
  83. *
  84. * @param aMarker The marker to copy.
  85. */
  86. MARKER_BASE( const MARKER_BASE& aMarker );
  87. ~MARKER_BASE();
  88. /**
  89. * Function DrawMarker
  90. * draws the shape is the polygon defined in m_Corners (array of wxPoints).
  91. */
  92. void DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
  93. const wxPoint& aOffset );
  94. /**
  95. * Function GetPos
  96. * returns the position of this MARKER, const.
  97. */
  98. const wxPoint& GetPos() const
  99. {
  100. return m_Pos;
  101. }
  102. /**
  103. * Function SetColor
  104. * Set the color of this marker
  105. */
  106. void SetColor( COLOR4D aColor )
  107. {
  108. m_Color = aColor;
  109. }
  110. /**
  111. * accessors to set/get error levels (warning, error, fatal error..)
  112. */
  113. void SetErrorLevel( MARKER_SEVERITY aErrorLevel )
  114. {
  115. m_ErrorLevel = aErrorLevel;
  116. }
  117. MARKER_SEVERITY GetErrorLevel() const
  118. {
  119. return m_ErrorLevel;
  120. }
  121. /** accessors to set/get marker type (DRC, ERC, or other)
  122. */
  123. void SetMarkerType( enum TYPEMARKER aMarkerType )
  124. {
  125. m_MarkerType = aMarkerType;
  126. }
  127. enum TYPEMARKER GetMarkerType() const
  128. {
  129. return m_MarkerType;
  130. }
  131. /**
  132. * Function SetData
  133. * fills in all the reportable data associated with a MARKER.
  134. * @param aErrorCode The categorizing identifier for an error
  135. * @param aMarkerPos The position of the MARKER on the BOARD
  136. * @param aText Text describing the first of two objects
  137. * @param aPos The position of the first of two objects
  138. * @param bText Text describing the second of the two conflicting objects
  139. * @param bPos The position of the second of two objects
  140. */
  141. void SetData( int aErrorCode, const wxPoint& aMarkerPos,
  142. const wxString& aText, const wxPoint& aPos,
  143. const wxString& bText, const wxPoint& bPos );
  144. /**
  145. * Function SetData
  146. * fills in all the reportable data associated with a MARKER.
  147. * @param aErrorCode The categorizing identifier for an error
  148. * @param aMarkerPos The position of the MARKER on the BOARD
  149. * @param aText Text describing the object
  150. * @param aPos The position of the object
  151. */
  152. void SetData( int aErrorCode, const wxPoint& aMarkerPos,
  153. const wxString& aText, const wxPoint& aPos );
  154. /**
  155. * Function SetAuxiliaryData
  156. * initialize data for the second (auxiliary) item
  157. * @param aAuxiliaryText = the second text (main text) concerning the second schematic or
  158. * board item
  159. * @param aAuxiliaryPos = position the second item
  160. */
  161. void SetAuxiliaryData( const wxString& aAuxiliaryText, const wxPoint& aAuxiliaryPos )
  162. {
  163. m_drc.SetAuxiliaryData( aAuxiliaryText, aAuxiliaryPos );
  164. }
  165. void SetShowNoCoordinate()
  166. {
  167. m_drc.SetShowNoCoordinate();
  168. }
  169. /**
  170. * Function GetReporter
  171. * returns the DRC_ITEM held within this MARKER so that its
  172. * interface may be used.
  173. * @return const& DRC_ITEM
  174. */
  175. const DRC_ITEM& GetReporter() const
  176. {
  177. return m_drc;
  178. }
  179. /**
  180. * Function DisplayMarkerInfo
  181. * displays the full info of this marker, in a HTML window.
  182. */
  183. void DisplayMarkerInfo( EDA_DRAW_FRAME* aFrame );
  184. /**
  185. * Function HitTestMarker
  186. * tests if the given wxPoint is within the bounds of this object.
  187. * @param ref_pos A wxPoint to test
  188. * @return bool - true if a hit, else false
  189. */
  190. bool HitTestMarker( const wxPoint& ref_pos ) const;
  191. /**
  192. * Function GetBoundingBoxMarker
  193. * returns the orthogonal, bounding box of this object for display purposes.
  194. * This box should be an enclosing perimeter for visible components of this
  195. * object, and the units should be in the pcb or schematic coordinate system.
  196. * It is OK to overestimate the size by a few counts.
  197. */
  198. EDA_RECT GetBoundingBoxMarker() const;
  199. };
  200. #endif // _CLASS_MARKER_BASE_H