-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinetilemodel.cpp
executable file
·41 lines (35 loc) · 1021 Bytes
/
linetilemodel.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
#include "linetilemodel.h"
#include <QPainter>
LineTile::LineTile(QObject *parent) :
TileModel(parent)
{
// default CornerTile
this->north = TileModel::ON;
this->south = TileModel::ON;
}
LineTile::LineTile(const QVector<bool>& tile, QObject *parent):
TileModel(parent)
{
LineTile::setNodes(tile);
}
void LineTile::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->north = TileModel::ON;
this->south = TileModel::ON;
return;
}
this->clearNodes();
TileModel::setNodes(tile);
// get rotateAngle
if (!this->north){
if (this->rotateAngle % 360 != 270)
this->rotateAngle = 90;
} else {
if (this->rotateAngle % 360 != 180)
this->rotateAngle = 0;
}
emit this->nodesChanged();
}