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.

681 lines
21 KiB

19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
18 years ago
14 years ago
19 years ago
19 years ago
19 years ago
18 years ago
19 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
18 years ago
18 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
14 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
14 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
18 years ago
14 years ago
14 years ago
14 years ago
14 years ago
19 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  5. * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.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 COLLECTORS_H
  25. #define COLLECTORS_H
  26. /* This module contains a number of COLLECTOR implementations which are used
  27. * to augment the functionality of class PCB_EDIT_FRAME.
  28. */
  29. #include <collector.h>
  30. #include <layers_id_colors_and_visibility.h> // LAYER_COUNT, layer defs
  31. #include <view/view.h>
  32. #include <class_board_item.h>
  33. /**
  34. * An abstract base class whose derivatives may be passed to a GENERAL_COLLECTOR,
  35. * telling GENERAL_COLLECTOR what should be collected (aside from HitTest()ing
  36. * and KICAD_T scanTypes[], information which are provided to the GENERAL_COLLECTOR
  37. * through attributes or arguments separately).
  38. * <p>
  39. * A justification for this class is to keep the structural storage details of
  40. * the program's "global preferences" or "configuration options" out of
  41. * GENERAL_COLLECTOR::Inspect(). This class carries all the necessary details
  42. * in with it to the Inspect() call. The constructors or other functions of
  43. * this class's derivatives are then the only place where knowledge of the
  44. * specific structure of the global preference storage is needed. Thus,
  45. * GENERAL_COLLECTOR::Inspect() can be kept as simple as possible, and insulated
  46. * from changes in global preference storage (and even then it is
  47. * not simple enough).
  48. * </p>
  49. * This class introduces the notion of layer locking.
  50. */
  51. class COLLECTORS_GUIDE
  52. {
  53. public:
  54. virtual ~COLLECTORS_GUIDE() {}
  55. /**
  56. * @return bool - true if the given layer is locked, else false.
  57. */
  58. virtual bool IsLayerLocked( PCB_LAYER_ID layer ) const = 0;
  59. /**
  60. * @return bool - true if the given layer is visible, else false.
  61. */
  62. virtual bool IsLayerVisible( PCB_LAYER_ID layer ) const = 0;
  63. /**
  64. * @return bool - true if should ignore locked layers, else false.
  65. */
  66. virtual bool IgnoreLockedLayers() const = 0;
  67. /**
  68. * @return bool - true if should ignore non-visible layers, else false.
  69. */
  70. virtual bool IgnoreNonVisibleLayers() const = 0;
  71. /**
  72. * @return int - the preferred layer for HitTest()ing.
  73. */
  74. virtual PCB_LAYER_ID GetPreferredLayer() const = 0;
  75. /**
  76. * Provide wildcard behavior regarding the preferred layer.
  77. *
  78. * @return bool - true if should ignore preferred layer, else false.
  79. */
  80. virtual bool IgnorePreferredLayer() const = 0;
  81. /**
  82. * @return bool - true if should ignore locked items, else false.
  83. */
  84. virtual bool IgnoreLockedItems() const = 0;
  85. /**
  86. * Determine if the secondary criteria or 2nd choice items should be included.
  87. *
  88. * @return bool - true if should include, else false.
  89. */
  90. virtual bool IncludeSecondary() const = 0;
  91. /**
  92. * @return bool - true if MTexts marked as "no show" should be ignored.
  93. */
  94. virtual bool IgnoreMTextsMarkedNoShow() const = 0;
  95. /**
  96. * @return bool - true if should ignore MTexts on back layers
  97. */
  98. virtual bool IgnoreMTextsOnBack() const = 0;
  99. /**
  100. * @return bool - true if should ignore MTexts on front layers.
  101. */
  102. virtual bool IgnoreMTextsOnFront() const = 0;
  103. /**
  104. * @return bool - true if should ignore MODULEs on Back Side.
  105. */
  106. virtual bool IgnoreModulesOnBack() const = 0;
  107. /**
  108. * @return bool - ture if should ignore MODULEs on Front Side.
  109. */
  110. virtual bool IgnoreModulesOnFront() const = 0;
  111. /**
  112. * @return bool - true if should ignore Pads on Back Side.
  113. */
  114. virtual bool IgnorePadsOnBack() const = 0;
  115. /**
  116. * @return bool - ture if should ignore PADSs on Front Side.
  117. */
  118. virtual bool IgnorePadsOnFront() const = 0;
  119. /**
  120. * @return bool - ture if should ignore through-hole PADSs.
  121. */
  122. virtual bool IgnoreThroughHolePads() const = 0;
  123. /**
  124. * @return bool - true if should ignore PADSs on Front side and Back side.
  125. */
  126. virtual bool IgnorePads() const
  127. {
  128. return IgnorePadsOnFront() && IgnorePadsOnBack() && IgnoreThroughHolePads();
  129. }
  130. /**
  131. * @return bool - true if should ignore modules values.
  132. */
  133. virtual bool IgnoreModulesVals() const = 0;
  134. /**
  135. * @return bool - true if should ignore module references.
  136. */
  137. virtual bool IgnoreModulesRefs() const = 0;
  138. /**
  139. * @return true if should ignore through-hole vias
  140. */
  141. virtual bool IgnoreThroughVias() const = 0;
  142. /**
  143. * @return true if should ignore blind/buried vias
  144. */
  145. virtual bool IgnoreBlindBuriedVias() const = 0;
  146. /**
  147. * @return true if should ignore micro vias
  148. */
  149. virtual bool IgnoreMicroVias() const = 0;
  150. /**
  151. * @return true if should ignore tracks
  152. */
  153. virtual bool IgnoreTracks() const = 0;
  154. /**
  155. * @return true if should ignore the interiors of zones
  156. */
  157. virtual bool IgnoreZoneFills() const = 0;
  158. virtual double OnePixelInIU() const = 0;
  159. /**
  160. * @return bool - true if Inspect() should use BOARD_ITEM::HitTest()
  161. * or false if Inspect() should use BOARD_ITEM::BoundsTest().
  162. virtual bool UseHitTesting() const = 0;
  163. */
  164. };
  165. /**
  166. * Collect #BOARD_ITEM objects.
  167. *
  168. * All this object really does is override the [] operator and return a #BOARD_ITEM instead
  169. * of a #EDA_ITEM. Derive all board collector objects from this class instead of the base
  170. * #COLLECTOR object.
  171. *
  172. * @see class COLLECTOR
  173. */
  174. class PCB_COLLECTOR : public COLLECTOR
  175. {
  176. public:
  177. /**
  178. * Overload the COLLECTOR::operator[](int) to return a #BOARD_ITEM instead of an #EDA_ITEM.
  179. *
  180. * @param ndx The index into the list.
  181. * @return BOARD_ITEM* - or something derived from it, or NULL.
  182. */
  183. BOARD_ITEM* operator[]( int ndx ) const override
  184. {
  185. if( (unsigned)ndx < (unsigned)GetCount() )
  186. return (BOARD_ITEM*) m_List[ ndx ];
  187. return NULL;
  188. }
  189. };
  190. /**
  191. * Used when the right click button is pressed, or when the select tool is in effect.
  192. * This class can be used by window classes such as PCB_EDIT_FRAME.
  193. *
  194. * Philosophy: this class knows nothing of the context in which a BOARD is used
  195. * and that means it knows nothing about which layers are visible or current,
  196. * but can handle those concerns by the SetPreferredLayer() function and the
  197. * SetLayerSet() function.
  198. */
  199. class GENERAL_COLLECTOR : public PCB_COLLECTOR
  200. {
  201. protected:
  202. /**
  203. * A place to hold collected objects which don't match precisely the search
  204. * criteria, but would be acceptable if nothing else is found.
  205. * "2nd" choice, which will be appended to the end of COLLECTOR's prime
  206. * "list" at the end of the search.
  207. */
  208. std::vector<BOARD_ITEM*> m_List2nd;
  209. /**
  210. * Determines which items are to be collected by Inspect()
  211. */
  212. const COLLECTORS_GUIDE* m_Guide;
  213. /**
  214. * The number of items that were originally in the primary list before the
  215. * m_List2nd was concatenated onto the end of it.
  216. */
  217. int m_PrimaryLength;
  218. public:
  219. /**
  220. * A scan list for all editable board items
  221. */
  222. static const KICAD_T AllBoardItems[];
  223. /**
  224. * A scan list for all editable board items, except zones
  225. */
  226. static const KICAD_T AllButZones[];
  227. /**
  228. * A scan list for zones outlines only
  229. */
  230. static const KICAD_T Zones[];
  231. /**
  232. * A scan list for all primary board items, omitting items which are subordinate to
  233. * a MODULE, such as D_PAD and TEXTEMODULE.
  234. */
  235. static const KICAD_T BoardLevelItems[];
  236. /**
  237. * A scan list for only MODULEs
  238. */
  239. static const KICAD_T Modules[];
  240. /**
  241. * A scan list for PADs or MODULEs
  242. */
  243. static const KICAD_T PadsOrModules[];
  244. /**
  245. * A scan list for PADs, TRACKs, or VIAs
  246. */
  247. static const KICAD_T PadsOrTracks[];
  248. /**
  249. * A scan list for MODULEs and their items (for Modedit)
  250. */
  251. static const KICAD_T ModulesAndTheirItems[];
  252. /**
  253. * A scan list for primary module items.
  254. */
  255. static const KICAD_T ModuleItems[];
  256. /**
  257. * A scan list for only TRACKS
  258. */
  259. static const KICAD_T Tracks[];
  260. /**
  261. * A scan list for TRACKS, VIAS, MODULES
  262. */
  263. static const KICAD_T LockableItems[];
  264. /**
  265. * Constructor GENERALCOLLECTOR
  266. */
  267. GENERAL_COLLECTOR()
  268. {
  269. m_Guide = NULL;
  270. m_PrimaryLength = 0;
  271. SetScanTypes( AllBoardItems );
  272. }
  273. void Empty2nd()
  274. {
  275. m_List2nd.clear();
  276. }
  277. void Append2nd( BOARD_ITEM* item )
  278. {
  279. m_List2nd.push_back( item );
  280. }
  281. /**
  282. * Record which COLLECTORS_GUIDE to use.
  283. *
  284. * @param aGuide Which guide to use in the collection.
  285. */
  286. void SetGuide( const COLLECTORS_GUIDE* aGuide ) { m_Guide = aGuide; }
  287. const COLLECTORS_GUIDE* GetGuide() { return m_Guide; }
  288. /**
  289. * @return int - The number if items which met the primary search criteria
  290. */
  291. int GetPrimaryCount() { return m_PrimaryLength; }
  292. /**
  293. * The examining function within the INSPECTOR which is passed to the Iterate function.
  294. *
  295. * Searches and collects all the objects which match the test data.
  296. *
  297. * @param testItem An EDA_ITEM to examine.
  298. * @param testData is not used in this class.
  299. * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
  300. * else SCAN_CONTINUE;
  301. */
  302. SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
  303. /**
  304. * Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
  305. *
  306. * @param aItem A BOARD_ITEM to scan, may be a BOARD or MODULE, or whatever.
  307. * @param aScanList A list of KICAD_Ts with a terminating EOT, that specs
  308. * what is to be collected and the priority order of the resultant
  309. * collection in "m_List".
  310. * @param aRefPos A wxPoint to use in hit-testing.
  311. * @param aGuide The COLLECTORS_GUIDE to use in collecting items.
  312. */
  313. void Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
  314. const wxPoint& aRefPos, const COLLECTORS_GUIDE& aGuide );
  315. };
  316. /**
  317. * A general implementation of a COLLECTORS_GUIDE. One of its constructors is
  318. * entitled to grab information from the program's global preferences.
  319. */
  320. class GENERAL_COLLECTORS_GUIDE : public COLLECTORS_GUIDE
  321. {
  322. private:
  323. // the storage architecture here is not important, since this is only
  324. // a carrier object and its functions are what is used, and data only indirectly.
  325. PCB_LAYER_ID m_PreferredLayer;
  326. bool m_IgnorePreferredLayer;
  327. LSET m_LayerLocked; ///< bit-mapped layer locked bits
  328. bool m_IgnoreLockedLayers;
  329. LSET m_LayerVisible; ///< bit-mapped layer visible bits
  330. bool m_IgnoreNonVisibleLayers;
  331. bool m_IgnoreLockedItems;
  332. bool m_IncludeSecondary;
  333. bool m_IgnoreMTextsMarkedNoShow;
  334. bool m_IgnoreMTextsOnBack;
  335. bool m_IgnoreMTextsOnFront;
  336. bool m_IgnoreModulesOnBack;
  337. bool m_IgnoreModulesOnFront;
  338. bool m_IgnorePadsOnFront;
  339. bool m_IgnorePadsOnBack;
  340. bool m_IgnoreThroughHolePads;
  341. bool m_IgnoreModulesVals;
  342. bool m_IgnoreModulesRefs;
  343. bool m_IgnoreThroughVias;
  344. bool m_IgnoreBlindBuriedVias;
  345. bool m_IgnoreMicroVias;
  346. bool m_IgnoreTracks;
  347. bool m_IgnoreZoneFills;
  348. double m_OnePixelInIU;
  349. public:
  350. /**
  351. * Grab stuff from global preferences and uses reasonable defaults.
  352. *
  353. * Add more constructors as needed.
  354. *
  355. * @param aVisibleLayerMask = current visible layers (bit mask)
  356. * @param aPreferredLayer = the layer to search first
  357. */
  358. GENERAL_COLLECTORS_GUIDE( LSET aVisibleLayerMask, PCB_LAYER_ID aPreferredLayer,
  359. KIGFX::VIEW* aView )
  360. {
  361. VECTOR2I one( 1, 1 );
  362. m_PreferredLayer = aPreferredLayer;
  363. m_IgnorePreferredLayer = false;
  364. m_LayerVisible = aVisibleLayerMask;
  365. m_IgnoreLockedLayers = true;
  366. m_IgnoreNonVisibleLayers = true;
  367. m_IgnoreLockedItems = false;
  368. #if defined(USE_MATCH_LAYER)
  369. m_IncludeSecondary = false;
  370. #else
  371. m_IncludeSecondary = true;
  372. #endif
  373. m_IgnoreMTextsMarkedNoShow = true; // g_ModuleTextNOVColor;
  374. m_IgnoreMTextsOnBack = true;
  375. m_IgnoreMTextsOnFront = false;
  376. m_IgnoreModulesOnBack = true; // !Show_Modules_Cmp;
  377. m_IgnoreModulesOnFront = false;
  378. m_IgnorePadsOnFront = false;
  379. m_IgnorePadsOnBack = false;
  380. m_IgnoreThroughHolePads = false;
  381. m_IgnoreModulesVals = false;
  382. m_IgnoreModulesRefs = false;
  383. m_IgnoreThroughVias = false;
  384. m_IgnoreBlindBuriedVias = false;
  385. m_IgnoreMicroVias = false;
  386. m_IgnoreTracks = false;
  387. m_IgnoreZoneFills = true;
  388. m_OnePixelInIU = aView->ToWorld( one, false ).x;
  389. }
  390. /**
  391. * @return bool - true if the given layer is locked, else false.
  392. */
  393. bool IsLayerLocked( PCB_LAYER_ID aLayerId ) const override
  394. {
  395. return m_LayerLocked[aLayerId];
  396. }
  397. void SetLayerLocked( PCB_LAYER_ID aLayerId, bool isLocked )
  398. {
  399. m_LayerLocked.set( aLayerId, isLocked );
  400. }
  401. /**
  402. * @return bool - true if the given layer is visible, else false.
  403. */
  404. bool IsLayerVisible( PCB_LAYER_ID aLayerId ) const override
  405. {
  406. return m_LayerVisible[aLayerId];
  407. }
  408. void SetLayerVisible( PCB_LAYER_ID aLayerId, bool isVisible )
  409. {
  410. m_LayerVisible.set( aLayerId, isVisible );
  411. }
  412. void SetLayerVisibleBits( LSET aLayerBits ) { m_LayerVisible = aLayerBits; }
  413. /**
  414. * @return bool - true if should ignore locked layers, else false.
  415. */
  416. bool IgnoreLockedLayers() const override { return m_IgnoreLockedLayers; }
  417. void SetIgnoreLockedLayers( bool ignore ) { m_IgnoreLockedLayers = ignore; }
  418. /**
  419. * @return bool - true if should ignore non-visible layers, else false.
  420. */
  421. bool IgnoreNonVisibleLayers() const override { return m_IgnoreNonVisibleLayers; }
  422. void SetIgnoreNonVisibleLayers( bool ignore ) { m_IgnoreLockedLayers = ignore; }
  423. /**
  424. * @return int - the preferred layer for HitTest()ing.
  425. */
  426. PCB_LAYER_ID GetPreferredLayer() const override { return m_PreferredLayer; }
  427. void SetPreferredLayer( PCB_LAYER_ID aLayer ) { m_PreferredLayer = aLayer; }
  428. /**
  429. * Provide wildcard behavior regarding the preferred layer.
  430. *
  431. * @return bool - true if should ignore preferred layer, else false.
  432. */
  433. bool IgnorePreferredLayer() const override { return m_IgnorePreferredLayer; }
  434. void SetIgnorePreferredLayer( bool ignore ) { m_IgnorePreferredLayer = ignore; }
  435. /**
  436. * @return bool - true if should ignore locked items, else false.
  437. */
  438. bool IgnoreLockedItems() const override { return m_IgnoreLockedItems; }
  439. void SetIgnoreLockedItems( bool ignore ) { m_IgnoreLockedItems = ignore; }
  440. /**
  441. * Determine if the secondary criteria, or 2nd choice items should be included.
  442. *
  443. * @return bool - true if should include, else false.
  444. */
  445. bool IncludeSecondary() const override { return m_IncludeSecondary; }
  446. void SetIncludeSecondary( bool include ) { m_IncludeSecondary = include; }
  447. /**
  448. * @return bool - true if MTexts marked as "no show" should be ignored.
  449. */
  450. bool IgnoreMTextsMarkedNoShow() const override { return m_IgnoreMTextsMarkedNoShow; }
  451. void SetIgnoreMTextsMarkedNoShow( bool ignore ) { m_IgnoreMTextsMarkedNoShow = ignore; }
  452. /**
  453. * @return bool - true if should ignore MTexts on back layers
  454. */
  455. bool IgnoreMTextsOnBack() const override { return m_IgnoreMTextsOnBack; }
  456. void SetIgnoreMTextsOnBack( bool ignore ) { m_IgnoreMTextsOnBack = ignore; }
  457. /**
  458. * @return bool - true if should ignore MTexts on front layers
  459. */
  460. bool IgnoreMTextsOnFront() const override { return m_IgnoreMTextsOnFront; }
  461. void SetIgnoreMTextsOnFront( bool ignore ) { m_IgnoreMTextsOnFront = ignore; }
  462. /**
  463. * @return bool - true if should ignore MODULEs on the back side
  464. */
  465. bool IgnoreModulesOnBack() const override { return m_IgnoreModulesOnBack; }
  466. void SetIgnoreModulesOnBack( bool ignore ) { m_IgnoreModulesOnBack = ignore; }
  467. /**
  468. * @return bool - true if should ignore MODULEs on component layer.
  469. */
  470. bool IgnoreModulesOnFront() const override { return m_IgnoreModulesOnFront; }
  471. void SetIgnoreModulesOnFront( bool ignore ) { m_IgnoreModulesOnFront = ignore; }
  472. /**
  473. * @return bool - true if should ignore Pads on Back Side.
  474. */
  475. bool IgnorePadsOnBack() const override { return m_IgnorePadsOnBack; }
  476. void SetIgnorePadsOnBack(bool ignore) { m_IgnorePadsOnBack = ignore; }
  477. /**
  478. * @return bool - true if should ignore PADSs on Front Side.
  479. */
  480. bool IgnorePadsOnFront() const override { return m_IgnorePadsOnFront; }
  481. void SetIgnorePadsOnFront(bool ignore) { m_IgnorePadsOnFront = ignore; }
  482. /**
  483. * @return bool - true if should ignore through-hole PADSs.
  484. */
  485. bool IgnoreThroughHolePads() const override { return m_IgnoreThroughHolePads; }
  486. void SetIgnoreThroughHolePads(bool ignore) { m_IgnoreThroughHolePads = ignore; }
  487. /**
  488. * @return bool - true if should ignore modules values.
  489. */
  490. bool IgnoreModulesVals() const override { return m_IgnoreModulesVals; }
  491. void SetIgnoreModulesVals(bool ignore) { m_IgnoreModulesVals = ignore; }
  492. /**
  493. * @return bool - true if should ignore modules references.
  494. */
  495. bool IgnoreModulesRefs() const override { return m_IgnoreModulesRefs; }
  496. void SetIgnoreModulesRefs(bool ignore) { m_IgnoreModulesRefs = ignore; }
  497. bool IgnoreThroughVias() const override { return m_IgnoreThroughVias; }
  498. void SetIgnoreThroughVias( bool ignore ) { m_IgnoreThroughVias = ignore; }
  499. bool IgnoreBlindBuriedVias() const override { return m_IgnoreBlindBuriedVias; }
  500. void SetIgnoreBlindBuriedVias( bool ignore ) { m_IgnoreBlindBuriedVias = ignore; }
  501. bool IgnoreMicroVias() const override { return m_IgnoreMicroVias; }
  502. void SetIgnoreMicroVias( bool ignore ) { m_IgnoreMicroVias = ignore; }
  503. bool IgnoreTracks() const override { return m_IgnoreTracks; }
  504. void SetIgnoreTracks( bool ignore ) { m_IgnoreTracks = ignore; }
  505. bool IgnoreZoneFills() const override { return m_IgnoreZoneFills; }
  506. void SetIgnoreZoneFills( bool ignore ) { m_IgnoreZoneFills = ignore; }
  507. double OnePixelInIU() const override { return m_OnePixelInIU; }
  508. };
  509. /**
  510. * Collect all #BOARD_ITEM objects of a given set of #KICAD_T type(s).
  511. *
  512. * @see class COLLECTOR
  513. */
  514. class PCB_TYPE_COLLECTOR : public PCB_COLLECTOR
  515. {
  516. public:
  517. /**
  518. * The examining function within the INSPECTOR which is passed to the Iterate function.
  519. *
  520. * @param testItem An EDA_ITEM to examine.
  521. * @param testData is not used in this class.
  522. * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
  523. * else SCAN_CONTINUE;
  524. */
  525. SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
  526. /**
  527. * Collect #BOARD_ITEM objects using this class's Inspector method, which does the collection.
  528. *
  529. * @param aBoard The BOARD_ITEM to scan.
  530. * @param aScanList The KICAD_Ts to gather up.
  531. */
  532. void Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] );
  533. };
  534. /**
  535. * Collect all #BOARD_ITEM objects on a given layer.
  536. *
  537. * This only uses the primary object layer for comparison.
  538. */
  539. class PCB_LAYER_COLLECTOR : public PCB_COLLECTOR
  540. {
  541. PCB_LAYER_ID m_layer_id;
  542. public:
  543. PCB_LAYER_COLLECTOR( PCB_LAYER_ID aLayerId = UNDEFINED_LAYER ) :
  544. m_layer_id( aLayerId )
  545. {
  546. }
  547. void SetLayerId( PCB_LAYER_ID aLayerId ) { m_layer_id = aLayerId; }
  548. /**
  549. * The examining function within the INSPECTOR which is passed to the iterate function.
  550. *
  551. * @param testItem An EDA_ITEM to examine.
  552. * @param testData is not used in this class.
  553. * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
  554. * else SCAN_CONTINUE;
  555. */
  556. SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
  557. /**
  558. * Tests a BOARD_ITEM using this class's Inspector method, which does the collection.
  559. *
  560. * @param aBoard The BOARD_ITEM to scan.
  561. * @param aScanList The KICAD_Ts to gather up.
  562. */
  563. void Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] );
  564. };
  565. #endif // COLLECTORS_H