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.

223 lines
7.6 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es>
  5. * Copyright (C) 2013 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 class_footprint_wizard.h
  26. * @brief Class PCBNEW_FOOTPRINT_WIZARDS
  27. */
  28. #ifndef CLASS_FOOTPRINT_WIZARD_H
  29. #define CLASS_FOOTPRINT_WIZARD_H
  30. #include <vector>
  31. #include <wxPcbStruct.h>
  32. // Allowable parameter types for PCB wizards
  33. const wxString WIZARD_PARAM_UNITS_MM = "mm"; // Millimetres
  34. const wxString WIZARD_PARAM_UNITS_MILS = "mils"; // Mils / thou
  35. const wxString WIZARD_PARAM_UNITS_FLOAT = "float"; // Floating point (dimensionless)
  36. const wxString WIZARD_PARAM_UNITS_INTEGER = "integer"; // Integer (dimensionless)
  37. const wxString WIZARD_PARAM_UNITS_BOOL = "bool"; // Boolean option
  38. const wxString WIZARD_PARAM_UNITS_RADIANS = "radians"; // Angle (radians)
  39. const wxString WIZARD_PARAM_UNITS_DEGREES = "degrees"; // Angle (degrees)
  40. const wxString WIZARD_PARAM_UNITS_PERCENT = "%"; // Percent (0% -> 100%)
  41. const wxString WIZARD_PARAM_UNITS_STRING = "string"; // String
  42. /**
  43. * Class FOOTPRINT_WIZARD
  44. * This is the parent class from where any footprint wizard class must
  45. * derive */
  46. class FOOTPRINT_WIZARD
  47. {
  48. public:
  49. FOOTPRINT_WIZARD() {}
  50. virtual ~FOOTPRINT_WIZARD();
  51. /**
  52. * Function GetName
  53. * @return the name of the wizard
  54. */
  55. virtual wxString GetName() = 0;
  56. /**
  57. * Function GetImage
  58. * @return an svg image of the wizard to be rendered
  59. */
  60. virtual wxString GetImage() = 0;
  61. /**
  62. * Function GetDescription
  63. * @return a description of the footprint wizard
  64. */
  65. virtual wxString GetDescription() = 0;
  66. /**
  67. * Function GetNumParameterPages
  68. * @return the number of parameter pages that this wizard will show to the user
  69. */
  70. virtual int GetNumParameterPages() = 0;
  71. /**
  72. * Function GetParameterPageName
  73. * @param aPage is the page we want the name of
  74. * @return a string with the page name
  75. */
  76. virtual wxString GetParameterPageName( int aPage ) = 0;
  77. /**
  78. * Function GetParameterNames
  79. * @param aPage is the page we want the parameter names of
  80. * @return an array string with the parameter names on a certain page
  81. */
  82. virtual wxArrayString GetParameterNames( int aPage ) = 0;
  83. /**
  84. * Function GetParameterTypes
  85. * @param aPage is the page we want the parameter types of
  86. * @return an array string with the parameter types on a certain page
  87. * "IU" for internal units, "UNITS" for units (0,1,2,3...,N)
  88. */
  89. virtual wxArrayString GetParameterTypes( int aPage ) = 0;
  90. /**
  91. * Function GetParameterValues
  92. * @param aPage is the page we want the parameter values of
  93. * @return an array of parameter values
  94. */
  95. virtual wxArrayString GetParameterValues( int aPage ) = 0;
  96. /**
  97. * Function GetParameterErrors
  98. * @param aPage is the page we want to know the errors of
  99. * @return an array of errors (if any) for the parameters, empty strings for OK parameters
  100. */
  101. virtual wxArrayString GetParameterErrors( int aPage ) = 0;
  102. /**
  103. * Function GetParameterHints
  104. * @param aPage is the page we want to know the hints of
  105. * @return an array of hints (if any) for the parameters, empty string for no hints
  106. */
  107. virtual wxArrayString GetParameterHints( int aPage ) = 0;
  108. /**
  109. * Function GetParamaterDesignators
  110. * @param aPage is the page we want to know the designators of
  111. * @return an array of designators (blank strings for no designators
  112. */
  113. virtual wxArrayString GetParameterDesignators( int aPage ) = 0;
  114. /**
  115. * Function SetParameterValues
  116. * @param aPage is the page we want to set the parameters in
  117. * @param aValues are the values we want to set into the parameters
  118. * @return an array of parameter values
  119. */
  120. virtual wxString SetParameterValues( int aPage, wxArrayString& aValues ) = 0;
  121. /**
  122. * Function ResetParameters
  123. * Reset all wizard parameters to default values
  124. */
  125. virtual void ResetParameters() = 0;
  126. /**
  127. * Function GetModule
  128. * This method builds the module itself and returns it to the caller function
  129. * @return PCB module built from the parameters given to the class
  130. * @param aMessage a wxString to store messages (if any) generated by the
  131. * footprint generator
  132. */
  133. virtual MODULE* GetFootprint( wxString* aMessage ) = 0;
  134. /**
  135. * Function GetObject
  136. * This method gets the pointer to the object from where this wizard constructs
  137. * @return it's a void pointer, as it could be a PyObject or any other
  138. */
  139. virtual void* GetObject() = 0;
  140. /**
  141. * Function register_wizard
  142. * It's the standard method of a "FOOTPRINT_WIZARD" to register itself into
  143. * the FOOTPRINT_WIZARDS singleton manager
  144. */
  145. void register_wizard();
  146. };
  147. class FOOTPRINT_WIZARDS
  148. {
  149. private:
  150. /**
  151. * FOOTPRINT_WIZARD system wide static list
  152. */
  153. static std::vector<FOOTPRINT_WIZARD*> m_FootprintWizards;
  154. public:
  155. /**
  156. * Function register_wizard
  157. * A footprint wizard calls this static method when it wants to register itself
  158. * into the system wizards
  159. * Note: if it is already registered, this function do nothing
  160. * if n existing wizard with the same name exists, this existing wizard will be
  161. * unregistered.
  162. * @param aWizard is the footprint wizard to be registered
  163. */
  164. static void register_wizard( FOOTPRINT_WIZARD* aWizard );
  165. /**
  166. * Function deregister_object
  167. * Anyone calls this method to deregister an object which builds a wizard,
  168. * it will lookup on the vector calling GetObject until find, then removed
  169. * and deleted
  170. *
  171. * @param aObject is the footprint wizard object to be deregistered
  172. */
  173. static bool deregister_object( void* aObject );
  174. /**
  175. * Function GetWizard
  176. * @param aName is the footprint wizard name
  177. * @return a wizard object by it's name or NULL if it isn't available.
  178. */
  179. static FOOTPRINT_WIZARD* GetWizard( wxString aName );
  180. /**
  181. * Function GetWizard
  182. * @return a wizard object by it's number or NULL if it isn't available.
  183. * @param aIndex is the wizard index in list
  184. */
  185. static FOOTPRINT_WIZARD* GetWizard( int aIndex );
  186. /**
  187. * Function GetWizardsCount
  188. * @return the number of wizards available into the system
  189. */
  190. static int GetWizardsCount();
  191. };
  192. #endif /* PCBNEW_FOOTPRINT_WIZARDS_H */