-
Notifications
You must be signed in to change notification settings - Fork 0
/
save.cpp
39 lines (37 loc) · 806 Bytes
/
save.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
#include "save.h"
QTextStream& operator<<(QTextStream& t, const Geom& p)
{
t << "geom " << size(p) << " ";
for(int i = 0; i < size(p); i++) {
t << p.starts[i] << " " << p.ends[i] << " ";
}
return t;
}
QTextStream& operator<<(QTextStream& t, const QVector2D& v)
{
t << v.x() << " " << v.y();
return t;
}
QTextStream& operator>>(QTextStream& t, QVector2D& v)
{
float x,y;
t >> x >> y;
v.setX(x); v.setY(y);
return t;
}
QTextStream& operator>>(QTextStream& t, Geom& g)
{
int size;
QString hd;
t >> hd >> size;
assert(hd == "geom");
QVector<QVector2D> st,ed;
for(int i = 0; i < size; i++) {
QVector2D s, e;
t >> s >> e;
st.push_back(s); ed.push_back(e);
}
g.starts = st;
g.ends = ed;
return t;
}