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.

144 lines
4.3 KiB

18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
14 years ago
  1. /**
  2. * @file class_marker_pcb.cpp
  3. * @brief Functions to handle markers used to show something (usually a drc problem)
  4. */
  5. /*
  6. * This program source code file is part of KiCad, a free EDA CAD application.
  7. *
  8. * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
  9. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  10. * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * as published by the Free Software Foundation; either version 2
  15. * of the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, you may find one here:
  24. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  25. * or you may search the http://www.gnu.org website for the version 2 license,
  26. * or you may write to the Free Software Foundation, Inc.,
  27. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  28. */
  29. #include <fctsys.h>
  30. #include <gr_basic.h>
  31. #include <class_drawpanel.h>
  32. #include <wxstruct.h>
  33. #include <trigo.h>
  34. #include <msgpanel.h>
  35. #include <pcbnew.h>
  36. #include <class_marker_pcb.h>
  37. #include <layers_id_colors_and_visibility.h>
  38. /// Adjust the actual size of markers, when using default shape
  39. #define SCALING_FACTOR DMils2iu( 30 )
  40. MARKER_PCB::MARKER_PCB( BOARD_ITEM* aParent ) :
  41. BOARD_ITEM( aParent, PCB_MARKER_T ),
  42. MARKER_BASE(), m_item( NULL )
  43. {
  44. m_Color = WHITE;
  45. m_ScalingFactor = SCALING_FACTOR;
  46. }
  47. MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
  48. const wxString& aText, const wxPoint& aPos,
  49. const wxString& bText, const wxPoint& bPos ) :
  50. BOARD_ITEM( NULL, PCB_MARKER_T ), // parent set during BOARD::Add()
  51. MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos, bText, bPos ), m_item( NULL )
  52. {
  53. m_Color = WHITE;
  54. m_ScalingFactor = SCALING_FACTOR;
  55. }
  56. MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
  57. const wxString& aText, const wxPoint& aPos ) :
  58. BOARD_ITEM( NULL, PCB_MARKER_T ), // parent set during BOARD::Add()
  59. MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos ), m_item( NULL )
  60. {
  61. m_Color = WHITE;
  62. m_ScalingFactor = SCALING_FACTOR;
  63. }
  64. /* destructor */
  65. MARKER_PCB::~MARKER_PCB()
  66. {
  67. }
  68. /* tests to see if this object is on the given layer.
  69. * DRC markers are not really on a copper layer, but
  70. * MARKER_PCB::IsOnCopperLayer return true if aLayer is a cooper layer,
  71. * because this test is often used to locad a marker
  72. * param aLayer The layer to test for.
  73. * return bool - true if on given layer, else false.
  74. */
  75. bool MARKER_PCB::IsOnLayer( LAYER_ID aLayer ) const
  76. {
  77. return IsCopperLayer( aLayer );
  78. }
  79. void MARKER_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
  80. {
  81. const DRC_ITEM& rpt = m_drc;
  82. aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Marker" ), DARKCYAN ) );
  83. wxString errorTxt;
  84. errorTxt.Printf( _( "ErrType (%d)- %s:" ),
  85. rpt.GetErrorCode(),
  86. GetChars( rpt.GetErrorText() ) );
  87. aList.push_back( MSG_PANEL_ITEM( errorTxt, wxEmptyString, RED ) );
  88. wxString txtA;
  89. txtA << DRC_ITEM::ShowCoord( rpt.GetPointA() ) << wxT( ": " ) << rpt.GetTextA();
  90. wxString txtB;
  91. if ( rpt.HasSecondItem() )
  92. txtB << DRC_ITEM::ShowCoord( rpt.GetPointB() ) << wxT( ": " ) << rpt.GetTextB();
  93. aList.push_back( MSG_PANEL_ITEM( txtA, txtB, DARKBROWN ) );
  94. }
  95. void MARKER_PCB::Rotate(const wxPoint& aRotCentre, double aAngle)
  96. {
  97. RotatePoint( &m_Pos, aRotCentre, aAngle );
  98. }
  99. void MARKER_PCB::Flip(const wxPoint& aCentre )
  100. {
  101. m_Pos.y = aCentre.y - (m_Pos.y - aCentre.y);
  102. }
  103. wxString MARKER_PCB::GetSelectMenuText() const
  104. {
  105. wxString text;
  106. text.Printf( _( "Marker @(%d,%d)" ), GetPos().x, GetPos().y );
  107. return text;
  108. }
  109. void MARKER_PCB::ViewGetLayers( int aLayers[], int& aCount ) const
  110. {
  111. aCount = 1;
  112. aLayers[0] = ITEM_GAL_LAYER( DRC_VISIBLE );
  113. }