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.

71 lines
2.4 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2017-2022 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. * Use when the right click button is pressed or when the select tool is in effect.
  24. */
  25. class GERBER_COLLECTOR : public COLLECTOR
  26. {
  27. public:
  28. GERBER_COLLECTOR()
  29. {
  30. SetScanTypes( { GERBER_LAYOUT_T, GERBER_IMAGE_T, GERBER_DRAW_ITEM_T } );
  31. }
  32. /**
  33. * Overload the [](int) operator to return a EDA_ITEM* instead of an EDA_ITEM* type.
  34. *
  35. * @param ndx The index into the list.
  36. * @return the item collected or NULL.
  37. */
  38. EDA_ITEM* operator[]( int ndx ) const override
  39. {
  40. if( (unsigned)ndx < (unsigned)GetCount() )
  41. return (EDA_ITEM*) m_list[ ndx ];
  42. return nullptr;
  43. }
  44. /**
  45. * The examining function within the INSPECTOR which is passed to the Iterate function.
  46. *
  47. * @param testItem An EDA_ITEM to examine.
  48. * @param testData is not used in this class.
  49. * @return SEARCH_QUIT if the Iterator is to stop the scan else SCAN_CONTINUE.
  50. */
  51. INSPECT_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
  52. /**
  53. * Scan an EDA_ITEM using this class's Inspector method, which does the collection.
  54. *
  55. * @param aItem An EDA_ITEM to scan
  56. * @param aScanTypes A list of KICAD_Ts that specs what is to be collected and the priority
  57. * order of the resultant collection in "m_list".
  58. * @param aRefPos A VECTOR2I to use in hit-testing.
  59. */
  60. void Collect( EDA_ITEM* aItem, const std::vector<KICAD_T>& aScanTypes,
  61. const VECTOR2I& aRefPos );
  62. };
  63. #endif