|
1 # Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # |
|
3 # Permission is hereby granted, free of charge, to any person obtaining a |
|
4 # copy of this software and /or associated documentation files |
|
5 # (the "Materials "), to deal in the Materials without restriction, |
|
6 # including without limitation the rights to use, copy, modify, merge, |
|
7 # publish, distribute, sublicense, and/or sell copies of the Materials, |
|
8 # and to permit persons to whom the Materials are furnished to do so, |
|
9 # subject to the following conditions: |
|
10 # |
|
11 # The above copyright notice and this permission notice shall be included |
|
12 # in all copies or substantial portions of the Materials. |
|
13 # |
|
14 # THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
15 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
16 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
17 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
|
18 # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
19 # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR |
|
20 # THE USE OR OTHER DEALINGS IN THE MATERIALS. |
|
21 |
|
22 import sys |
|
23 import matplotlib |
|
24 matplotlib.use("wxAgg") |
|
25 import matplotlib.pyplot |
|
26 import lines |
|
27 |
|
28 |
|
29 if __name__ == '__main__': |
|
30 |
|
31 start = 0 |
|
32 if len(sys.argv) > 2: |
|
33 start = int(sys.argv[1]) |
|
34 |
|
35 minx = 65535. |
|
36 miny = 65535. |
|
37 maxx = -65535. |
|
38 maxy = -65535. |
|
39 |
|
40 z = zip(lines.lines[::2], lines.lines[1::2]) |
|
41 |
|
42 if len(sys.argv) == 2: |
|
43 end = int(sys.argv[1]) |
|
44 elif len(sys.argv) > 2: |
|
45 end = int(sys.argv[2]) |
|
46 else: |
|
47 assert(len(sys.argv) == 1) |
|
48 end = len(z) |
|
49 |
|
50 print start, end |
|
51 |
|
52 legend = False |
|
53 if end - start < 10: |
|
54 legend = True |
|
55 |
|
56 for seg in z: |
|
57 px0 = seg[0][0]/128. |
|
58 py0 = seg[0][1]/8. |
|
59 px1 = seg[1][0]/128. |
|
60 py1 = seg[1][1]/8. |
|
61 minx = min(px0, minx) |
|
62 miny = min(py0, miny) |
|
63 maxx = max(px0, maxx) |
|
64 maxy = max(py0, maxy) |
|
65 minx = min(px1, minx) |
|
66 miny = min(py1, miny) |
|
67 maxx = max(px1, maxx) |
|
68 maxy = max(py1, maxy) |
|
69 |
|
70 currLegend = 0 |
|
71 for seg in z[start:end]: |
|
72 px0 = seg[0][0]/128. |
|
73 py0 = seg[0][1]/8. |
|
74 px1 = seg[1][0]/128. |
|
75 py1 = seg[1][1]/8. |
|
76 |
|
77 if not legend: |
|
78 matplotlib.pyplot.plot([px0, px1], [py0, py1]) |
|
79 else: |
|
80 matplotlib.pyplot.plot([px0, px1], [py0, py1], label = str(currLegend)) |
|
81 currLegend += 1 |
|
82 |
|
83 minx = min(minx, miny) |
|
84 maxx = max(maxx, maxy) |
|
85 |
|
86 #matplotlib.pyplot.plot(x, y) |
|
87 matplotlib.pyplot.axis([minx,maxx,minx,maxx]) |
|
88 if legend: |
|
89 matplotlib.pyplot.legend() |
|
90 matplotlib.pyplot.show() |
|
91 |