forked from geoffreyPerrin/AutoCell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autocell.cpp
121 lines (98 loc) · 1.99 KB
/
autocell.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "autocell.h"
AutoCell::AutoCell(int width,int height, int cellStates,int nb_neighborhood, QString name):
width(width),height(height),cellStates(cellStates),
currentState(0),etats(0),neighborhood(QVector< QVector <int> >(nb_neighborhood, QVector<int>(1))),
name(name)
{
if(height>1)
{
neighborhood.push_back(QVector<int>(nb_neighborhood));
}
etats.push_back(Etat(height,width));
}
QVector<QVector<int> >AutoCell::getMatrice() const
{
return etats.last().getMatrice();
}
//void AutoCell::setMatrice(const QVector<QVector<int> > &value)
//{
// matrice = value;
//}
int AutoCell::getWidth() const
{
return width;
}
void AutoCell::setWidth(int value)
{
width = value;
}
int AutoCell::getHeight() const
{
return height;
}
void AutoCell::setHeight(int value)
{
height = value;
}
int AutoCell::getCellWidth() const
{
return cellWidth;
}
void AutoCell::setCellWidth(int value)
{
cellWidth = value;
}
int AutoCell::getCellHeight() const
{
return cellHeight;
}
void AutoCell::setCellHeight(int value)
{
cellHeight = value;
}
void AutoCell::setValueEtat(int numEtat, int i, int j, int val)
{
if(numEtat >= etats.size())
etats.push_back(Etat(etats[0].getMatrice().size(),etats[0].getMatrice()[0].size()));
etats[numEtat].setValue(i,j,val);
}
void AutoCell::reinit()
{
while(!etats.isEmpty())
etats.pop_front();
Etat e = etatInitial;
etats.push_back(e);
currentState=0;
}
QVector<QVector<int> > AutoCell::getNeighborhood() const
{
return neighborhood;
}
void AutoCell::setNeighborhood(const QVector<QVector<int> > &value)
{
neighborhood = value;
}
int AutoCell::getCurrentState() const
{
return currentState;
}
void AutoCell::setCurrentState(int value)
{
currentState = value;
}
QVector<Etat> AutoCell::getEtats() const
{
return etats;
}
void AutoCell::setEtats(const QVector<Etat> &value)
{
etats = value;
}
QString AutoCell::getName() const
{
return name;
}
void AutoCell::setName(const QString &value)
{
name = value;
}