-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcell.cpp
executable file
·55 lines (46 loc) · 1.15 KB
/
cell.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
#include "cell.h"
#include <QPainter>
Cell::Cell(int x, int y, int size, QColor color, QColor wall, QGraphicsScene *scene)
{
visited = false;
idx = x;
idy = y;
cellSize = size;
cellColor = color;
wallColor = wall;
x *= size;
y *= size;
rect = new QGraphicsRectItem(x,y,size,size); //for marking
rect->setBrush(QBrush(cellColor, Qt::SolidPattern));
rect->setPen(Qt::NoPen);
rect->hide();
top = new QGraphicsLineItem (x, y, x+size, y);
top->setPen(wallColor);
right = new QGraphicsLineItem (x+size, y, x+size, y+size);
right->setPen(wallColor);
bottom = new QGraphicsLineItem (x, y+size, x+size, y+size);
bottom->setPen(wallColor);
left = new QGraphicsLineItem (x, y, x, y+size);
left->setPen(wallColor);
scene->addItem(top);
scene->addItem(bottom);
scene->addItem(left);
scene->addItem(right);
scene->addItem(rect);
}
bool Cell::isVisited() const
{
return visited;
}
void Cell::setVisited(bool state)
{
visited = state;
}
void Cell::Show()
{
rect->show();
}
void Cell::Hide()
{
rect->hide();
}