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.

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