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.

135 lines
3.8 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
  5. * Copyright (C) 2011 KiCad Developers, see change_log.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 _LIB_COLLECTORS_H_
  25. #define _LIB_COLLECTORS_H_
  26. #include <class_collector.h>
  27. #include <lib_draw_item.h>
  28. class LIB_COLLECTOR;
  29. class LIB_COLLECTOR_DATA
  30. {
  31. int m_unit;
  32. int m_convert;
  33. friend class LIB_COLLECTOR;
  34. public:
  35. LIB_COLLECTOR_DATA() :
  36. m_unit( 0 ),
  37. m_convert( 0 ) {}
  38. };
  39. /**
  40. * Class LIB_COLLECTOR
  41. */
  42. class LIB_COLLECTOR : public COLLECTOR
  43. {
  44. LIB_COLLECTOR_DATA m_data;
  45. public:
  46. /**
  47. * A scan list for all schematic items.
  48. */
  49. static const KICAD_T AllItems[];
  50. /**
  51. * A scan list for all editable schematic items.
  52. */
  53. static const KICAD_T EditableItems[];
  54. /**
  55. * A scan list for all movable schematic items.
  56. */
  57. static const KICAD_T MovableItems[];
  58. /**
  59. * A scan list for all rotatable schematic items.
  60. */
  61. static const KICAD_T RotatableItems[];
  62. /**
  63. * A scan list for all schematic items except pins.
  64. */
  65. static const KICAD_T AllItemsButPins[];
  66. /**
  67. * Constructor LIB_COLLECTOR
  68. */
  69. LIB_COLLECTOR( const KICAD_T* aScanTypes = LIB_COLLECTOR::AllItems )
  70. {
  71. SetScanTypes( aScanTypes );
  72. }
  73. /**
  74. * Operator []
  75. * overloads COLLECTOR::operator[](int) to return a LIB_ITEM* instead of
  76. * an EDA_ITEM* type.
  77. * @param aIndex The index into the list.
  78. * @return LIB_ITEM* at \a aIndex or NULL.
  79. */
  80. LIB_ITEM* operator[]( int aIndex ) const
  81. {
  82. if( (unsigned)aIndex < (unsigned)GetCount() )
  83. return (LIB_ITEM*) m_List[ aIndex ];
  84. return NULL;
  85. }
  86. /**
  87. * Function Inspect
  88. * is the examining function within the INSPECTOR which is passed to the
  89. * Iterate function.
  90. *
  91. * @param aItem An EDA_ITEM to examine.
  92. * @param aTestData is not used in this class.
  93. * @return SEARCH_RESULT #SEARCH_QUIT if the iterator is to stop the scan,
  94. * else #SEARCH_CONTINUE;
  95. */
  96. SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
  97. /**
  98. * Function Collect
  99. * scans a SCH_ITEM using this class's Inspector method, which does the collection.
  100. * @param aItem A SCH_ITEM to scan.
  101. * @param aFilterList A list of #KICAD_T types with a terminating #EOT, that determines
  102. * what is to be collected and the priority order of the resulting
  103. * collection.
  104. * @param aPosition A wxPoint to use in hit-testing.
  105. * @param aUnit The unit of the items to collect or zero if all units.
  106. * @param aConvert The convert of the items to collect or zero if all conversions.
  107. */
  108. void Collect( LIB_ITEMS& aItem, const KICAD_T aFilterList[], const wxPoint& aPosition,
  109. int aUnit = 0, int aConvert = 0 );
  110. };
  111. #endif // _LIB_COLLECTORS_H_