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.

145 lines
4.7 KiB

7 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright The 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 TYPE_SCH_MARKER_H_
  25. #define TYPE_SCH_MARKER_H_
  26. #include <erc/erc_item.h>
  27. #include <sch_item.h>
  28. #include <marker_base.h>
  29. class SCH_MARKER : public SCH_ITEM, public MARKER_BASE
  30. {
  31. public:
  32. SCH_MARKER( std::shared_ptr<ERC_ITEM> aItem, const VECTOR2I& aPos );
  33. ~SCH_MARKER();
  34. // Do not create a copy constructor. The one generated by the compiler is adequate.
  35. static inline bool ClassOf( const EDA_ITEM* aItem )
  36. {
  37. return aItem && SCH_MARKER_T == aItem->Type();
  38. }
  39. wxString GetClass() const override
  40. {
  41. return wxT( "SCH_MARKER" );
  42. }
  43. const KIID GetUUID() const override { return m_Uuid; }
  44. wxString SerializeToString() const;
  45. static SCH_MARKER* DeserializeFromString( const SCH_SHEET_LIST& aSheetList,
  46. const wxString& data );
  47. std::vector<int> ViewGetLayers() const override;
  48. SCH_LAYER_ID GetColorLayer() const;
  49. SEVERITY GetSeverity() const override;
  50. void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
  51. int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override
  52. {
  53. // SCH_MARKERs should not be plotted. However, SCH_ITEM will fail an assertion if we
  54. // do not confirm this by locally implementing a no-op Plot().
  55. }
  56. BOX2I const GetBoundingBox() const override;
  57. // Geometric transforms (used in block operations):
  58. void Move( const VECTOR2I& aMoveVector ) override
  59. {
  60. m_Pos += aMoveVector;
  61. }
  62. void MirrorHorizontally( int aCenter ) override;
  63. void MirrorVertically( int aCenter ) override;
  64. void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
  65. /**
  66. * Compare DRC marker main and auxiliary text against search string.
  67. *
  68. * @param[in] aSearchData is the criteria to search against.
  69. * @param[in] aAuxData is the optional data required for the search or NULL if not used.
  70. * @return True if the DRC main or auxiliary text matches the search criteria.
  71. */
  72. bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxDat ) const override;
  73. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  74. wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override
  75. {
  76. return wxString( _( "ERC Marker" ) );
  77. }
  78. BITMAPS GetMenuImage() const override;
  79. VECTOR2I GetPosition() const override { return m_Pos; }
  80. void SetPosition( const VECTOR2I& aPosition ) override { m_Pos = aPosition; }
  81. bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
  82. EDA_ITEM* Clone() const override;
  83. /**
  84. * Set this marker as a legacy artifact.
  85. *
  86. * Legacy markers are those deserialized from a file version < 20230121.
  87. */
  88. void SetIsLegacyMarker( bool isLegacyMarker = true ) { m_isLegacyMarker = isLegacyMarker; }
  89. /**
  90. * Determine if this marker is legacy (i.e. does not store sheet paths for specific errors).
  91. *
  92. * @return True if marker deserialized from a file version < 20230121
  93. */
  94. bool IsLegacyMarker() const { return m_isLegacyMarker; }
  95. double Similarity( const SCH_ITEM& aOther ) const override
  96. {
  97. return 0.0;
  98. }
  99. bool operator==( const SCH_ITEM& aOther ) const override
  100. {
  101. return false;
  102. }
  103. #if defined(DEBUG)
  104. void Show( int nestLevel, std::ostream& os ) const override;
  105. #endif
  106. protected:
  107. void swapData( SCH_ITEM* aItem ) override;
  108. KIGFX::COLOR4D getColor() const override;
  109. bool m_isLegacyMarker; ///< True if marker was deserialized from a file version < 20230121.
  110. };
  111. #endif // TYPE_SCH_MARKER_H_