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.

150 lines
4.6 KiB

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 <trigo.h>
  33. #include <msgpanel.h>
  34. #include <bitmaps.h>
  35. #include <base_units.h>
  36. #include <pcbnew.h>
  37. #include <class_marker_pcb.h>
  38. #include <layers_id_colors_and_visibility.h>
  39. /// Adjust the actual size of markers, when using default shape
  40. #define SCALING_FACTOR Mils2iu( 3 )
  41. MARKER_PCB::MARKER_PCB( BOARD_ITEM* aParent ) :
  42. BOARD_ITEM( aParent, PCB_MARKER_T ),
  43. MARKER_BASE(), m_item( nullptr )
  44. {
  45. m_Color = WHITE;
  46. m_ScalingFactor = SCALING_FACTOR;
  47. }
  48. MARKER_PCB::MARKER_PCB( EDA_UNITS_T aUnits, int aErrorCode, const wxPoint& aMarkerPos,
  49. BOARD_ITEM* aItem, const wxPoint& aPos,
  50. BOARD_ITEM* bItem, const wxPoint& bPos ) :
  51. BOARD_ITEM( nullptr, PCB_MARKER_T ), // parent set during BOARD::Add()
  52. MARKER_BASE( aUnits, aErrorCode, aMarkerPos, aItem, aPos, bItem, bPos ), m_item( nullptr )
  53. {
  54. m_Color = WHITE;
  55. m_ScalingFactor = SCALING_FACTOR;
  56. }
  57. MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
  58. const wxString& aText, const wxPoint& aPos,
  59. const wxString& bText, const wxPoint& bPos ) :
  60. BOARD_ITEM( nullptr, PCB_MARKER_T ), // parent set during BOARD::Add()
  61. MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos, bText, bPos ), m_item( nullptr )
  62. {
  63. m_Color = WHITE;
  64. m_ScalingFactor = SCALING_FACTOR;
  65. }
  66. /* destructor */
  67. MARKER_PCB::~MARKER_PCB()
  68. {
  69. }
  70. /* tests to see if this object is on the given layer.
  71. * DRC markers are not really on a copper layer, but
  72. * MARKER_PCB::IsOnCopperLayer return true if aLayer is a cooper layer,
  73. * because this test is often used to locad a marker
  74. * param aLayer The layer to test for.
  75. * return bool - true if on given layer, else false.
  76. */
  77. bool MARKER_PCB::IsOnLayer( PCB_LAYER_ID aLayer ) const
  78. {
  79. return IsCopperLayer( aLayer );
  80. }
  81. void MARKER_PCB::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
  82. {
  83. wxString errorTxt, txtA, txtB;
  84. aList.emplace_back( MSG_PANEL_ITEM( _( "Type" ), _( "Marker" ), DARKCYAN ) );
  85. errorTxt.Printf( _( "ErrType (%d)- %s:" ), m_drc.GetErrorCode(), m_drc.GetErrorText() );
  86. aList.emplace_back( MSG_PANEL_ITEM( errorTxt, wxEmptyString, RED ) );
  87. txtA.Printf( wxT( "%s: %s" ), DRC_ITEM::ShowCoord( aUnits, m_drc.GetPointA() ), m_drc.GetTextA() );
  88. if( m_drc.HasSecondItem() )
  89. txtB.Printf( wxT( "%s: %s" ), DRC_ITEM::ShowCoord( aUnits, m_drc.GetPointB() ), m_drc.GetTextB() );
  90. aList.emplace_back( MSG_PANEL_ITEM( txtA, txtB, DARKBROWN ) );
  91. }
  92. void MARKER_PCB::Rotate(const wxPoint& aRotCentre, double aAngle)
  93. {
  94. RotatePoint( &m_Pos, aRotCentre, aAngle );
  95. }
  96. void MARKER_PCB::Flip(const wxPoint& aCentre )
  97. {
  98. m_Pos.y = aCentre.y - (m_Pos.y - aCentre.y);
  99. }
  100. wxString MARKER_PCB::GetSelectMenuText( EDA_UNITS_T aUnits ) const
  101. {
  102. return wxString::Format( _( "Marker @(%s, %s)" ),
  103. MessageTextFromValue( aUnits, m_Pos.x ),
  104. MessageTextFromValue( aUnits, m_Pos.y ) );
  105. }
  106. BITMAP_DEF MARKER_PCB::GetMenuImage() const
  107. {
  108. return drc_xpm;
  109. }
  110. void MARKER_PCB::ViewGetLayers( int aLayers[], int& aCount ) const
  111. {
  112. aCount = 1;
  113. aLayers[0] = LAYER_DRC;
  114. }
  115. const EDA_RECT MARKER_PCB::GetBoundingBox() const
  116. {
  117. return EDA_RECT( m_Pos, wxSize( 1300000, 1300000 ) );
  118. }