-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTreeItem.cpp
201 lines (183 loc) · 4.19 KB
/
TreeItem.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#include <QtXml>
#include "TreeItem.h"
TreeItem::TreeItem( int row, TreeItem *parent)
{
Type = 255;
rowNumber = row;
parentItem = parent;
}
TreeItem::~TreeItem()
{
QHash<int,TreeItem*>::iterator it;
for (it = childItems.begin(); it != childItems.end(); ++it)
delete it.value();
}
TreeItem *TreeItem::parent()
{
return parentItem;
}
int TreeItem::row()
{
return rowNumber;
}
TreeItem * TreeStateItem::child(int i)
{
if (childItems.contains(i))
return childItems[i];
TreeItem * tmp = state->getChild(i, this);
childItems[i]=tmp;
return tmp;
}
TreeItem * TreeTransItem::child(int i)
{
if (childItems.contains(i))
return childItems[i];
if(tr->getSubtask()->getName().size()>0)
{
TreeTextItem * tmp = new TreeTextItem(i, this);
tmp->setNameAttr("Subtask", tr->getSubtask()->getName());
childItems[i]=tmp;
return tmp;
}
return 0;
}
TreeItem * TreeCoordItem::child(int i)
{
if (childItems.contains(i))
return childItems[i];
int index = i;
if(isProper(coords->getMotionType()))
{
if(index==0)
{
TreeTextItem * tmp = new TreeTextItem(i, this);
tmp->setNameAttr("MotionType", QString().fromStdString(MOTION_TYPE_TABLE[coords->getMotionType()]));
childItems[i]=tmp;
return tmp;
}
else
{
index--;
}
}
if(isProper(coords->getCoordType()))
{
if(index==0)
{
TreeTextItem * tmp = new TreeTextItem(i, this);
tmp->setNameAttr("CoordType", QString().fromStdString(COORD_TYPE_TABLE[coords->getCoordType()]));
childItems[i]=tmp;
return tmp;
}
else
{
index--;
}
}
foreach(Pose * pos, coords->getPoses())
{
if(index==0)
{
TreePoseItem * tmp = new TreePoseItem(i, this);
tmp->setPos(pos);
childItems[i]=tmp;
return tmp;
}
else
{
index--;
}
}
return 0;
}
TreeItem * TreeRobotSetItem::child(int i)
{
int index=i;
if (childItems.contains(i))
return childItems[i];
foreach(Robot rob, set)
{
if(index==0)
{
TreeTextItem * tmp = new TreeTextItem(i, this);
tmp->setNameAttr("Robot", QString().fromStdString(ROBOT_TABLE[rob]));
childItems[i]=tmp;
return tmp;
}
else
{
index--;
}
}
return 0;
}
TreeItem * TreeInitItem::child(int i)
{
if (childItems.contains(i))
return childItems[i];
int index = i;
for(unsigned int j=0;j<init.init_values.size();j++)
{
if(index==0)
{
std::pair<GeneratorType, int> myPair=init.init_values[j];
TreeTextItem * tmp = new TreeTextItem(i, this);
char table[10];
sprintf(table,"%d", myPair.second);
tmp->setNameAttr(QString().fromStdString(GENERATOR_TYPE_TABLE[myPair.first]), table);
childItems[i]=tmp;
return tmp;
}
else
{
index--;
}
}
return 0;
}
TreeItem *TreePoseItem::child(int i)
{
if (childItems.contains(i))
return childItems[i];
std::vector<double> a;
QString tmpName;
if(i==0)
{
a = pos->getA();
tmpName = QString("Accelerations");
}
else if(i==1)
{
a = pos->getV();
tmpName = QString("Velocities");
}
else if(i==2)
{
a = pos->getC();
tmpName = QString("Coordinates");
}
else
{
return 0;
}
QString value;
TreeTextItem * tmp = new TreeTextItem(i, this);
for(unsigned int j = 0;j<a.size();j++)
{
char table[10];
sprintf(table,"%lf ", a[j]);
value.append(table);
}
tmp->setNameAttr(tmpName, value);
childItems[i]=tmp;
return tmp;
}
TreeItem * TreeGraphItem::child(int i)
{
if (childItems.contains(i))
return childItems[i];
TreeStateItem * tmp = new TreeStateItem(i, this);
childItems[i]=tmp;
tmp->setState(Model->mod->getState(gr, i));
return tmp;
}