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.

134 lines
3.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef GERBER_COLLECTORS_H
  20. #define GERBER_COLLECTORS_H
  21. #include <collector.h>
  22. /**
  23. * Class GERBER_COLLECTOR
  24. * is intended for use when the right click button is pressed, or when the
  25. * plain "arrow" tool is in effect.
  26. */
  27. class GERBER_COLLECTOR : public COLLECTOR
  28. {
  29. protected:
  30. /**
  31. * A place to hold collected objects which don't match precisely the search
  32. * criteria, but would be acceptable if nothing else is found.
  33. * "2nd" choice, which will be appended to the end of COLLECTOR's prime
  34. * "list" at the end of the search.
  35. */
  36. std::vector<EDA_ITEM*> m_List2nd;
  37. /**
  38. * Determines which items are to be collected by Inspect()
  39. */
  40. //const COLLECTORS_GUIDE* m_Guide;
  41. /**
  42. * The number of items that were originally in the primary list before the
  43. * m_List2nd was concatenated onto the end of it.
  44. */
  45. int m_PrimaryLength;
  46. public:
  47. /**
  48. * A scan list for all selectable gerber items
  49. */
  50. static const KICAD_T AllItems[];
  51. GERBER_COLLECTOR()
  52. {
  53. //m_Guide = NULL;
  54. m_PrimaryLength = 0;
  55. SetScanTypes( AllItems );
  56. }
  57. void Empty2nd()
  58. {
  59. m_List2nd.clear();
  60. }
  61. /*void Append2nd( BOARD_ITEM* item )
  62. {
  63. m_List2nd.push_back( item );
  64. }*/
  65. /**
  66. * Function SetGuide
  67. * records which COLLECTORS_GUIDE to use.
  68. * @param aGuide Which guide to use in the collection.
  69. */
  70. //void SetGuide( const COLLECTORS_GUIDE* aGuide ) { m_Guide = aGuide; }
  71. /**
  72. * Function operator[int]
  73. * overloads COLLECTOR::operator[](int) to return a EDA_ITEM* instead of
  74. * an EDA_ITEM* type.
  75. * @param ndx The index into the list.
  76. * @return EDA_ITEM* - or something derived from it, or NULL.
  77. */
  78. EDA_ITEM* operator[]( int ndx ) const
  79. {
  80. if( (unsigned)ndx < (unsigned)GetCount() )
  81. return (EDA_ITEM*) m_List[ ndx ];
  82. return NULL;
  83. }
  84. /**
  85. * Function GetPrimaryCount
  86. * @return int - The number if items which met the primary search criteria
  87. */
  88. int GetPrimaryCount() { return m_PrimaryLength; }
  89. /**
  90. * Function Inspect
  91. * is the examining function within the INSPECTOR which is passed to the
  92. * Iterate function.
  93. *
  94. * @param testItem An EDA_ITEM to examine.
  95. * @param testData is not used in this class.
  96. * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
  97. * else SCAN_CONTINUE;
  98. */
  99. SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
  100. /**
  101. * Function Collect
  102. * scans an EDA_ITEM using this class's Inspector method, which does the collection.
  103. * @param aItem An EDA_ITEM to scan
  104. * @param aScanList A list of KICAD_Ts with a terminating EOT, that specs
  105. * what is to be collected and the priority order of the resultant
  106. * collection in "m_List".
  107. * @param aRefPos A wxPoint to use in hit-testing.
  108. * @param aGuide The COLLECTORS_GUIDE to use in collecting items.
  109. */
  110. void Collect( EDA_ITEM* aItem, const KICAD_T aScanList[],
  111. const wxPoint& aRefPos/*, const COLLECTORS_GUIDE& aGuide */);
  112. };
  113. #endif