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.

198 lines
6.1 KiB

  1. /***************************************/
  2. /* Markers: used to show a drc problem */
  3. /***************************************/
  4. #ifndef _CLASS_MARKER_BASE_H
  5. #define _CLASS_MARKER_BASE_H
  6. #include <class_drc_item.h>
  7. #include <gr_basic.h>
  8. class MARKER_BASE
  9. {
  10. public:
  11. wxPoint m_Pos; ///< position of the marker
  12. protected:
  13. int m_MarkerType; ///< Can be used as a flag
  14. EDA_COLOR_T m_Color; ///< color
  15. EDA_RECT m_ShapeBoundingBox; ///< Bounding box of the graphic symbol, relative
  16. ///< to the position of the shape, used for Hit
  17. ///< Tests
  18. int m_ScalingFactor; ///< Scaling factor for m_Size and m_Corners (can
  19. ///< set the physical size
  20. DRC_ITEM m_drc;
  21. void init();
  22. public:
  23. MARKER_BASE();
  24. /**
  25. * Constructor
  26. * @param aErrorCode The categorizing identifier for an error
  27. * @param aMarkerPos The position of the MARKER on the BOARD
  28. * @param aText Text describing the first of two objects
  29. * @param aPos The position of the first of two objects
  30. * @param bText Text describing the second of the two conflicting objects
  31. * @param bPos The position of the second of two objects
  32. */
  33. MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
  34. const wxString& aText, const wxPoint& aPos,
  35. const wxString& bText, const wxPoint& bPos );
  36. /**
  37. * Constructor
  38. * @param aErrorCode The categorizing identifier for an error
  39. * @param aMarkerPos The position of the MARKER on the BOARD
  40. * @param aText Text describing the object
  41. * @param aPos The position of the object
  42. */
  43. MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
  44. const wxString& aText, const wxPoint& aPos );
  45. /**
  46. * Contructor
  47. * makes a copy of \a aMarker but does not copy the DRC_ITEM.
  48. *
  49. * @param aMarker The marker to copy.
  50. */
  51. MARKER_BASE( const MARKER_BASE& aMarker );
  52. ~MARKER_BASE();
  53. /**
  54. * Function DrawMarker
  55. * draws the shape is the polygon defined in m_Corners (array of wxPoints).
  56. */
  57. void DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
  58. const wxPoint& aOffset );
  59. /**
  60. * Function GetPos
  61. * returns the position of this MARKER, const.
  62. */
  63. const wxPoint& GetPos() const
  64. {
  65. return m_Pos;
  66. }
  67. /**
  68. * Function SetColor
  69. * Set the color of this marker
  70. */
  71. void SetColor( EDA_COLOR_T aColor )
  72. {
  73. m_Color = aColor;
  74. }
  75. /**
  76. * Function to set/get error levels (warning, fatal ..)
  77. * this value is stored in m_MarkerType
  78. */
  79. void SetErrorLevel( int aErrorLevel )
  80. {
  81. m_MarkerType &= ~0xFF00;
  82. aErrorLevel &= 0xFF;
  83. m_MarkerType |= aErrorLevel << 8;
  84. }
  85. int GetErrorLevel() const
  86. {
  87. return (m_MarkerType >> 8) & 0xFF;
  88. }
  89. /** Functions to set/get marker type (DRC, ERC, or other)
  90. * this value is stored in m_MarkerType
  91. */
  92. void SetMarkerType( int aMarkerType )
  93. {
  94. m_MarkerType &= ~0xFF;
  95. aMarkerType &= 0xFF;
  96. m_MarkerType |= aMarkerType;
  97. }
  98. int GetMarkerType() const
  99. {
  100. return m_MarkerType & 0xFF;
  101. }
  102. /**
  103. * Function SetData
  104. * fills in all the reportable data associated with a MARKER.
  105. * @param aErrorCode The categorizing identifier for an error
  106. * @param aMarkerPos The position of the MARKER on the BOARD
  107. * @param aText Text describing the first of two objects
  108. * @param aPos The position of the first of two objects
  109. * @param bText Text describing the second of the two conflicting objects
  110. * @param bPos The position of the second of two objects
  111. */
  112. void SetData( int aErrorCode, const wxPoint& aMarkerPos,
  113. const wxString& aText, const wxPoint& aPos,
  114. const wxString& bText, const wxPoint& bPos );
  115. /**
  116. * Function SetData
  117. * fills in all the reportable data associated with a MARKER.
  118. * @param aErrorCode The categorizing identifier for an error
  119. * @param aMarkerPos The position of the MARKER on the BOARD
  120. * @param aText Text describing the object
  121. * @param aPos The position of the object
  122. */
  123. void SetData( int aErrorCode, const wxPoint& aMarkerPos,
  124. const wxString& aText, const wxPoint& aPos );
  125. /**
  126. * Function SetAuxiliaryData
  127. * initialize data for the second (auxiliary) item
  128. * @param aAuxiliaryText = the second text (main text) concerning the second schematic or
  129. * board item
  130. * @param aAuxiliaryPos = position the second item
  131. */
  132. void SetAuxiliaryData( const wxString& aAuxiliaryText, const wxPoint& aAuxiliaryPos )
  133. {
  134. m_drc.SetAuxiliaryData( aAuxiliaryText, aAuxiliaryPos );
  135. }
  136. void SetShowNoCoordinate()
  137. {
  138. m_drc.SetShowNoCoordinate();
  139. }
  140. /**
  141. * Function GetReporter
  142. * returns the DRC_ITEM held within this MARKER so that its
  143. * interface may be used.
  144. * @return const& DRC_ITEM
  145. */
  146. const DRC_ITEM& GetReporter() const
  147. {
  148. return m_drc;
  149. }
  150. /**
  151. * Function DisplayMarkerInfo
  152. * displays the full info of this marker, in a HTML window.
  153. */
  154. void DisplayMarkerInfo( EDA_DRAW_FRAME* aFrame );
  155. /**
  156. * Function HitTestMarker
  157. * tests if the given wxPoint is within the bounds of this object.
  158. * @param ref_pos A wxPoint to test
  159. * @return bool - true if a hit, else false
  160. */
  161. bool HitTestMarker( const wxPoint& ref_pos ) const;
  162. /**
  163. * Function GetBoundingBoxMarker
  164. * returns the orthogonal, bounding box of this object for display purposes.
  165. * This box should be an enclosing perimeter for visible components of this
  166. * object, and the units should be in the pcb or schematic coordinate system.
  167. * It is OK to overestimate the size by a few counts.
  168. */
  169. EDA_RECT GetBoundingBoxMarker() const;
  170. };
  171. #endif // _CLASS_MARKER_BASE_H