-
Notifications
You must be signed in to change notification settings - Fork 2
/
robotbase.h
207 lines (177 loc) · 5.81 KB
/
robotbase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
* Copyright (C) Kreogist Dev Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef ROBOTBASE_H
#define ROBOTBASE_H
#include <QPointF>
#include <QColor>
#include <QRadialGradient>
/*!
* \brief The RobotBase class is a base class of robot, it contains all the
* basic functions of a robot.
*/
class RobotBase
{
public:
/*!
* \brief Construct a RobotBase class.
*/
RobotBase();
/*!
* \brief The position of the robot.
* \return The QPointF format robot position.
*/
QPointF pos() const;
/*!
* \brief Set the position of a robot.
* \param pos The position of the robot.
*/
void setPos(const QPointF &pos);
/*!
* \brief This is an overloaded function.\n
* Set the position of a robot.
* \param x The x position of the robot.
* \param y The y position of the robot.
*/
inline void setPos(qreal x, qreal y)
{
setPos(QPointF(x, y));
}
/*!
* \brief Paint the robot with the specific painter.
* \param painter The painting painter.
*/
void paintRobot(QPainter *painter);
/*!
* \brief Paint the parameter of the robot with the specific painter.\n
* The parameters of a robots include the range and angle.
* \param painter The painting painter.
*/
void paintRobotParameter(QPainter *painter);
/*!
* \brief Paint the detect area of the current robot with the specific
* painter.
* \param painter The painting painter.
*/
void paintRobotDetectArea(QPainter *painter);
/*!
* \brief Paint the detect area of the current enemy robot with the specific
* painter.
* \param painter The painting painter.
*/
void paintEnemyDetectArea(QPainter *painter);
/*!
* \brief Get the size of all the robots.
* \return The size of all robots.
*/
static int robotSize();
/*!
* \brief Change the size of all the robots.
* \param robotSize The new size of all robots.
*/
static void setRobotSize(int robotSize);
/*!
* \brief Get the detect radius of all the robots.
* \return The detect radius of all robots.
*/
static int detectRadius();
/*!
* \brief Change all the detect radius of all the robots.
* \param detectRadius The new detect radius of all the robots.
*/
static void setDetectRadius(int detectRadius);
/*!
* \brief Sets the color of the robot.
* \param robotColor The prefer color of all robots.
*/
static void setRobotColor(const QColor &robotColor);
/*!
* \brief Get the color of all robots.
* \return The QColor of the robots.
*/
static QColor robotColor();
/*!
* \brief Get the color of the detection radius border of the robots.
* \return The QColor of the detection radius border of the robots.
*/
static QColor detectRadiusColor();
/*!
* \brief Change the color of the robot detection radius border.
* \param robotColor The prefer color of all the detection radius border of
* robots.
*/
static void setDetectRadiusColor(const QColor &detectRadiusColor);
/*!
* \brief Get the moving angle of the robot. \n
* The default angle of the robot is 0 (3'o clock position).
* \return The angle of the robot.
*/
qreal angle() const;
/*!
* \brief Change the moving angle of the robot, the value should be ranged
* from 0 degrees to 360 degrees. The program will automatically change the
* value.
* \param angle The prefer angle of the robot.
*/
void setAngle(const qreal &angle);
/*!
* \brief Get the color the all the direction line color of the robots.
* \return The color of the direction line.
*/
static QColor directionLineColor();
/*!
* \brief Change the color of the direction line.
* \param directionLineColor The direction line color.
*/
static void setDirectionLineColor(const QColor &directionLineColor);
/*!
* \brief Initial the grapihcs parameters of all the Robot.
*/
static void initialRobotPatameters();
/*!
* \brief Get the color the all the robot border color.
* \return The QColor of all the robot border.
*/
static QColor robotBorder();
/*!
* \brief Change the color of the robot border.
* \param robotBorder The QColor of the robot border.
*/
static void setRobotBorder(const QColor &robotBorder);
/*!
* \brief Get the color the all the enemy border color.
* \return The QColor of all the enemy border.
*/
static QColor enemyRadiusColor();
/*!
* \brief Set the color of the enemy radius.
* \param enemyRadiusColor The QColor of the enemy.
*/
static void setEnemyRadiusColor(const QColor &enemyRadiusColor);
protected:
QPointF m_pos;
qreal m_angle;
static int m_robotSize, m_detectRadius;
static QColor m_robotColor;
static QColor m_detectRadiusColor;
static QColor m_directionLineColor;
static QColor m_robotBorder;
static QColor m_enemyRadiusColor;
static QRadialGradient m_detectRadiusGradient;
static QRadialGradient m_enemyRadiusGradient;
};
#endif // ROBOTBASE_H