-
Notifications
You must be signed in to change notification settings - Fork 0
/
fieldview.cpp
71 lines (68 loc) · 2.98 KB
/
fieldview.cpp
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
#include "fieldview.h"
#include "vector"
#include "Defines.h"
#include "iostream"
FieldView::FieldView(QWidget* parent=0):QGraphicsView(parent)
{
setScene(&Scene);
}
void FieldView::DrawField()
{
Scene.setBackgroundBrush(QBrush(Qt::green));
Scene.addRect(FIELD_BORDER,FIELD_BORDER,FIELD_WIDTH,FIELD_HEIGHT,QPen(QBrush(Qt::white),LINE_WIDTH_PIX));
Scene.addLine(FIELD_BORDER+FIELD_WIDTH/2,FIELD_BORDER,FIELD_BORDER+FIELD_WIDTH/2,FIELD_BORDER+FIELD_HEIGHT,QPen(Qt::white,LINE_WIDTH_PIX));
Scene.addEllipse(CENTER_X - CIRCLE_RADIUS_PIX,CENTER_Y - CIRCLE_RADIUS_PIX,CIRCLE_RADIUS_PIX*2,CIRCLE_RADIUS_PIX*2,QPen(QBrush(Qt::white),LINE_WIDTH_PIX));
}
void FieldView::DrawBall(const std::vector<QPoint>& robotPositions)
{
for(int i=0;i<robotPositions.size();i++)
{
Scene.addEllipse(robotPositions[i].x() - BALL_SIZE_PIX/2, robotPositions[i].y() - BALL_SIZE_PIX/2,BALL_SIZE_PIX,BALL_SIZE_PIX,QPen(QBrush(Qt::yellow),BALL_WIDTH_PIX));
}
update();
}
void FieldView::DrawBlueRobots(const std::vector<QPoint>& robotPositions)
{
for(int i=0;i<robotPositions.size();i++)
{
Scene.addEllipse(robotPositions[i].x() - ROBOT_SIZE_PIX/2, robotPositions[i].y() - ROBOT_SIZE_PIX/2,ROBOT_SIZE_PIX,ROBOT_SIZE_PIX,QPen(QBrush(Qt::blue),ROBOT_WIDTH_PIX));
// std::cout << " X : " << robotPositions[i].x() << " Y : " << robotPositions[i].y() <<std::endl;
}
update();
}
void FieldView::DrawRedRobots(const std::vector<QPoint>& robotPositions)
{
for(int i=0;i<robotPositions.size();i++)
{
Scene.addEllipse(robotPositions[i].x() - ROBOT_SIZE_PIX/2, robotPositions[i].y() - ROBOT_SIZE_PIX/2,ROBOT_SIZE_PIX,ROBOT_SIZE_PIX,QPen(QBrush(Qt::red),ROBOT_WIDTH_PIX));
// std::cout << " X : " << robotPositions[i].x() << " Y : " << robotPositions[i].y() <<std::endl;
}
update();
}
void FieldView::DrawBlackRobots(const std::vector<QPoint>& robotPositions)
{
for(int i=0;i<robotPositions.size();i++)
{
Scene.addEllipse(robotPositions[i].x() - ROBOT_SIZE_PIX/2, robotPositions[i].y() - ROBOT_SIZE_PIX/2,ROBOT_SIZE_PIX,ROBOT_SIZE_PIX,QPen(QBrush(Qt::white),ROBOT_WIDTH_PIX));
// std::cout << " X : " << robotPositions[i].x() << " Y : " << robotPositions[i].y() <<std::endl;
}
update();
}
void FieldView::DrawWhiteRobots(const std::vector<QPoint>& robotPositions)
{
for(int i=0;i<robotPositions.size();i++)
{
Scene.addEllipse(robotPositions[i].x() - ROBOT_SIZE_PIX/2, robotPositions[i].y() - ROBOT_SIZE_PIX/2,ROBOT_SIZE_PIX,ROBOT_SIZE_PIX,QPen(QBrush(Qt::white),ROBOT_WIDTH_PIX));
// std::cout << " X : " << robotPositions[i].x() << " Y : " << robotPositions[i].y() <<std::endl;
}
update();
}
void FieldView::DrawRef(const std::vector<QPoint>& robotPositions)
{
for(int i=0;i<robotPositions.size();i++)
{
Scene.addEllipse(robotPositions[i].x() - ROBOT_SIZE_PIX/2, robotPositions[i].y() - ROBOT_SIZE_PIX/2,ROBOT_SIZE_PIX,ROBOT_SIZE_PIX,QPen(QBrush(Qt::black),ROBOT_WIDTH_PIX));
// std::cout << " X : " << robotPositions[i].x() << " Y : " << robotPositions[i].y() <<std::endl;
}
update();
}