ZKDiagram.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * ZKDiagram.h
  3. *
  4. * Created on: Jul 31, 2017
  5. * Author: guoxs
  6. */
  7. #ifndef _CONTROL_ZKDIAGRAM_H_
  8. #define _CONTROL_ZKDIAGRAM_H_
  9. #include <vector>
  10. #include "ZKBase.h"
  11. class ZKDiagramPrivate;
  12. /**
  13. * @brief 波形图控件
  14. */
  15. class ZKDiagram : public ZKBase {
  16. ZK_DECLARE_PRIVATE(ZKDiagram)
  17. public:
  18. typedef enum {
  19. E_DIAGRAM_STYLE_LINE, // 折线
  20. E_DIAGRAM_STYLE_CURVE // 曲线
  21. } EDiagramStyle;
  22. public:
  23. ZKDiagram(ZKBase *pParent);
  24. virtual ~ZKDiagram();
  25. /**
  26. * @brief 设置波形线宽
  27. * @param index 波形索引值
  28. * @param width 波形线宽
  29. */
  30. void setPenWidth(int index, uint32_t width);
  31. /**
  32. * @brief 设置波形颜色
  33. * @param index 波形索引值
  34. * @param color 波形颜色值:0x RGB
  35. */
  36. void setPenColor(int index, uint32_t color);
  37. /**
  38. * @brief 设置波形X轴方向缩放比例
  39. * @param index 波形索引值
  40. * @param xScale X轴方向缩放比例
  41. */
  42. void setXScale(int index, float xScale);
  43. /**
  44. * @brief 设置波形Y轴方向缩放比例
  45. * @param index 波形索引值
  46. * @param yScale Y轴方向缩放比例
  47. */
  48. void setYScale(int index, float yScale);
  49. /**
  50. * @brief 设置波形数据
  51. * @param index 波形索引值
  52. * @param pPoints 坐标数组
  53. * @param count 数组长度
  54. */
  55. void setData(int index, const SZKPoint *pPoints, int count);
  56. /**
  57. * @brief 添加波形数据
  58. * @param index 波形索引值
  59. * @param data Y轴方向数据值
  60. */
  61. void addData(int index, float data);
  62. /**
  63. * @brief 清除波形图
  64. * @param index 波形索引值
  65. */
  66. void clear(int index);
  67. void addDiagramInfo(uint32_t width, uint32_t color, EDiagramStyle style,
  68. float xScale, float yScale, float step, uint32_t eraseSpace, bool isAntialiasOn);
  69. protected:
  70. ZKDiagram(ZKBase *pParent, ZKBasePrivate *pBP);
  71. virtual void onBeforeCreateWindow(const Json::Value &json);
  72. virtual const char* getClassName() const { return ZK_DIAGRAM; }
  73. virtual void onDraw(ZKCanvas *pCanvas);
  74. private:
  75. void parseDiagramAttributeFromJson(const Json::Value &json);
  76. };
  77. #endif /* _CONTROL_ZKDIAGRAM_H_ */