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.

137 lines
4.0 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 change_log.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 UnitSelector.h
  26. * a wxChoiceBox to select units in Pcb_Calculator
  27. */
  28. #ifndef _UnitSelector_h_
  29. #define _UnitSelector_h_
  30. #include <wx/string.h>
  31. #include <wx/choice.h>
  32. class UNIT_SELECTOR: public wxChoice
  33. {
  34. public:
  35. UNIT_SELECTOR( wxWindow *parent, wxWindowID id,
  36. const wxPoint& pos, const wxSize& size,
  37. const wxArrayString& choices, long style = 0 ):
  38. wxChoice( parent, id, pos, size, choices, style )
  39. {
  40. }
  41. /**
  42. * Function GetUnitScale
  43. * @return the scaling factor to convert users units
  44. * to normalized units (meter, herz, ohm, radian )
  45. */
  46. virtual double GetUnitScale() = 0;
  47. wxString GetUnitName()
  48. {
  49. return GetStringSelection();
  50. }
  51. };
  52. class UNIT_SELECTOR_LEN: public UNIT_SELECTOR
  53. {
  54. public:
  55. UNIT_SELECTOR_LEN( wxWindow *parent, wxWindowID id,
  56. const wxPoint& pos, const wxSize& size,
  57. const wxArrayString& choices, long style = 0 );
  58. /**
  59. * Function GetUnitScale
  60. * @return the scaling factor to convert users units
  61. * to normalized units (meter)
  62. */
  63. virtual double GetUnitScale() override;
  64. };
  65. class UNIT_SELECTOR_THICKNESS: public UNIT_SELECTOR
  66. {
  67. public:
  68. UNIT_SELECTOR_THICKNESS( wxWindow *parent, wxWindowID id,
  69. const wxPoint& pos, const wxSize& size,
  70. const wxArrayString& choices, long style = 0 );
  71. /**
  72. * Function GetUnitScale
  73. * @return the scaling factor to convert users units
  74. * to normalized units (meter) including oz/ft^2
  75. */
  76. virtual double GetUnitScale() override;
  77. };
  78. class UNIT_SELECTOR_FREQUENCY: public UNIT_SELECTOR
  79. {
  80. public:
  81. UNIT_SELECTOR_FREQUENCY( wxWindow *parent, wxWindowID id,
  82. const wxPoint& pos, const wxSize& size,
  83. const wxArrayString& choices, long style = 0 );
  84. /**
  85. * Function GetUnitScale
  86. * @return the scaling factor to convert users units
  87. * to normalized units (Hz)
  88. */
  89. virtual double GetUnitScale() override;
  90. };
  91. class UNIT_SELECTOR_ANGLE: public UNIT_SELECTOR
  92. {
  93. public:
  94. UNIT_SELECTOR_ANGLE( wxWindow *parent, wxWindowID id,
  95. const wxPoint& pos, const wxSize& size,
  96. const wxArrayString& choices, long style = 0 );
  97. /**
  98. * Function GetUnitScale
  99. * @return the scaling factor to convert users units
  100. * to normalized units (Hz)
  101. */
  102. virtual double GetUnitScale() override;
  103. };
  104. class UNIT_SELECTOR_RESISTOR: public UNIT_SELECTOR
  105. {
  106. public:
  107. UNIT_SELECTOR_RESISTOR( wxWindow *parent, wxWindowID id,
  108. const wxPoint& pos, const wxSize& size,
  109. const wxArrayString& choices, long style = 0 );
  110. /**
  111. * Function GetUnitScale
  112. * @return the scaling factor to convert users units
  113. * to normalized units (Hz)
  114. */
  115. virtual double GetUnitScale() override;
  116. };
  117. #endif // _UnitSelector_h_