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.

119 lines
3.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #ifndef CLEANUP_ITEM_H
  24. #define CLEANUP_ITEM_H
  25. #include <drc/drc_item.h>
  26. class PCB_BASE_FRAME;
  27. enum CLEANUP_RC_CODE {
  28. CLEANUP_FIRST = DRCE_LAST + 1,
  29. CLEANUP_SHORTING_TRACK = CLEANUP_FIRST,
  30. CLEANUP_SHORTING_VIA,
  31. CLEANUP_REDUNDANT_VIA,
  32. CLEANUP_DUPLICATE_TRACK,
  33. CLEANUP_MERGE_TRACKS,
  34. CLEANUP_DANGLING_TRACK,
  35. CLEANUP_DANGLING_VIA,
  36. CLEANUP_ZERO_LENGTH_TRACK,
  37. CLEANUP_TRACK_IN_PAD,
  38. CLEANUP_NULL_GRAPHIC,
  39. CLEANUP_DUPLICATE_GRAPHIC,
  40. CLEANUP_LINES_TO_RECT
  41. };
  42. class CLEANUP_ITEM : public RC_ITEM
  43. {
  44. public:
  45. CLEANUP_ITEM( int aErrorCode );
  46. /**
  47. * Return the string form of a drc error code.
  48. */
  49. wxString GetErrorText( int aErrorCode = -1, bool aTranslate = true ) const;
  50. private:
  51. wxString m_errorMessage;
  52. };
  53. /**
  54. * An implementation of the interface named RC_ITEMS_PROVIDER which uses a vector
  55. * of pointers to CLEANUP_ITEMs to fulfill the interface. No ownership is taken of the
  56. * vector.
  57. */
  58. class VECTOR_CLEANUP_ITEMS_PROVIDER : public RC_ITEMS_PROVIDER
  59. {
  60. public:
  61. VECTOR_CLEANUP_ITEMS_PROVIDER( std::vector<std::shared_ptr<CLEANUP_ITEM> >* aList ) :
  62. m_sourceVector( aList )
  63. {
  64. }
  65. void SetSeverities( int aSeverities ) override
  66. {
  67. }
  68. int GetCount( int aSeverity = -1 ) const override
  69. {
  70. return m_sourceVector->size();
  71. }
  72. std::shared_ptr<RC_ITEM> GetItem( int aIndex ) const override
  73. {
  74. return m_sourceVector->at( aIndex );
  75. }
  76. std::shared_ptr<CLEANUP_ITEM> GetCleanupItem( int aIndex )
  77. {
  78. return m_sourceVector->at( aIndex );
  79. }
  80. void DeleteItem( int aIndex, bool aDeep ) override
  81. {
  82. if( aDeep )
  83. {
  84. auto item = m_sourceVector->at( aIndex );
  85. m_sourceVector->erase( m_sourceVector->begin() + aIndex );
  86. }
  87. }
  88. void DeleteAllItems( bool aIncludeExclusions, bool aDeep ) override
  89. {
  90. if( aDeep )
  91. {
  92. m_sourceVector->clear();
  93. }
  94. }
  95. private:
  96. std::vector<std::shared_ptr<CLEANUP_ITEM> >* m_sourceVector; // owns its CLEANUP_ITEMs
  97. };
  98. #endif // CLEANUP_ITEM_H