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.

116 lines
3.2 KiB

3 years ago
3 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2016 CERN
  5. * Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * @author Maciej Suminski <maciej.suminski@cern.ch>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 3
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * https://www.gnu.org/licenses/gpl-3.0.html
  22. * or you may search the http://www.gnu.org website for the version 3 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. #ifndef TUNER_SLIDER_H
  27. #define TUNER_SLIDER_H
  28. #include "tuner_slider_base.h"
  29. #include <sim/spice_value.h>
  30. #include <sim/spice_generator.h>
  31. #include <wx/timer.h>
  32. class SIMULATOR_FRAME_UI;
  33. class SCH_SYMBOL;
  34. /**
  35. * Custom widget to handle quick component values modification and simulation on the fly.
  36. */
  37. class TUNER_SLIDER : public TUNER_SLIDER_BASE
  38. {
  39. public:
  40. TUNER_SLIDER( SIMULATOR_FRAME_UI* aPanel, wxWindow* aParent, const SCH_SHEET_PATH& aSheetPath,
  41. SCH_SYMBOL* aSymbol );
  42. wxString GetSymbolRef() const
  43. {
  44. return m_ref;
  45. }
  46. const SPICE_VALUE& GetMin() const
  47. {
  48. return m_min;
  49. }
  50. const SPICE_VALUE& GetMax() const
  51. {
  52. return m_max;
  53. }
  54. const SPICE_VALUE& GetValue() const
  55. {
  56. return m_value;
  57. }
  58. KIID GetSymbol( SCH_SHEET_PATH* aSheetPath ) const
  59. {
  60. *aSheetPath = m_sheetPath;
  61. return m_symbol;
  62. }
  63. bool SetValue( const SPICE_VALUE& aVal );
  64. bool SetMin( const SPICE_VALUE& aVal );
  65. bool SetMax( const SPICE_VALUE& aVal );
  66. void ShowChangedLanguage();
  67. private:
  68. void updateComponentValue();
  69. void updateSlider();
  70. void updateValueText();
  71. void updateMax();
  72. void updateValue();
  73. void updateMin();
  74. void onESeries( wxCommandEvent& event ) override;
  75. void onClose( wxCommandEvent& event ) override;
  76. void onSave( wxCommandEvent& event ) override;
  77. void onSliderScroll( wxScrollEvent& event ) override;
  78. void onSliderChanged( wxScrollEvent& event ) override;
  79. void onMaxKillFocus( wxFocusEvent& event ) override;
  80. void onValueKillFocus( wxFocusEvent& event ) override;
  81. void onMinKillFocus( wxFocusEvent& event ) override;
  82. void onMaxTextEnter( wxCommandEvent& event ) override;
  83. void onValueTextEnter( wxCommandEvent& event ) override;
  84. void onMinTextEnter( wxCommandEvent& event ) override;
  85. private:
  86. KIID m_symbol;
  87. SCH_SHEET_PATH m_sheetPath;
  88. wxString m_ref;
  89. SPICE_VALUE m_min;
  90. SPICE_VALUE m_max;
  91. SPICE_VALUE m_value;
  92. SIMULATOR_FRAME_UI* m_frame;
  93. };
  94. #endif /* TUNER_SLIDER_H */