-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcornertilemodel.cpp
executable file
·47 lines (37 loc) · 1.09 KB
/
cornertilemodel.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
#include <QPainter>
#include <QTimer>
#include "cornertilemodel.h"
CornerTile::CornerTile(QObject *parent) :
TileModel(parent)
{
// default CornerTile
this->east = TileModel::ON;
this->south = TileModel::ON;
}
CornerTile::CornerTile(const QVector<bool>& tile, QObject *parent):
TileModel(parent)
{
CornerTile::setNodes(tile);
}
void CornerTile::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;
return;
}
this->clearNodes();
TileModel::setNodes(tile);
// get rotateAngle
if (this->south && this->west)
this->rotateAngle = 90;
else if (this->west && this->north)
this->rotateAngle = 180;
else if (this->north && this->east)
this->rotateAngle = 270;
else
this->rotateAngle = 0;
emit this->nodesChanged();
}