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.

133 lines
3.7 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-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 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 _UnitSelector_h_
  25. #define _UnitSelector_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. virtual 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. virtual 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. virtual 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. virtual 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. virtual double GetUnitScale() override;
  112. };
  113. #endif // _UnitSelector_h_