-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjunctiontilemodel.cpp
More file actions
52 lines (45 loc) · 1.22 KB
/
Copy pathjunctiontilemodel.cpp
File metadata and controls
52 lines (45 loc) · 1.22 KB
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
#include "junctiontilemodel.h"
#include <QPainter>
JunctionTile::JunctionTile(QObject *parent) :
TileModel(parent)
{
// default CornerTile
this->east = TileModel::ON;
this->south = TileModel::ON;
this->west = TileModel::ON;
}
JunctionTile::JunctionTile(const QVector<bool>& tile, QObject *parent):
TileModel(parent)
{
JunctionTile::setNodes(tile);
}
void JunctionTile::setNodes(const QVector<bool>& tile)
{
// set default nodes if tile is invalid.
if (tile.size() == 0 ||
!(tile[TileModel::North] || tile[TileModel::East] || tile[TileModel::South] || tile[TileModel::West])) {
this->east = TileModel::ON;
this->south = TileModel::ON;
this->west = TileModel::ON;
return;
}
this->clearNodes();
TileModel::setNodes(tile);
// get rotateAngle
if (!this->north)
this->rotateAngle = 0;
else if (!this->east)
this->rotateAngle = 90;
else if (!this->south)
this->rotateAngle = 180;
else
this->rotateAngle = 270;
emit this->nodesChanged();
}
//bool JunctionTile::isValidTile()
//{
// QString nodeString = this->getNodeString();
// if (nodeString.size() == 3)
// return true;
// return false;
//}