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.

143 lines
4.6 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 The 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 transline_ident.h
  22. */
  23. #ifndef TRANSLINE_IDENT_H
  24. #define TRANSLINE_IDENT_H
  25. #include <vector>
  26. #include "transline/transline.h"
  27. // Forward declare the bitmaps enum from bitmaps/bitmap_list.h
  28. enum class BITMAPS : unsigned int;
  29. // An enum to handle muwave shapes:
  30. enum TRANSLINE_TYPE_ID {
  31. START_OF_LIST_TYPE = 0,
  32. DEFAULT_TYPE = START_OF_LIST_TYPE,
  33. MICROSTRIP_TYPE = DEFAULT_TYPE,
  34. CPW_TYPE,
  35. GROUNDED_CPW_TYPE,
  36. RECTWAVEGUIDE_TYPE,
  37. COAX_TYPE,
  38. C_MICROSTRIP_TYPE,
  39. STRIPLINE_TYPE,
  40. TWISTEDPAIR_TYPE,
  41. END_OF_LIST_TYPE
  42. };
  43. // A Class to handle parameters
  44. enum PRM_TYPE {
  45. PRM_TYPE_SUBS,
  46. PRM_TYPE_PHYS,
  47. PRM_TYPE_ELEC,
  48. PRM_TYPE_FREQUENCY
  49. };
  50. /**
  51. * A class to handle one parameter of transline.
  52. */
  53. class TRANSLINE_PRM
  54. {
  55. public:
  56. /**
  57. * @param aKeywordCfg is the keyword used in config to identify the parameter
  58. * only ASCII7 keyword is valid.
  59. * @param aDlgLabel is a I18n string used to identify the parameter in dialog.
  60. * usually aDlgLabel is same as aKeywordCfg, but translatable.
  61. */
  62. TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg = "",
  63. const wxString& aDlgLabel = wxEmptyString,
  64. const wxString& aToolTip = wxEmptyString,
  65. double aValue = 0.0, bool aConvUnit = false );
  66. double ToUserUnit();
  67. double FromUserUnit();
  68. PRM_TYPE m_Type; // Type of parameter: substr, physical, elect
  69. PRMS_ID m_Id; // Id of parameter ( link to transline functions )
  70. std::string m_KeyWord; // keyword for this parameter in json config file in ASCII7 only
  71. wxString m_DlgLabel; // name for this parameter in dialog (usually translated
  72. wxString m_ToolTip; // Tool tip for this parameter in dialog
  73. double m_Value; // Value for this parameter in dialog
  74. double m_DefaultValue; // Default value for this parameter from CTOR build
  75. double m_NormalizedValue; // actual value for this parameter
  76. bool m_ConvUnit; // true if an unit selector must be used
  77. void* m_ValueCtrl; // The text ctrl containing the value in dialog
  78. void* m_UnitCtrl; // The UNIT_SELECTOR containing the unit in dialog
  79. int m_UnitSelection; // last selection for units
  80. };
  81. /**
  82. * A class to handle a list of parameters of a given transline.
  83. *
  84. * @note The first string of TRANSLINE_PRM (m_KeyWord) is a keyword in config file.
  85. * It can contain only ASCII7 chars. The second string of TRANSLINE_PRM is a
  86. * string translated for dialog so mark it for translation. Do not mark translatable
  87. * m_DlgLabel that obviously cannot be translated, like "H" or "H_t".
  88. */
  89. class TRANSLINE_IDENT
  90. {
  91. public:
  92. TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType );
  93. ~TRANSLINE_IDENT();
  94. // Add a new param in list
  95. void AddPrm( TRANSLINE_PRM* aParam )
  96. {
  97. m_prms_List.push_back( aParam );
  98. }
  99. TRANSLINE_PRM* GetPrm( unsigned aIdx ) const
  100. {
  101. if( aIdx < m_prms_List.size() )
  102. return m_prms_List[aIdx];
  103. else
  104. return nullptr;
  105. }
  106. unsigned GetPrmsCount() const
  107. {
  108. return m_prms_List.size();
  109. }
  110. void ReadConfig();
  111. void WriteConfig();
  112. public:
  113. enum TRANSLINE_TYPE_ID m_Type; // The type of transline handled
  114. BITMAPS m_BitmapName; // The name of the bitmap to display in dialogs
  115. TRANSLINE* m_TLine; // The TRANSLINE itself
  116. wxArrayString m_Messages; // messages for results
  117. // true if selection of parameters must be enabled in dialog menu.
  118. bool m_HasPrmSelection;
  119. private:
  120. std::vector<TRANSLINE_PRM*> m_prms_List;
  121. };
  122. #endif // TRANSLINE_IDENT_H