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.

131 lines
4.0 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2023 Alex Shvartzkop <dudesuchamazing@gmail.com>
  5. * Copyright (C) 2023 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 GENERATOR_H_
  25. #define GENERATOR_H_
  26. #include <unordered_set>
  27. #include <string_any_map.h>
  28. #include <pcb_group.h>
  29. class EDIT_POINTS;
  30. class BOARD;
  31. class BOARD_ITEM;
  32. class PCB_BASE_EDIT_FRAME;
  33. class GENERATOR_TOOL;
  34. class STATUS_MIN_MAX_POPUP;
  35. class PCB_GENERATOR : public PCB_GROUP
  36. {
  37. public:
  38. PCB_GENERATOR( BOARD_ITEM* aParent, PCB_LAYER_ID aLayer );
  39. virtual ~PCB_GENERATOR();
  40. /*
  41. * Clone() this and all descendants
  42. */
  43. PCB_GENERATOR* DeepClone() const;
  44. virtual void EditStart( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
  45. virtual void EditPush( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit,
  46. const wxString& aCommitMsg = wxEmptyString, int aCommitFlags = 0 );
  47. virtual void EditRevert( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
  48. virtual void Remove( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
  49. virtual bool Update( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
  50. #define STATUS_ITEMS_ONLY true
  51. virtual std::vector<EDA_ITEM*> GetPreviewItems( GENERATOR_TOOL* aTool,
  52. PCB_BASE_EDIT_FRAME* aFrame,
  53. bool aStatusItemsOnly = false );
  54. virtual bool MakeEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints ) const;
  55. virtual bool UpdateFromEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints,
  56. BOARD_COMMIT* aCommit );
  57. virtual bool UpdateEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints );
  58. const BOX2I GetBoundingBox() const override;
  59. VECTOR2I GetPosition() const override { return m_origin; }
  60. void SetPosition( const VECTOR2I& aPos ) override { m_origin = aPos; }
  61. void Move( const VECTOR2I& aMoveVector ) override;
  62. bool AddItem( BOARD_ITEM* aItem ) override;
  63. LSET GetLayerSet() const override;
  64. virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
  65. virtual wxString GetGeneratorType() const;
  66. virtual const STRING_ANY_MAP GetProperties() const;
  67. virtual void SetProperties( const STRING_ANY_MAP& aProps );
  68. virtual std::vector<std::pair<wxString, wxVariant>> GetRowData();
  69. virtual void ShowPropertiesDialog( PCB_BASE_EDIT_FRAME* aEditFrame ) {};
  70. wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
  71. virtual wxString GetPluralName() const = 0;
  72. #if defined(DEBUG)
  73. void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  74. #endif
  75. wxString GetClass() const override;
  76. static inline bool ClassOf( const EDA_ITEM* aItem );
  77. #ifdef GENERATOR_ORDER
  78. int GetUpdateOrder() const { return m_updateOrder; }
  79. void SetUpdateOrder( int aValue ) { m_updateOrder = aValue; }
  80. #endif
  81. protected:
  82. wxString m_generatorType;
  83. VECTOR2I m_origin;
  84. #ifdef GENERATOR_ORDER
  85. int m_updateOrder = 0;
  86. #endif
  87. friend class GENERATORS_MGR;
  88. };
  89. #endif /* GENERATOR_H_ */