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.

219 lines
6.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2011-2014 Jean-Pierre Charras
  5. * Copyright (C) 2004-2022 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 3
  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 along
  18. * with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * @file UnitSelector.h
  22. * a wxChoiceBox to select units in Pcb_Calculator
  23. */
  24. #ifndef UNIT_SELECTOR_H
  25. #define UNIT_SELECTOR_H
  26. #include <wx/string.h>
  27. #include <wx/choice.h>
  28. class UNIT_SELECTOR: public wxChoice
  29. {
  30. public:
  31. UNIT_SELECTOR( wxWindow *parent, wxWindowID id,
  32. const wxPoint& pos, const wxSize& size,
  33. const wxArrayString& choices, long style = 0 ):
  34. wxChoice( parent, id, pos, size, choices, style )
  35. {
  36. }
  37. /**
  38. * Function GetUnitScale
  39. * @return the scaling factor to convert users units
  40. * to normalized units (meter, herz, ohm, radian )
  41. */
  42. virtual double GetUnitScale() = 0;
  43. wxString GetUnitName()
  44. {
  45. return GetStringSelection();
  46. }
  47. };
  48. class UNIT_SELECTOR_LEN: public UNIT_SELECTOR
  49. {
  50. public:
  51. UNIT_SELECTOR_LEN( wxWindow *parent, wxWindowID id,
  52. const wxPoint& pos, const wxSize& size,
  53. const wxArrayString& choices, long style = 0 );
  54. /**
  55. * Function GetUnitScale
  56. * @return the scaling factor to convert users units
  57. * to normalized units (meter)
  58. */
  59. double GetUnitScale() override;
  60. };
  61. class UNIT_SELECTOR_THICKNESS: public UNIT_SELECTOR
  62. {
  63. public:
  64. UNIT_SELECTOR_THICKNESS( wxWindow *parent, wxWindowID id,
  65. const wxPoint& pos, const wxSize& size,
  66. const wxArrayString& choices, long style = 0 );
  67. /**
  68. * Function GetUnitScale
  69. * @return the scaling factor to convert users units
  70. * to normalized units (meter) including oz/ft^2
  71. */
  72. double GetUnitScale() override;
  73. };
  74. class UNIT_SELECTOR_FREQUENCY: public UNIT_SELECTOR
  75. {
  76. public:
  77. UNIT_SELECTOR_FREQUENCY( wxWindow *parent, wxWindowID id,
  78. const wxPoint& pos, const wxSize& size,
  79. const wxArrayString& choices, long style = 0 );
  80. /**
  81. * Function GetUnitScale
  82. * @return the scaling factor to convert users units
  83. * to normalized units (Hz)
  84. */
  85. double GetUnitScale() override;
  86. };
  87. class UNIT_SELECTOR_ANGLE: public UNIT_SELECTOR
  88. {
  89. public:
  90. UNIT_SELECTOR_ANGLE( wxWindow *parent, wxWindowID id,
  91. const wxPoint& pos, const wxSize& size,
  92. const wxArrayString& choices, long style = 0 );
  93. /**
  94. * Function GetUnitScale
  95. * @return the scaling factor to convert users units
  96. * to normalized units (Hz)
  97. */
  98. double GetUnitScale() override;
  99. };
  100. class UNIT_SELECTOR_RESISTOR: public UNIT_SELECTOR
  101. {
  102. public:
  103. UNIT_SELECTOR_RESISTOR( wxWindow *parent, wxWindowID id,
  104. const wxPoint& pos, const wxSize& size,
  105. const wxArrayString& choices, long style = 0 );
  106. /**
  107. * Function GetUnitScale
  108. * @return the scaling factor to convert users units
  109. * to normalized units (Hz)
  110. */
  111. double GetUnitScale() override;
  112. };
  113. class UNIT_SELECTOR_LINEAR_RESISTANCE : public UNIT_SELECTOR
  114. {
  115. public:
  116. UNIT_SELECTOR_LINEAR_RESISTANCE( wxWindow *parent, wxWindowID id,
  117. const wxPoint& pos, const wxSize& size,
  118. const wxArrayString& choices, long style = 0 );
  119. /**
  120. * Function GetUnitScale
  121. * @return the scaling factor to convert users units
  122. * to normalized units ( ohm/m )
  123. */
  124. double GetUnitScale() override;
  125. };
  126. class UNIT_SELECTOR_LEN_CABLE : public UNIT_SELECTOR
  127. {
  128. public:
  129. UNIT_SELECTOR_LEN_CABLE( wxWindow *parent, wxWindowID id,
  130. const wxPoint& pos, const wxSize& size,
  131. const wxArrayString& choices, long style = 0 );
  132. /**
  133. * Function GetUnitScale
  134. * @return the scaling factor to convert users units
  135. * to normalized units ( m )
  136. */
  137. double GetUnitScale() override;
  138. };
  139. class UNIT_SELECTOR_VOLTAGE : public UNIT_SELECTOR
  140. {
  141. public:
  142. UNIT_SELECTOR_VOLTAGE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
  143. const wxArrayString& choices, long style = 0 );
  144. /**
  145. * Function GetUnitScale
  146. * @return the scaling factor to convert users units
  147. * to normalized units ( V )
  148. */
  149. double GetUnitScale() override;
  150. };
  151. class UNIT_SELECTOR_POWER : public UNIT_SELECTOR
  152. {
  153. public:
  154. UNIT_SELECTOR_POWER( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
  155. const wxArrayString& choices, long style = 0 );
  156. /**
  157. * Function GetUnitScale
  158. * @return the scaling factor to convert users units
  159. * to normalized units ( W )
  160. */
  161. double GetUnitScale() override;
  162. };
  163. class UNIT_SELECTOR_SPEED : public UNIT_SELECTOR
  164. {
  165. public:
  166. UNIT_SELECTOR_SPEED( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
  167. const wxArrayString& choices, long style = 0 );
  168. /**
  169. * Function GetUnitScale
  170. * @return the scaling factor to convert users units
  171. * to normalized units ( ohm/m )
  172. */
  173. double GetUnitScale() override;
  174. };
  175. class UNIT_SELECTOR_TIME : public UNIT_SELECTOR
  176. {
  177. public:
  178. UNIT_SELECTOR_TIME( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
  179. const wxArrayString& choices, long style = 0 );
  180. /**
  181. * Function GetUnitScale
  182. * @return the scaling factor to convert users units
  183. * to normalized units ( ohm/m )
  184. */
  185. double GetUnitScale() override;
  186. };
  187. #endif // UNIT_SELECTOR_H