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.

131 lines
3.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2009-2018 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
  5. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.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 PCB_MARKER_H
  25. #define PCB_MARKER_H
  26. #include <board_item.h>
  27. #include <rc_item.h>
  28. #include <marker_base.h>
  29. class DRC_ITEM;
  30. // Coordinates count for the basic shape marker
  31. #define MARKER_SHAPE_POINT_COUNT 9
  32. class MSG_PANEL_ITEM;
  33. class PCB_MARKER : public BOARD_ITEM, public MARKER_BASE
  34. {
  35. public:
  36. PCB_MARKER( std::shared_ptr<RC_ITEM> aItem, const VECTOR2I& aPos, int aLayer = F_Cu );
  37. ~PCB_MARKER();
  38. static inline bool ClassOf( const EDA_ITEM* aItem )
  39. {
  40. return aItem && PCB_MARKER_T == aItem->Type();
  41. }
  42. const KIID GetUUID() const override { return m_Uuid; }
  43. wxString Serialize() const;
  44. static PCB_MARKER* Deserialize( const wxString& data );
  45. void Move( const VECTOR2I& aMoveVector ) override
  46. {
  47. m_Pos += aMoveVector;
  48. }
  49. void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
  50. void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
  51. VECTOR2I GetPosition() const override { return m_Pos; }
  52. void SetPosition( const VECTOR2I& aPos ) override { m_Pos = aPos; }
  53. VECTOR2I GetCenter() const override
  54. {
  55. return GetPosition();
  56. }
  57. bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
  58. {
  59. if( GetMarkerType() == MARKER_RATSNEST )
  60. return false;
  61. else
  62. return HitTestMarker( aPosition, aAccuracy );
  63. }
  64. EDA_ITEM* Clone() const override
  65. {
  66. return new PCB_MARKER( *this );
  67. }
  68. GAL_LAYER_ID GetColorLayer() const;
  69. std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer,
  70. FLASHING aFlash = FLASHING::DEFAULT ) const override;
  71. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  72. bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
  73. {
  74. return BOARD_ITEM::Matches( m_rcItem->GetErrorMessage(), aSearchData );
  75. }
  76. wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
  77. BITMAPS GetMenuImage() const override;
  78. void SetZoom( double aZoomFactor );
  79. const BOX2I ViewBBox() const override;
  80. const BOX2I GetBoundingBox() const override;
  81. void ViewGetLayers( int aLayers[], int& aCount ) const override;
  82. SEVERITY GetSeverity() const override;
  83. #if defined(DEBUG)
  84. void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  85. #endif
  86. /** Get class name
  87. * @return string "PCB_MARKER"
  88. */
  89. virtual wxString GetClass() const override
  90. {
  91. return wxT( "PCB_MARKER" );
  92. }
  93. protected:
  94. KIGFX::COLOR4D getColor() const override;
  95. };
  96. #endif // PCB_MARKER_H