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 
10 namespace rm_referee
11 {
12 class Graph
13 {
14 public:
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 
34  void setColor(const rm_referee::GraphColor& color)
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  }
93  bool isRepeated()
94  {
96  }
97  bool isString()
98  {
100  }
102  {
106  }
107 
108 private:
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 
114  std::vector<std::pair<int, int>> start_positions_{}, end_positions_{};
116  std::string title_{}, content_{}, last_title_{}, last_content_{};
117 };
118 
119 } // namespace rm_referee
rm_referee::Graph::start_positions_
std::vector< std::pair< int, int > > start_positions_
Definition: graph.h:114
rm_referee::Graph::initPosition
void initPosition(XmlRpc::XmlRpcValue value, std::vector< std::pair< int, int >> &positions)
Definition: graph.cpp:84
rm_referee::Base
Definition: data.h:142
rm_referee::Graph::end_positions_
std::vector< std::pair< int, int > > end_positions_
Definition: graph.h:114
rm_referee
Definition: data.h:100
rm_referee::Graph::getConfig
rm_referee::GraphConfig getConfig()
Definition: graph.h:25
rm_referee::Graph::setStartX
void setStartX(int start_x)
Definition: graph.h:75
rm_referee::GraphConfig::start_x
uint32_t start_x
Definition: protocol.h:448
rm_referee::Graph::setRadius
void setRadius(int radius)
Definition: graph.h:52
rm_referee::Graph::last_content_
std::string last_content_
Definition: graph.h:116
rm_referee::Graph::isString
bool isString()
Definition: graph.h:97
rm_referee::Graph::setIntNum
void setIntNum(int num)
Definition: graph.h:56
rm_referee::Graph::content_
std::string content_
Definition: graph.h:116
rm_referee::Graph::getCharacters
std::string getCharacters()
Definition: graph.h:29
rm_referee::STRING
@ STRING
Definition: protocol.h:173
rm_referee::GraphConfig::end_angle
uint32_t end_angle
Definition: protocol.h:446
rm_referee::Graph::setContent
void setContent(const std::string &content)
Definition: graph.h:38
rm_referee::Graph::last_config_
rm_referee::GraphConfig last_config_
Definition: graph.h:115
rm_referee::GraphConfig::graphic_type
uint32_t graphic_type
Definition: protocol.h:442
rm_referee::Graph::title_
std::string title_
Definition: graph.h:116
rm_referee::Graph::Graph
Graph(const XmlRpc::XmlRpcValue &config, Base &base, int id)
Definition: graph.cpp:7
rm_referee::GraphConfig::radius
uint32_t radius
Definition: protocol.h:450
rm_referee::Graph::config_
rm_referee::GraphConfig config_
Definition: graph.h:115
rm_referee::Graph::getType
rm_referee::GraphType getType(const std::string &type)
Definition: graph.cpp:119
rm_referee::Graph::last_title_
std::string last_title_
Definition: graph.h:116
rm_referee::Graph::updatePosition
void updatePosition(int index)
Definition: graph.cpp:70
rm_referee::Graph::isRepeated
bool isRepeated()
Definition: graph.h:93
rm_referee::GraphConfig::operate_type
uint32_t operate_type
Definition: protocol.h:441
rm_referee::Graph::setStartY
void setStartY(int start_y)
Definition: graph.h:79
rm_referee::Graph::setColor
void setColor(const rm_referee::GraphColor &color)
Definition: graph.h:34
rm_referee::GraphConfig::end_x
uint32_t end_x
Definition: protocol.h:451
rm_referee::GraphOperation
GraphOperation
Definition: protocol.h:144
rm_referee::Graph::base_
Base & base_
Definition: graph.h:113
rm_referee::Graph::setFloatNum
void setFloatNum(float data)
Definition: graph.h:65
rm_referee::Graph::setOperation
void setOperation(const rm_referee::GraphOperation &operation)
Definition: graph.h:17
rm_referee::GraphConfig::end_y
uint32_t end_y
Definition: protocol.h:452
rm_referee::Graph::setStartAngle
void setStartAngle(int start_angle)
Definition: graph.h:83
rm_referee::Graph::updateLastConfig
void updateLastConfig()
Definition: graph.h:101
rm_referee::GraphConfig::start_y
uint32_t start_y
Definition: protocol.h:449
rm_referee::GraphConfig::color
uint32_t color
Definition: protocol.h:444
data.h
ros_utilities.h
rm_referee::Graph::getColor
rm_referee::GraphColor getColor(const std::string &color)
Definition: graph.cpp:97
rm_referee::Graph::setEndY
void setEndY(int end_y)
Definition: graph.h:48
rm_referee::GraphType
GraphType
Definition: protocol.h:164
rm_referee::GraphColor
GraphColor
Definition: protocol.h:151
rm_referee::GraphConfig
Definition: protocol.h:438
rm_referee::Graph
Definition: graph.h:12
XmlRpc::XmlRpcValue
rm_referee::Graph::getOperation
int getOperation()
Definition: graph.h:21
rm_referee::Graph::setEndX
void setEndX(int end_x)
Definition: graph.h:44
rm_referee::Graph::setEndAngle
void setEndAngle(int end_angle)
Definition: graph.h:88
rm_referee::GraphConfig::start_angle
uint32_t start_angle
Definition: protocol.h:445


rm_referee
Author(s): Qiayuan Liao
autogenerated on Tue May 6 2025 02:23:49