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.

114 lines
3.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Created on: 11 Mar 2016, author John Beard
  5. * Copyright (C) 1992-2016 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. /**
  25. * @file array_creator.h
  26. */
  27. #ifndef PCBNEW_ARRAY_CREATOR_H_
  28. #define PCBNEW_ARRAY_CREATOR_H_
  29. #include <dialogs/dialog_create_array.h>
  30. #include <class_board.h>
  31. #include <class_module.h>
  32. #include <class_board_item.h>
  33. /*!
  34. * Class that performs array creation by producing a dialog to gather
  35. * parameters and then creating and laying out the items.
  36. *
  37. * This is a template class which needs to be implemented by the relevant
  38. * edit tooling, since the details of how the document is manipulated
  39. * varies between edit modes (e.g. legacy or GAL)
  40. */
  41. class ARRAY_CREATOR
  42. {
  43. public:
  44. ARRAY_CREATOR(PCB_BASE_FRAME& parent):
  45. m_parent( parent )
  46. {}
  47. /*!
  48. * Open the dialog, gather parameters and create the array
  49. */
  50. void Invoke();
  51. protected:
  52. virtual ~ARRAY_CREATOR() {}
  53. PCB_BASE_FRAME& m_parent;
  54. private:
  55. /*!
  56. * Get the BOARD that is currently being edited.
  57. */
  58. virtual BOARD* getBoard() const = 0;
  59. /*!
  60. * If editing a footprint, returns the relevant MODULE, else NULL
  61. */
  62. virtual MODULE* getModule() const = 0;
  63. /*!
  64. * @return number of original items to put into an array (eg size of the
  65. * selection)
  66. */
  67. virtual int getNumberOfItemsToArray() const = 0;
  68. /*!
  69. * @return the n'th original item to be arrayed
  70. */
  71. virtual BOARD_ITEM* getNthItemToArray( int n ) const = 0;
  72. /*!
  73. * @return the rotation centre of all the items to be arrayed, when taken
  74. * together
  75. */
  76. virtual wxPoint getRotationCentre() const = 0;
  77. /*!
  78. * Perform any relevant action before pushing a newly created array item
  79. * to the BOARD
  80. */
  81. virtual void prePushAction( BOARD_ITEM* new_item )
  82. {}
  83. /*!
  84. * Perform any actions needed after pushing an item to the BOARD
  85. */
  86. virtual void postPushAction( BOARD_ITEM* new_item )
  87. {}
  88. /*!
  89. * Actions to perform after the array process is complete
  90. */
  91. virtual void finalise() = 0;
  92. };
  93. #endif /* PCBNEW_ARRAY_CREATOR_H_ */