rm_control
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
graph.h
Go to the documentation of this file.
1//
2// Created by peter on 2021/7/19.
3//
4
5#pragma once
6
9
10namespace rm_referee
11{
12class Graph
13{
14public:
15 explicit Graph(const XmlRpc::XmlRpcValue& config, Base& base, int id);
16 void updatePosition(int index);
18 {
19 config_.operate_type = operation;
20 }
22 {
23 return config_.operate_type;
24 }
26 {
27 return config_;
28 }
29 std::string getCharacters()
30 {
31 return title_ + content_;
32 }
33
35 {
36 config_.color = color;
37 }
38 void setContent(const std::string& content)
39 {
40 content_ = content;
41 if (!title_.empty() || !content_.empty())
42 config_.end_angle = static_cast<int>((title_ + content_).size());
43 }
44 void setEndX(int end_x)
45 {
46 config_.end_x = end_x;
47 }
48 void setEndY(int end_y)
49 {
50 config_.end_y = end_y;
51 }
52 void setRadius(int radius)
53 {
54 config_.radius = radius;
55 }
56 void setIntNum(int num)
57 {
58 int a = num & 1023;
59 int b = (num >> 10) & 2047;
60 int c = num >> 21;
61 config_.radius = a;
62 config_.end_x = b;
63 config_.end_y = c;
64 }
65 void setFloatNum(float data)
66 {
67 int num = static_cast<int>(data * 1000);
68 int a = num & 1023;
69 int b = (num >> 10) & 2047;
70 int c = num >> 21;
71 config_.radius = a;
72 config_.end_x = b;
73 config_.end_y = c;
74 }
75 void setStartX(int start_x)
76 {
77 config_.start_x = start_x;
78 }
79 void setStartY(int start_y)
80 {
81 config_.start_y = start_y;
82 }
83 void setStartAngle(int start_angle)
84 {
85 if (0 <= start_angle && start_angle <= 360)
86 config_.start_angle = start_angle;
87 }
88 void setEndAngle(int end_angle)
89 {
90 if (0 <= end_angle && end_angle <= 360)
91 config_.end_angle = end_angle;
92 }
94 {
95 return config_ == last_config_ && title_ == last_title_ && content_ == last_content_;
96 }
97 bool isString()
98 {
100 }
102 {
103 last_content_ = content_;
104 last_title_ = title_;
105 last_config_ = config_;
106 }
107
108private:
109 void initPosition(XmlRpc::XmlRpcValue value, std::vector<std::pair<int, int>>& positions);
110 rm_referee::GraphColor getColor(const std::string& color);
111 rm_referee::GraphType getType(const std::string& type);
112
113 Base& base_;
114 std::vector<std::pair<int, int>> start_positions_{}, end_positions_{};
115 rm_referee::GraphConfig config_{}, last_config_{};
116 std::string title_{}, content_{}, last_title_{}, last_content_{};
117};
118
119} // namespace rm_referee
Definition data.h:112
Definition graph.h:13
void setStartX(int start_x)
Definition graph.h:75
void setOperation(const rm_referee::GraphOperation &operation)
Definition graph.h:17
rm_referee::GraphConfig getConfig()
Definition graph.h:25
void setColor(const rm_referee::GraphColor &color)
Definition graph.h:34
void setRadius(int radius)
Definition graph.h:52
void setEndY(int end_y)
Definition graph.h:48
void setStartAngle(int start_angle)
Definition graph.h:83
void setIntNum(int num)
Definition graph.h:56
Graph(const XmlRpc::XmlRpcValue &config, Base &base, int id)
Definition graph.cpp:7
int getOperation()
Definition graph.h:21
bool isRepeated()
Definition graph.h:93
void updatePosition(int index)
Definition graph.cpp:70
void setContent(const std::string &content)
Definition graph.h:38
void setFloatNum(float data)
Definition graph.h:65
void updateLastConfig()
Definition graph.h:101
void setEndAngle(int end_angle)
Definition graph.h:88
bool isString()
Definition graph.h:97
void setEndX(int end_x)
Definition graph.h:44
void setStartY(int start_y)
Definition graph.h:79
std::string getCharacters()
Definition graph.h:29
Definition data.h:101
GraphType
Definition protocol.h:165
@ STRING
Definition protocol.h:173
GraphColor
Definition protocol.h:152
GraphOperation
Definition protocol.h:145
Definition protocol.h:439
uint32_t start_x
Definition protocol.h:448
uint32_t start_angle
Definition protocol.h:445
uint32_t radius
Definition protocol.h:450
uint32_t color
Definition protocol.h:444
uint32_t end_x
Definition protocol.h:451
uint32_t end_y
Definition protocol.h:452
uint32_t graphic_type
Definition protocol.h:442
uint32_t start_y
Definition protocol.h:449
uint32_t end_angle
Definition protocol.h:446
uint32_t operate_type
Definition protocol.h:441