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.

117 lines
4.3 KiB

7 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
  5. * Copyright (C) 2011-2021 KiCad Developers, see AUTHORS.txt for contributors.
  6. * Copyright (C) 2019 CERN
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. #ifndef EE_COLLECTORS_H
  26. #define EE_COLLECTORS_H
  27. #include <lib_symbol.h>
  28. #include <collector.h>
  29. #include <dialogs/dialog_schematic_find.h>
  30. #include <sch_item.h>
  31. class SCH_SHEET_PATH;
  32. class SCH_SYMBOL;
  33. class EE_COLLECTOR : public COLLECTOR
  34. {
  35. public:
  36. static const KICAD_T AllItems[];
  37. static const KICAD_T EditableItems[];
  38. static const KICAD_T MovableItems[];
  39. static const KICAD_T SymbolsOnly[];
  40. static const KICAD_T SheetsOnly[];
  41. static const KICAD_T WiresOnly[];
  42. static const KICAD_T FieldOwners[];
  43. EE_COLLECTOR( const KICAD_T* aScanTypes = EE_COLLECTOR::AllItems ) :
  44. m_Unit( 0 ),
  45. m_Convert( 0 )
  46. {
  47. SetScanTypes( aScanTypes );
  48. }
  49. /**
  50. * Overload COLLECTOR::operator[](int) to return a SCH_ITEM instead of an EDA_ITEM.
  51. *
  52. * @param aIndex The index into the list.
  53. * @return SCH_ITEM* at \a aIndex or NULL.
  54. */
  55. SCH_ITEM* operator[]( int aIndex ) const override
  56. {
  57. if( (unsigned)aIndex < (unsigned)GetCount() )
  58. return (SCH_ITEM*) m_list[ aIndex ];
  59. return nullptr;
  60. }
  61. SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
  62. /**
  63. * Scan a #EDA_ITEM using this class's Inspector method which does the collection.
  64. *
  65. * @param aScreen The eeschema screen to use for scanning
  66. * @param aFilterList A list of #KICAD_T types with a terminating #EOT, that determines
  67. * what is to be collected and the priority order of the resulting
  68. * collection.
  69. * @param aPos are the coordinates to use in hit testing.
  70. * @param aUnit is the symbol unit filter (for symbol editor).
  71. * @param aConvert is the DeMorgan filter (for symbol editor)
  72. */
  73. void Collect( SCH_SCREEN* aScreen, const KICAD_T aFilterList[], const wxPoint& aPos,
  74. int aUnit = 0, int aConvert = 0 );
  75. /**
  76. * Scan an #EDA_ITEM using this class's Inspector method which does the collection.
  77. *
  78. * @param aItems is a LIB_SYMBOL multivector holding the symbol items.
  79. * @param aFilterList is a list of #KICAD_T types with a terminating #EOT, that determines
  80. * what is to be collected and the priority order of the resulting
  81. * collection.
  82. * @param aPos are the coordinates to use in hit testing.
  83. * @param aUnit is the symbol unit filter (for symbol editor).
  84. * @param aConvert is the DeMorgan filter (for symbol editor).
  85. */
  86. void Collect( LIB_ITEMS_CONTAINER& aItems, const KICAD_T aFilterList[], const wxPoint& aPos,
  87. int aUnit = 0, int aConvert = 0 );
  88. /**
  89. * Test if the collected items form a corner of two line segments.
  90. *
  91. * @return True if the collected items form a corner of two line segments.
  92. */
  93. bool IsCorner() const;
  94. public:
  95. int m_Unit; // Fixed symbol unit filter (for symbol editor)
  96. int m_Convert; // Fixed DeMorgan filter (for symbol editor)
  97. };
  98. void CollectOtherUnits( const wxString& thisRef, int thisUnit, const LIB_ID& aLibId,
  99. SCH_SHEET_PATH& aSheet, std::vector<SCH_SYMBOL*>* otherUnits );
  100. #endif // EE_COLLECTORS_H