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.

187 lines
3.9 KiB

  1. /*******************************************/
  2. /* Schematic marker object implementation. */
  3. /*******************************************/
  4. #include "fctsys.h"
  5. #include "wxstruct.h"
  6. #include "class_drawpanel.h"
  7. #include "trigo.h"
  8. #include "general.h"
  9. #include "sch_marker.h"
  10. #include "erc.h"
  11. /* Marker are mainly used to show an ERC error
  12. * but they could be used to give a specific info
  13. */
  14. const wxChar* NameMarqueurType[] =
  15. {
  16. wxT( "" ),
  17. wxT( "ERC" ),
  18. wxT( "PCB" ),
  19. wxT( "SIMUL" ),
  20. wxT( "?????" )
  21. };
  22. /**************************/
  23. /* class SCH_MARKER */
  24. /**************************/
  25. SCH_MARKER::SCH_MARKER() : SCH_ITEM( NULL, SCH_MARKER_T ), MARKER_BASE()
  26. {
  27. }
  28. SCH_MARKER::SCH_MARKER( const wxPoint& pos, const wxString& text ) :
  29. SCH_ITEM( NULL, SCH_MARKER_T ),
  30. MARKER_BASE( 0, pos, text, pos )
  31. {
  32. }
  33. SCH_MARKER::~SCH_MARKER()
  34. {
  35. }
  36. EDA_ITEM* SCH_MARKER::doClone() const
  37. {
  38. return new SCH_MARKER( *this );
  39. }
  40. #if defined(DEBUG)
  41. void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const
  42. {
  43. // for now, make it look like XML:
  44. NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
  45. << GetPos() << "/>\n";
  46. }
  47. #endif
  48. /**
  49. * Function Save (do nothing : markers are no more saved in files )
  50. * writes the data structures for this object out to a FILE in "*.brd" format.
  51. * @param aFile The FILE to write to.
  52. * @return bool - true if success writing else false.
  53. */
  54. bool SCH_MARKER::Save( FILE* aFile ) const
  55. {
  56. return true;
  57. }
  58. void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
  59. const wxPoint& aOffset, int aDrawMode, int aColor )
  60. {
  61. EDA_Colors color = (EDA_Colors) m_Color;
  62. EDA_Colors tmp = color;
  63. if( GetMarkerType() == MARK_ERC )
  64. {
  65. color = ( GetErrorLevel() == WAR ) ?
  66. (EDA_Colors) g_LayerDescr.LayerColor[LAYER_ERC_WARN] :
  67. (EDA_Colors) g_LayerDescr.LayerColor[LAYER_ERC_ERR];
  68. }
  69. if( aColor < 0 )
  70. m_Color = color;
  71. else
  72. m_Color = (EDA_Colors) aColor;
  73. DrawMarker( aPanel, aDC, aDrawMode, aOffset );
  74. m_Color = tmp;
  75. }
  76. bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, wxPoint * aFindLocation )
  77. {
  78. if( !SCH_ITEM::Matches( m_drc.GetMainText(), aSearchData ) )
  79. {
  80. if( SCH_ITEM::Matches( m_drc.GetAuxiliaryText(), aSearchData ) )
  81. {
  82. if( aFindLocation )
  83. *aFindLocation = m_Pos;
  84. return true;
  85. }
  86. return false;
  87. }
  88. if( aFindLocation )
  89. *aFindLocation = m_Pos;
  90. return true;
  91. }
  92. /**
  93. * Function GetBoundingBox
  94. * returns the orthogonal, bounding box of this object for display purposes.
  95. * This box should be an enclosing perimeter for visible components of this
  96. * object, and the units should be in the pcb or schematic coordinate system.
  97. * It is OK to overestimate the size by a few counts.
  98. */
  99. EDA_RECT SCH_MARKER::GetBoundingBox() const
  100. {
  101. return GetBoundingBoxMarker();
  102. }
  103. void SCH_MARKER::DisplayInfo( EDA_DRAW_FRAME* aFrame )
  104. {
  105. if( aFrame == NULL )
  106. return;
  107. wxString msg;
  108. aFrame->ClearMsgPanel();
  109. aFrame->AppendMsgPanel( _( "Electronics rule check error" ),
  110. GetReporter().GetErrorText(), DARKRED );
  111. }
  112. void SCH_MARKER::Rotate( wxPoint rotationPoint )
  113. {
  114. RotatePoint( &m_Pos, rotationPoint, 900 );
  115. }
  116. void SCH_MARKER::Mirror_X( int aXaxis_position )
  117. {
  118. m_Pos.y -= aXaxis_position;
  119. m_Pos.y = -m_Pos.y;
  120. m_Pos.y += aXaxis_position;
  121. }
  122. void SCH_MARKER::Mirror_Y( int aYaxis_position )
  123. {
  124. m_Pos.x -= aYaxis_position;
  125. m_Pos.x = -m_Pos.x;
  126. m_Pos.x += aYaxis_position;
  127. }
  128. bool SCH_MARKER::IsSelectStateChanged( const wxRect& aRect )
  129. {
  130. bool previousState = IsSelected();
  131. if( aRect.Contains( m_Pos ) )
  132. m_Flags |= SELECTED;
  133. else
  134. m_Flags &= ~SELECTED;
  135. return previousState != IsSelected();
  136. }
  137. bool SCH_MARKER::doHitTest( const wxPoint& aPoint, int aAccuracy ) const
  138. {
  139. return HitTestMarker( aPoint );
  140. }