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.

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