Team Fortress 2 Source Code as on 22/4/2020
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.

81 lines
2.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef GRAPHPANEL_H
  7. #define GRAPHPANEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <vgui_controls/Panel.h>
  12. #include "utllinkedlist.h"
  13. #include "utlvector.h"
  14. namespace vgui
  15. {
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Holds and displays a chart
  18. //-----------------------------------------------------------------------------
  19. class GraphPanel : public Panel
  20. {
  21. DECLARE_CLASS_SIMPLE( GraphPanel, Panel );
  22. public:
  23. GraphPanel(Panel *parent, const char *name);
  24. // domain settings (x-axis settings)
  25. // sets the window of samples to display
  26. void SetDisplayDomainSize(float size);
  27. // sets the range of samples the graph should keep
  28. // should be set to the max you would set the display domain size
  29. void SetMaxDomainSize(float size);
  30. // sets the minimum domain that will be displayed; used to collapse samples
  31. void SetMinDomainSize(float size);
  32. // range settings (y-axis settings)
  33. void SetUseFixedRange(float lowRange, float highRange);
  34. void SetUseDynamicRange(float *rangeList, int numRanges);
  35. void GetDisplayedRange(float &lowRange, float &highRange);
  36. // adds an item to the end of the list
  37. // sampleEnd is assumed to be the trailing edge of the sample
  38. // assumes that the samples are fairly evenly spaced (not much more work to do to fix this though)
  39. void AddItem(float sampleEnd, float sampleValue);
  40. protected:
  41. virtual void Paint();
  42. virtual void PerformLayout();
  43. virtual void ApplySchemeSettings(IScheme *pScheme);
  44. private:
  45. int GetVisibleItemCount();
  46. struct Sample_t
  47. {
  48. float sampleEnd;
  49. float value;
  50. };
  51. CUtlLinkedList<Sample_t, int> m_Samples;
  52. // the window to show
  53. float m_flDomainSize;
  54. float m_flMaxDomainSize, m_flMinDomainSize;
  55. bool m_bMaxDomainSizeSet;
  56. // range
  57. float m_flLowRange, m_flHighRange;
  58. bool m_bUseDynamicRange;
  59. CUtlVector<float> m_RangeList;
  60. // rendering
  61. int m_iGraphBarWidth;
  62. int m_iGraphBarGapWidth;
  63. };
  64. } // namespace vgui
  65. #endif // GRAPHPANEL_H