A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
grid.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3import cairo
4import sys
5import re
6import gtk
7
8
9
11
17 def __init__(self, start = 0, end = 0, value = ''):
18 """! Initializer
19 @param self this object
20 @param start start
21 @param end end
22 @param value value
23 """
24 self.start = start
25 self.end = end
26 self.value = value
27
29
33 def __init__(self, at = 0, value = ''):
34 """! Initializer
35 @param self this object
36 @param at you
37 @param value value
38 """
39 self.at = at
40 self.value = value
41
43
47 def __init__(self, at = 0, value = 0.0):
48 """! Initializer
49 @param self this object
50 @param at you
51 @param value value
52 """
53 self.at = at
54 self.value = value
55
57
61 def __init__(self, at = 0, value = 0.0):
62 """! Initializer
63 @param self this object
64 @param at you
65 @param value value
66 """
67 self.at = at
68 self.value = value
69def ranges_cmp(a, b):
70 diff = a.start - b.start
71 if diff < 0:
72 return -1
73 elif diff > 0:
74 return +1
75 else:
76 return 0
77def events_cmp(a, b):
78 diff = a.at - b.at
79 if diff < 0:
80 return -1
81 elif diff > 0:
82 return +1
83 else:
84 return 0
85
87
91 def __init__(self, name = ''):
92 """! Initializer
93 @param self this object
94 @param name name
95 """
96 self.name = name
97 self.ranges = []
98 return
99 def __search(self, key):
100 """! Search
101 @param self this object
102 @param key key
103 @return index if found or -1 if not found
104 """
105 l = 0
106 u = len(self.ranges)-1
107 while l <= u:
108 i = int((l + u) / 2)
109 if key >= self.ranges[i].start and key <= self.ranges[i].end:
110 return i
111 elif key < self.ranges[i].start:
112 u = i - 1
113 else:
114 # key > self.ranges[i].end
115 l = i + 1
116 return - 1
117 def add_range(self, range):
118 """! Add range
119 @param self this object
120 @param range range
121 @return none
122 """
123 self.ranges.append(range)
124 def get_all(self):
125 """! Get all ranges
126 @param self this object
127 @return the ranges
128 """
129 return self.ranges
130 def get_ranges(self, start, end):
131 """! Get selected ranges
132 @param self this object
133 @param start range start
134 @param end range end
135 @return the range or and empty list
136 """
137 s = self.__search(start)
138 e = self.__search(end)
139 if s == -1 and e == -1:
140 return []
141 elif s == -1:
142 return self.ranges[0:e + 1]
143 elif e == -1:
144 return self.ranges[s:len(self.ranges)]
145 else:
146 return self.ranges[s:e + 1]
147 def get_ranges_bounds(self, start, end):
148 """! Get ranges bounds
149 @param self this object
150 @param start range start
151 @param end range end
152 @return range
153 """
154 s = self.__search(start)
155 e = self.__search(end)
156 if s == -1 and e == -1:
157 return(0, 0)
158 elif s == -1:
159 return(0, e + 1)
160 elif e == -1:
161 return(s, len(self.ranges))
162 else:
163 return(s, e + 1)
164 def sort(self):
165 """! Sort ranges
166 @param self this object
167 @return none
168 """
169 self.ranges.sort(ranges_cmp)
170 def get_bounds(self):
171 """! Get bounds
172 @param self this object
173 @return the bounds
174 """
175 if len(self.ranges) > 0:
176 lo = self.ranges[0].start
177 hi = self.ranges[len(self.ranges)-1].end
178 return(lo, hi)
179 else:
180 return(0, 0)
181
183
187 def __init__(self, name = ''):
188 """! Get ranges bounds
189 @param self this object
190 @param name name
191 """
192 self.name = name
193 self.events = []
194 def __search(self, key):
195 """! Search function
196 @param self this object
197 @param key the key
198 @return event index
199 """
200 l = 0
201 u = len(self.events)-1
202 while l <= u:
203 i = int((l + u) / 2)
204 if key == self.events[i].at:
205 return i
206 elif key < self.events[i].at:
207 u = i - 1
208 else:
209 # key > self.events[i].at
210 l = i + 1
211 return l
212 def add_event(self, event):
213 """! Add Event
214 @param self this object
215 @param event event to add
216 @return none
217 """
218 self.events.append(event)
219 def get_events(self, start, end):
220 """! Get Events
221 @param self this object
222 @param start starting event
223 @param end ending event
224 @return the events
225 """
226 s = self.__search(start)
227 e = self.__search(end)
228 return self.events[s:e + 1]
229 def get_events_bounds(self, start, end):
230 """! Get Events Bounds
231 @param self this object
232 @param start starting event
233 @param end ending event
234 @return event bounds
235 """
236 s = self.__search(start)
237 e = self.__search(end)
238 return(s, e + 1)
239 def sort(self):
240 """! Sort function
241 @param self this object
242 @return none
243 """
244 self.events.sort(events_cmp)
245 def get_bounds(self):
246 """! Get Bounds
247 @param self this object
248 @return the bounds
249 """
250 if len(self.events) > 0:
251 lo = self.events[0].at
252 hi = self.events[-1].at
253 return(lo, hi)
254 else:
255 return(0, 0)
256
257
259
267 def __init__(self, name = ''):
268 """! Initializer
269 @param self this object
270 @param name name
271 """
272 self.ranges = []
273 self.event_str = []
274 self.event_int = []
275 self.name = name
276 def get_range(self, name):
277 """! Get range
278 @param self this object
279 @param name name
280 @return the range
281 """
282 for range in self.ranges:
283 if range.name == name:
284 return range
285 timeline = TimelineDataRange(name)
286 self.ranges.append(timeline)
287 return timeline
288 def get_event_str(self, name):
289 """! Get Event String
290 @param self this object
291 @param name name
292 @return the event string
293 """
294 for event_str in self.event_str:
295 if event_str.name == name:
296 return event_str
297 timeline = TimelineEvent(name)
298 self.event_str.append(timeline)
299 return timeline
300 def get_event_int(self, name):
301 """! Get Event Int
302 @param self this object
303 @param name name
304 @return eevent int
305 """
306 for event_int in self.event_int:
307 if event_int.name == name:
308 return event_int
309 timeline = TimelineEvent(name)
310 self.event_int.append(timeline)
311 return timeline
312 def get_ranges(self):
313 """! Get Ranges
314 @param self this object
315 @return the ranges
316 """
317 return self.ranges
318 def get_events_str(self):
319 """! Get Events string
320 @param self this object
321 @return event string
322 """
323 return self.event_str
324 def get_events_int(self):
325 """! Get Events int
326 @param self this object
327 @return evrnt int
328 """
329 return self.event_int
330 def sort(self):
331 """! Sort the ranges and events
332 @param self this object
333 @return none
334 """
335 for range in self.ranges:
336 range.sort()
337 for event in self.event_int:
338 event.sort()
339 for event in self.event_str:
340 event.sort()
341 def get_bounds(self):
342 """! Get Bounds
343 @param self this object
344 @return the bounds
345 """
346 lo = 0
347 hi = 0
348 for range in self.ranges:
349 (range_lo, range_hi) = range.get_bounds()
350 if range_lo < lo:
351 lo = range_lo
352 if range_hi > hi:
353 hi = range_hi
354 for event_str in self.event_str:
355 (ev_lo, ev_hi) = event_str.get_bounds()
356 if ev_lo < lo:
357 lo = ev_lo
358 if ev_hi > hi:
359 hi = ev_hi
360 for event_int in self.event_int:
361 (ev_lo, ev_hi) = event_int.get_bounds()
362 if ev_lo < lo:
363 lo = ev_lo
364 if ev_hi > hi:
365 hi = ev_hi
366 return(lo, hi)
367
368
370
372 def __init__(self):
373 """ Initializer
374 @param self: this object
375 """
376 self.timelines = []
377 def get(self, name):
378 """! Get Timeline
379 @param self this object
380 @param name name
381 @return the timeline for the name
382 """
383 for timeline in self.timelines:
384 if timeline.name == name:
385 return timeline
386 timeline = Timeline(name)
387 self.timelines.append(timeline)
388 return timeline
389 def get_all(self):
390 """! Get All Timeline
391 @param self this object
392 @return all timelines
393 """
394 return self.timelines
395 def sort(self):
396 """! Sort the timelines
397 @param self this object
398 @return none
399 """
400 for timeline in self.timelines:
401 timeline.sort()
402 def get_bounds(self):
403 """! Get Bounds
404 @param self this object
405 @return the bounds for all timelines
406 """
407 lo = 0
408 hi = 0
409 for timeline in self.timelines:
410 (t_lo, t_hi) = timeline.get_bounds()
411 if t_lo < lo:
412 lo = t_lo
413 if t_hi > hi:
414 hi = t_hi
415 return(lo, hi)
417 """! Get All Ranges
418 @param self this object
419 @return the keys for all ranges
420 """
421 range_values = {}
422 for timeline in self.timelines:
423 for ranges in timeline.get_ranges():
424 for ran in ranges.get_all():
425 range_values[ran.value] = 1
426 return range_values.keys()
427
428
429class Color:
430
436 def __init__(self, r = 0.0, g = 0.0, b = 0.0):
437 """! Initializer
438 @param self: this object
439 @param r: red
440 @param g: green
441 @param b: blue
442 """
443 self.r = r
444 self.g = g
445 self.b = b
446 def set(self, r, g, b):
447 """! Set color
448 @param self: this object
449 @param r: red
450 @param g: green
451 @param b: blue
452 @return none
453 """
454 self.r = r
455 self.g = g
456 self.b = b
457
458
459class Colors:
460
465 default_colors = [Color(1, 0, 0), Color(0, 1, 0), Color(0, 0, 1), Color(1, 1, 0), Color(1, 0, 1), Color(0, 1, 1)]
466 def __init__(self):
467 """! Initializer
468 @param self this object
469 """
470 self.__colors = {}
471 def add(self, name, color):
472 """! Add
473 @param self this object
474 @param name name of the color
475 @param color color value
476 @return none
477 """
478 self.__colors[name] = color
479 def lookup(self, name):
480 """! Lookup name
481 @param self this object
482 @param name name
483 @return named color
484 """
485 if not self.__colors.has_key(name):
486 self.add(name, self.default_colors.pop())
487 return self.__colors.get(name)
488
489
491
501 def __init__(self):
502 """! Initializer
503 @param self this object
504 """
505 self.__padding = 10
506 def set_padding(self, padding):
507 """! Set padding
508 @param self this object
509 @param padding padding
510 @return none
511 """
512 self.__padding = padding
513 def set_legends(self, legends, colors):
514 """! Set padding
515 @param self this object
516 @param legends legends
517 @param colors colors
518 @return none
519 """
520 self.__legends = legends
521 self.__colors = colors
522 def layout(self, width):
523 """! Set padding
524 @param self this object
525 @param width width
526 @return none
527 """
528 self.__width = width
529 surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 1, 1)
530 ctx = cairo.Context(surface)
531 line_height = 0
532 total_height = self.__padding
533 line_used = self.__padding
534 for legend in self.__legends:
535 (t_width, t_height) = ctx.text_extents(legend)[2:4]
536 item_width = self.__padding + self.__padding + t_width + self.__padding
537 item_height = t_height + self.__padding
538 if item_height > line_height:
539 line_height = item_height
540 if line_used + item_width > self.__width:
541 line_used = self.__padding + item_width
542 total_height += line_height
543 else:
544 line_used += item_width
545 x = line_used - item_width
546 total_height += line_height
547 self.__height = total_height
548
549 def get_height(self):
550 """! Set padding
551 @param self this object
552 @return height
553 """
554 return self.__height
555 def draw(self, ctx):
556 """! Set padding
557 @param self this object
558 @param ctx ctx
559 @return none
560 """
561 i = 0
562 line_height = 0
563 total_height = self.__padding
564 line_used = self.__padding
565 for legend in self.__legends:
566 (t_width, t_height) = ctx.text_extents(legend)[2:4]
567 item_width = self.__padding + self.__padding + t_width + self.__padding
568 item_height = t_height + self.__padding
569 if item_height > line_height:
570 line_height = item_height
571 if line_used + item_width > self.__width:
572 line_used = self.__padding + item_width
573 total_height += line_height
574 else:
575 line_used += item_width
576 x = line_used - item_width
577 ctx.rectangle(x, total_height, self.__padding, self.__padding)
578 ctx.set_source_rgb(0, 0, 0)
579 ctx.set_line_width(2)
580 ctx.stroke_preserve()
581 ctx.set_source_rgb(self.__colors[i].r,
582 self.__colors[i].g,
583 self.__colors[i].b)
584 ctx.fill()
585 ctx.move_to(x + self.__padding*2, total_height + t_height)
586 ctx.set_source_rgb(0, 0, 0)
587 ctx.show_text(legend)
588 i += 1
589
590 return
591
592
594
616 def __init__(self):
617 """! Initializer
618 @param self this object
619 """
620 self.padding = 10
621 return
622 def get_height(self):
623 """! Get Height
624 @param self this object
625 @return height
626 """
627 return self.height
628 def set_timelines(self, timelines, colors):
629 """! Set Timelines
630 @param self this object
631 @param timelines timelines
632 @param colors colors
633 @return none
634 """
635 self.timelines = timelines
636 self.colors = colors
637 def set_render_range(self, start, end):
638 """! Set Render Range
639 @param self this object
640 @param start start
641 @param end end
642 @return none
643 """
644 self.start = start
645 self.end = end
647 """! Get Data X Start
648 @param self: this object
649 @return X start
650 """
651 return self.padding / 2 + self.left_width + self.padding + self.right_width + self.padding / 2
652 def layout(self, width):
653 """! Get Data X Start
654 @param self this object
655 @param width width
656 @return none
657 """
658 surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 1, 1)
659 ctx = cairo.Context(surface)
660 max_text_height = ctx.text_extents("ABCDEFGHIJKLMNOPQRSTUVWXYZabcedefghijklmnopqrstuvwxyz0123456789")[3]
661
662 left_width = 0
663 right_width = 0
664 left_n_lines = 0
665 range_n = 0
666 eventint_n = 0
667 eventstr_n = 0
668 for timeline in self.timelines.get_all():
669 left_n_lines += 1
670 t_width = ctx.text_extents(timeline.name)[2]
671 left_width = max(left_width, t_width)
672 for rang in timeline.get_ranges():
673 t_width = ctx.text_extents(rang.name)[2]
674 right_width = max(right_width, t_width)
675 range_n += 1
676 for events_int in timeline.get_events_int():
677 t_width = ctx.text_extents(events_int.name)[2]
678 right_width = max(right_width, t_width)
679 eventint_n += 1
680 for events_str in timeline.get_events_str():
681 t_width = ctx.text_extents(events_str.name)[2]
682 right_width = max(right_width, t_width)
683 eventstr_n += 1
684
685 left_height = left_n_lines * max_text_height + (left_n_lines - 1) * self.padding
686 right_n_lines = range_n + eventint_n + eventstr_n
687 right_height = (right_n_lines - 1) * self.padding + right_n_lines * max_text_height
688 right_data_height = (eventint_n + eventstr_n) * (max_text_height + 5) + range_n * 10
689 right_data_height += (right_n_lines - 1) * self.padding
690
691 height = max(left_height, right_height)
692 height = max(height, right_data_height)
693
694 self.left_width = left_width
695 self.right_width = right_width
696 self.max_text_height = max_text_height
697 self.width = width
698 self.height = height + self.padding
699 def draw_line(self, ctx, x, y, width, height):
700 """! Draw Line
701 @param self this object
702 @param ctx ctx
703 @param x x
704 @param y y
705 @param width width
706 @param height height
707 @return none
708 """
709 ctx.move_to(x, y)
710 ctx.rel_line_to(width, height)
711 ctx.close_path()
712 ctx.set_operator(cairo.OPERATOR_SOURCE)
713 ctx.set_line_width(1.0)
714 ctx.set_source_rgb(0, 0, 0)
715 ctx.stroke()
716 def draw_events(self, ctx, events, x, y, width, height):
717 """! Draw Event
718 @param self this object
719 @param ctx ctx
720 @param events events
721 @param x x
722 @param y y
723 @param width width
724 @param height height
725 @return none
726 """
727 if (self.grey_background % 2) == 0:
728 ctx.rectangle(x, y - self.padding / 2,
729 width, height + self.padding)
730 ctx.set_source_rgb(0.9, 0.9, 0.9)
731 ctx.fill()
732 last_x_drawn = int(x)
733 (lo, hi) = events.get_events_bounds(self.start, self.end)
734 for event in events.events[lo:hi]:
735 real_x = int(x + (event.at - self.start) * width / (self.end - self.start))
736 if real_x > last_x_drawn + 2:
737 ctx.rectangle(real_x, y, 1, 1)
738 ctx.set_source_rgb(1, 0, 0)
739 ctx.stroke()
740 ctx.move_to(real_x, y + self.max_text_height)
741 ctx.set_source_rgb(0, 0, 0)
742 ctx.show_text(str(event.value))
743 last_x_drawn = real_x
744 self.grey_background += 1
745 def draw_ranges(self, ctx, ranges, x, y, width, height):
746 """! Draw Ranges
747 @param self this object
748 @param ctx ctx
749 @param ranges ranges
750 @param x x
751 @param y y
752 @param width width
753 @param height height
754 @return none
755 """
756 if (self.grey_background % 2) == 0:
757 ctx.rectangle(x, y - self.padding / 2,
758 width, height + self.padding)
759 ctx.set_source_rgb(0.9, 0.9, 0.9)
760 ctx.fill()
761 last_x_drawn = int(x - 1)
762 (lo, hi) = ranges.get_ranges_bounds(self.start, self.end)
763 for data_range in ranges.ranges[lo:hi]:
764 s = max(data_range.start, self.start)
765 e = min(data_range.end, self.end)
766 x_start = int(x + (s - self.start) * width / (self.end - self.start))
767 x_end = int(x + (e - self.start) * width / (self.end - self.start))
768 if x_end > last_x_drawn:
769 ctx.rectangle(x_start, y, x_end - x_start, 10)
770 ctx.set_source_rgb(0, 0, 0)
771 ctx.stroke_preserve()
772 color = self.colors.lookup(data_range.value)
773 ctx.set_source_rgb(color.r, color.g, color.b)
774 ctx.fill()
775 last_x_drawn = x_end
776
777 self.grey_background += 1
778
779 def draw(self, ctx):
780 """! Draw
781 @param self this object
782 @param ctx ctx
783 @return none
784 """
785 timeline_top = 0
786 top_y = self.padding / 2
787 left_x_start = self.padding / 2
788 left_x_end = left_x_start + self.left_width
789 right_x_start = left_x_end + self.padding
790 right_x_end = right_x_start + self.right_width
791 data_x_start = right_x_end + self.padding / 2
792 data_x_end = self.width
793 data_width = data_x_end - data_x_start
794 cur_y = top_y
795 self.draw_line(ctx, 0, 0, self.width, 0)
797 for timeline in self.timelines.get_all():
798 (y_bearing, t_width, t_height) = ctx.text_extents(timeline.name)[1:4]
799 ctx.move_to(left_x_start, cur_y + self.max_text_height - (t_height + y_bearing))
800 ctx.show_text(timeline.name);
801 for events_int in timeline.get_events_int():
802 (y_bearing, t_width, t_height) = ctx.text_extents(events_int.name)[1:4]
803 ctx.move_to(right_x_start, cur_y + self.max_text_height - (t_height + y_bearing))
804 ctx.show_text(events_int.name)
805 self.draw_events(ctx, events_int, data_x_start, cur_y, data_width, self.max_text_height + 5)
806 cur_y += self.max_text_height + 5 + self.padding
807 self.draw_line(ctx, right_x_start - self.padding / 2, cur_y - self.padding / 2,
808 self.right_width + self.padding, 0)
809
810 for events_str in timeline.get_events_str():
811 (y_bearing, t_width, t_height) = ctx.text_extents(events_str.name)[1:4]
812 ctx.move_to(right_x_start, cur_y + self.max_text_height - (t_height + y_bearing))
813 ctx.show_text(events_str.name)
814 self.draw_events(ctx, events_str, data_x_start, cur_y, data_width, self.max_text_height + 5)
815 cur_y += self.max_text_height + 5 + self.padding
816 self.draw_line(ctx, right_x_start - self.padding / 2, cur_y - self.padding / 2,
817 self.right_width + self.padding, 0)
818 for ranges in timeline.get_ranges():
819 (y_bearing, t_width, t_height) = ctx.text_extents(ranges.name)[1:4]
820 ctx.move_to(right_x_start, cur_y + self.max_text_height - (t_height + y_bearing))
821 ctx.show_text(ranges.name)
822 self.draw_ranges(ctx, ranges, data_x_start, cur_y, data_width, 10)
823 cur_y += self.max_text_height + self.padding
824 self.draw_line(ctx, right_x_start - self.padding / 2, cur_y - self.padding / 2,
825 self.right_width + self.padding, 0)
826 self.draw_line(ctx, 0, cur_y - self.padding / 2,
827 self.width, 0)
828 bot_y = cur_y - self.padding / 2
829 self.draw_line(ctx, left_x_end + self.padding / 2, 0,
830 0, bot_y)
831 self.draw_line(ctx, right_x_end + self.padding / 2, 0,
832 0, bot_y)
833 return
834
835
837
851 def __init__(self):
852 """! Initializer
853 @param self this object
854 """
855 self.__top = 0
856 return
857 def set_bounds(self, lo, hi):
858 """! Set Bounds
859 @param self this object
860 @param lo lo
861 @param hi hi
862 @return none
863 """
864 self.__lo = lo
865 self.__hi = hi
866 def get_position(self, x):
867 """! Get Position
868 @param self this object
869 @param x x
870 @return real x
871 """
872 real_x = (x - self.__lo ) * self.__width / (self.__hi - self.__lo)
873 return real_x
874 def set_top(self):
875 """! Set Top
876 @param self this object
877 @return none
878 """
879 self.__top = 1
880 def set_bot(self):
881 """! Set Bottom
882 @param self this object
883 @return none
884 """
885 self.__top = 0
886 def layout(self, width):
887 """! Layout
888 @param self this object
889 @param width width
890 @return none
891 """
892 surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 1, 1)
893 ctx = cairo.Context(surface)
894
895 # calculate scale delta
896 data_delta = self.__hi - self.__lo
897 closest = 1
898 while (closest*10) < data_delta:
899 closest *= 10
900 if (data_delta / closest) == 0:
901 delta = closest
902 elif(data_delta / closest) == 1:
903 delta = closest / 10
904 else:
905 delta = closest
906 start = self.__lo - (self.__lo % delta) + delta
907 end = self.__hi - (self.__hi % delta)
908
909 self.__delta = delta
910 self.__width = width
911
912 # calculate text height
913 max_text_height = ctx.text_extents("ABCDEFGHIJKLMNOPQRSTUVWXYZabcedefghijklmnopqrstuvwxyz0123456789")[3]
914 self.max_text_height = max_text_height
915 height = max_text_height + 10
916 self.__height = height
917
918 def get_height(self):
919 """! Get Height
920 @param self: this object
921 @return height
922 """
923 return self.__height
924 def draw(self, ctx):
925 """! Draw
926 @param self this object
927 @param ctx ctx
928 @return none
929 """
930 delta = self.__delta
931 start = self.__lo - (self.__lo % delta) + delta
932 end = self.__hi - (self.__hi % delta)
933
934 if self.__top == 1:
935 s = -1
936 else:
937 s = 1
938 # print scale points
939 ctx.set_source_rgb(0, 0, 0)
940 ctx.set_line_width(1.0)
941 ticks = range(int(start), int(end + delta), int(delta))
942 for x in ticks:
943 real_x = (x - self.__lo ) * self.__width / (self.__hi - self.__lo)
944 ctx.move_to(real_x, 0)
945 ctx.line_to(real_x, 5*s)
946 ctx.close_path()
947 ctx.stroke()
948 (t_y_bearing, t_width, t_height) = ctx.text_extents(str(x))[1:4]
949 if self.__top:
950 text_delta = t_height + t_y_bearing
951 else:
952 text_delta = -t_y_bearing
953 ctx.move_to(real_x - t_width / 2, (5 + 5 + text_delta)*s)
954 ctx.show_text(str(x))
955 # draw subticks
956 delta /= 10
957 if delta > 0:
958 start = self.__lo - (self.__lo % delta) + delta
959 end = self.__hi - (self.__hi % delta)
960 for x in range(int(start), int(end + delta), int(delta)):
961 real_x = (x - self.__lo ) * self.__width / (self.__hi - self.__lo)
962 ctx.move_to(real_x, 0)
963 ctx.line_to(real_x, 3*s)
964 ctx.close_path()
965 ctx.stroke()
966
967
968
970
992 def __init__(self, start, end):
993 """! Initializer
994 @param self this object
995 @param start start
996 @param end end
997 """
998 self.__start = float(start)
999 self.__end = float(end)
1001 self.__mid_scale.set_top()
1003 self.__bot_scale.set_bounds(start, end)
1004 self.__bot_scale.set_bot()
1005 self.__width = 1
1006 self.__height = 1
1007 def get_width(self):
1008 """! Get Width
1009 @param self: this object
1010 @return width
1011 """
1012 return self.__width
1013 def get_height(self):
1014 """! Get Height
1015 @param self this object
1016 @return height
1017 """
1018 return self.__height
1019 # return x, y, width, height
1021 """! Get Data Rectangle
1022 @param self this object
1023 @return rectangle
1024 """
1025 y_start = self.__top_legend.get_height()
1026 x_start = self.__data.get_data_x_start()
1027 return(x_start, y_start, self.__width - x_start, self.__data.get_height())
1028 def scale_data(self, x):
1029 """! Get Data Rectangle
1030 @param self this object
1031 @param x x
1032 @return scaled x
1033 """
1034 x_start = self.__data.get_data_x_start()
1035 x_scaled = x / (self.__width - x_start) * (self.__r_end - self.__r_start)
1036 return x_scaled
1037 # return x, y, width, height
1039 """! Get Selection Rectangle
1040 @param self this object
1041 @return rectangle
1042 """
1043 y_start = self.__top_legend.get_height() + self.__data.get_height() + self.__mid_scale.get_height() + 20
1044 y_height = self.__bot_scale.get_height() + 20
1045 x_start = self.__bot_scale.get_position(self.__r_start)
1046 x_end = self.__bot_scale.get_position(self.__r_end)
1047 return(x_start, y_start, x_end - x_start, y_height)
1048 def scale_selection(self, x):
1049 """! Scale Selection
1050 @param self this object
1051 @param x the X
1052 @return scaled X
1053 """
1054 x_scaled = x / self.__width * (self.__end - self.__start)
1055 return x_scaled
1056 def set_range(self, start, end):
1057 """! Set Range
1058 @param self this object
1059 @param start start
1060 @param end end
1061 @return none
1062 """
1063 s = min(start, end)
1064 e = max(start, end)
1065 start = max(self.__start, s)
1066 end = min(self.__end, e)
1067 self.__r_start = start
1068 self.__r_end = end
1069 self.__data.set_render_range(start, end)
1070 self.__mid_scale.set_bounds(start, end)
1071 self.layout(self.__width, self.__height)
1072 def get_range(self):
1073 """! Get Range
1074 @param self this object
1075 @return range
1076 """
1077 return(self.__r_start, self.__r_end)
1078 def set_data(self, data):
1079 """! Set Date
1080 @param self this object
1081 @param data data
1082 @return none
1083 """
1084 self.__data = data
1085 def set_top_legend(self, top_legend):
1086 """! Set Top Legend
1087 @param self this object
1088 @param top_legend The legend
1089 @return none
1090 """
1091 self.__top_legend = top_legend
1092 def layout(self, width, height):
1093 """! Set Layout
1094 @param self this object
1095 @param width width
1096 @param height height
1097 @return none
1098 """
1099 self.__width = width
1100 self.__height = height
1101 self.__top_legend.layout(width)
1102 top_legend_height = self.__top_legend.get_height()
1103 self.__data.layout(width)
1104 self.__mid_scale.layout(width - self.__data.get_data_x_start())
1105 self.__bot_scale.layout(width)
1106 return
1107 def __x_pixel(self, x, width):
1108 """! X Pixel
1109 @param self this object
1110 @param x x
1111 @param width width
1112 @return x pixel
1113 """
1114 new_x = (x - self.__start) * width / (self.__end - self.__start)
1115 return new_x
1116
1117 def draw(self, ctx):
1118 """! Draw
1119 @param self this object
1120 @param ctx ctx
1121 @return none
1122 """
1123 # default background is white
1124 ctx.save()
1125 ctx.set_source_rgb(1, 1, 1)
1126 ctx.set_operator(cairo.OPERATOR_SOURCE)
1127 ctx.rectangle(0, 0, self.__width, self.__height)
1128 ctx.fill()
1129
1130 # top legend
1131 ctx.save()
1132 self.__top_legend.draw(ctx)
1133 top_legend_height = self.__top_legend.get_height()
1134 ctx.restore()
1135
1136 # separation line
1137 ctx.move_to(0, top_legend_height)
1138 ctx.line_to(self.__width, top_legend_height)
1139 ctx.close_path()
1140 ctx.set_line_width(2)
1141 ctx.set_source_rgb(0, 0, 0)
1142 ctx.stroke()
1143
1144 # data
1145 ctx.save()
1146 ctx.translate(0,
1147 top_legend_height)
1148 self.__data.draw(ctx)
1149 ctx.restore()
1150
1151 # scale below data
1152 ctx.save()
1153 ctx.translate(self.__data.get_data_x_start(),
1154 top_legend_height + self.__data.get_height() + self.__mid_scale.get_height())
1155 self.__mid_scale.draw(ctx)
1156 ctx.restore()
1157
1158 height_used = top_legend_height + self.__data.get_height() + self.__mid_scale.get_height()
1159
1160 # separation between scale and left pane
1161 ctx.move_to(self.__data.get_data_x_start(), height_used)
1162 ctx.rel_line_to(0, -self.__mid_scale.get_height())
1163 ctx.close_path()
1164 ctx.set_source_rgb(0, 0, 0)
1165 ctx.set_line_width(2)
1166 ctx.stroke()
1167
1168 # separation below scale
1169 ctx.move_to(0, height_used)
1170 ctx.line_to(self.__width, height_used)
1171 ctx.close_path()
1172 ctx.set_line_width(2)
1173 ctx.set_source_rgb(0, 0, 0)
1174 ctx.stroke()
1175
1176 select_start = self.__bot_scale.get_position(self.__r_start)
1177 select_end = self.__bot_scale.get_position(self.__r_end)
1178
1179 # left connection between top scale and bottom scale
1180 ctx.move_to(0, height_used);
1181 ctx.line_to(self.__data.get_data_x_start(), height_used)
1182 ctx.line_to(select_start, height_used + 20)
1183 ctx.line_to(0, height_used + 20)
1184 ctx.line_to(0, height_used)
1185 ctx.set_source_rgb(0, 0, 0)
1186 ctx.set_line_width(1)
1187 ctx.stroke_preserve()
1188 ctx.set_source_rgb(0.9, 0.9, 0.9)
1189 ctx.fill()
1190
1191 # right connection between top scale and bottom scale
1192 ctx.move_to(self.__width, height_used)
1193 ctx.line_to(self.__width, height_used + 20)
1194 ctx.line_to(select_end, height_used + 20)
1195 ctx.line_to(self.__width, height_used)
1196 ctx.set_source_rgb(0, 0, 0)
1197 ctx.set_line_width(1)
1198 ctx.stroke_preserve()
1199 ctx.set_source_rgb(0.9, 0.9, 0.9)
1200 ctx.fill()
1201
1202 height_used += 20
1203
1204 # unused area background
1205 unused_start = self.__bot_scale.get_position(self.__r_start)
1206 unused_end = self.__bot_scale.get_position(self.__r_end)
1207 unused_height = self.__bot_scale.get_height() + 20
1208 ctx.rectangle(0, height_used,
1209 unused_start,
1210 unused_height)
1211 ctx.rectangle(unused_end,
1212 height_used,
1213 self.__width - unused_end,
1214 unused_height)
1215 ctx.set_source_rgb(0.9, 0.9, 0.9)
1216 ctx.fill()
1217
1218 # border line around bottom scale
1219 ctx.move_to(unused_end, height_used)
1220 ctx.line_to(self.__width, height_used)
1221 ctx.line_to(self.__width, height_used + unused_height)
1222 ctx.line_to(0, height_used + unused_height)
1223 ctx.line_to(0, height_used)
1224 ctx.line_to(unused_start, height_used)
1225 ctx.close_path()
1226 ctx.set_line_width(2)
1227 ctx.set_source_rgb(0, 0, 0)
1228 ctx.stroke()
1229 ctx.move_to(unused_start, height_used)
1230 ctx.line_to(unused_end, height_used)
1231 ctx.close_path()
1232 ctx.set_line_width(1)
1233 ctx.set_source_rgb(0.9, 0.9, 0.9)
1234 ctx.stroke()
1235
1236 # unused area dot borders
1237 ctx.save()
1238 ctx.move_to(max(unused_start, 2), height_used)
1239 ctx.rel_line_to(0, unused_height)
1240 ctx.move_to(min(unused_end, self.__width - 2), height_used)
1241 ctx.rel_line_to(0, unused_height)
1242 ctx.set_dash([5], 0)
1243 ctx.set_source_rgb(0, 0, 0)
1244 ctx.set_line_width(1)
1245 ctx.stroke()
1246 ctx.restore()
1247
1248 # bottom scale
1249 ctx.save()
1250 ctx.translate(0, height_used)
1251 self.__bot_scale.draw(ctx)
1252 ctx.restore()
1253
1254
1255class GtkGraphicRenderer(gtk.DrawingArea):
1256
1286 def __init__(self, data):
1287 """! Initializer
1288 @param self this object
1289 @param data data
1290 """
1291 super(GtkGraphicRenderer, self).__init__()
1292 self.__data = data
1293 self.__moving_left = False
1294 self.__moving_right = False
1295 self.__moving_both = False
1296 self.__moving_top = False
1298 self.add_events(gtk.gdk.POINTER_MOTION_MASK)
1299 self.add_events(gtk.gdk.BUTTON_PRESS_MASK)
1300 self.add_events(gtk.gdk.BUTTON_RELEASE_MASK)
1301 self.connect("expose_event", self.expose)
1302 self.connect('size-allocate', self.size_allocate)
1303 self.connect('motion-notify-event', self.motion_notify)
1304 self.connect('button-press-event', self.button_press)
1305 self.connect('button-release-event', self.button_release)
1307 """! Set Smaller Zoom
1308 @param self this object
1309 @return none
1310 """
1311 (start, end) = self.__data.get_range()
1312 self.__data.set_range(start, start + (end - start)*2)
1313 self.__force_full_redraw = True
1314 self.queue_draw()
1316 """! Set Bigger Zoom
1317 @param self this object
1318 @return none
1319 """
1320 (start, end) = self.__data.get_range()
1321 self.__data.set_range(start, start + (end - start) / 2)
1322 self.__force_full_redraw = True
1323 self.queue_draw()
1324 def output_png(self, filename):
1325 """! Output PNG
1326 @param self this object
1327 @param filename file name
1328 @return none
1329 """
1330 surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
1331 self.__data.get_width(),
1332 self.__data.get_height())
1333 ctx = cairo.Context(self.__buffer_surface)
1334 self.__data.draw(ctx)
1335 surface.write_to_png(filename)
1336 def button_press(self, widget, event):
1337 """! Button Press
1338 @param self this object
1339 @param widget widget
1340 @param event event
1341 @return true if button has been pressed otherwise false
1342 """
1343 (x, y, width, height) = self.__data.get_selection_rectangle()
1344 (d_x, d_y, d_width, d_height) = self.__data.get_data_rectangle()
1345 if event.y > y and event.y < y + height:
1346 if abs(event.x - x) < 5:
1347 self.__moving_left = True
1348 return True
1349 if abs(event.x - (x + width)) < 5:
1350 self.__moving_right = True
1351 return True
1352 if event.x > x and event.x < x + width:
1353 self.__moving_both = True
1354 self.__moving_both_start = event.x
1355 self.__moving_both_cur = event.x
1356 return True
1357 if event.y > d_y and event.y < (d_y + d_height):
1358 if event.x > d_x and event.x < (d_x + d_width):
1359 self.__moving_top = True
1360 self.__moving_top_start = event.x
1361 self.__moving_top_cur = event.x
1362 return True
1363 return False
1364 def button_release(self, widget, event):
1365 """! Button Release
1366 @param self this object
1367 @param widget widget
1368 @param event event
1369 @return true if button was released otherwise false
1370 """
1371 if self.__moving_left:
1372 self.__moving_left = False
1373 left = self.__data.scale_selection(self.__moving_left_cur)
1374 right = self.__data.get_range()[1]
1375 self.__data.set_range(left, right)
1376 self.__force_full_redraw = True
1377 self.queue_draw()
1378 return True
1379 if self.__moving_right:
1380 self.__moving_right = False
1381 right = self.__data.scale_selection(self.__moving_right_cur)
1382 left = self.__data.get_range()[0]
1383 self.__data.set_range(left, right)
1384 self.__force_full_redraw = True
1385 self.queue_draw()
1386 return True
1387 if self.__moving_both:
1388 self.__moving_both = False
1389 delta = self.__data.scale_selection(self.__moving_both_cur - self.__moving_both_start)
1390 (left, right) = self.__data.get_range()
1391 self.__data.set_range(left + delta, right + delta)
1392 self.__force_full_redraw = True
1393 self.queue_draw()
1394 return True
1395 if self.__moving_top:
1396 self.__moving_top = False
1397 return False
1398 def motion_notify(self, widget, event):
1399 """! Motion Notify
1400 @param self this object
1401 @param widget widget
1402 @param event event
1403 @return true if moving otherwise false
1404 """
1405 (x, y, width, height) = self.__data.get_selection_rectangle()
1406 if self.__moving_left:
1407 if event.x <= 0:
1409 elif event.x >= x + width:
1410 self.__moving_left_cur = x + width
1411 else:
1412 self.__moving_left_cur = event.x
1413 self.queue_draw_area(0, int(y), int(self.__width), int(height))
1414 return True
1415 if self.__moving_right:
1416 if event.x >= self.__width:
1417 self.__moving_right = self.__width
1418 elif event.x < x:
1420 else:
1421 self.__moving_right_cur = event.x
1422 self.queue_draw_area(0, int(y), int(self.__width), int(height))
1423 return True
1424 if self.__moving_both:
1425 cur_e = self.__width - (x + width - self.__moving_both_start)
1426 cur_s = (self.__moving_both_start - x)
1427 if event.x < cur_s:
1428 self.__moving_both_cur = cur_s
1429 elif event.x > cur_e:
1430 self.__moving_both_cur = cur_e
1431 else:
1432 self.__moving_both_cur = event.x
1433 self.queue_draw_area(0, int(y), int(self.__width), int(height))
1434 return True
1435 if self.__moving_top:
1436 self.__moving_top_cur = event.x
1437 delta = self.__data.scale_data(self.__moving_top_start - self.__moving_top_cur)
1438 (left, right) = self.__data.get_range()
1439 self.__data.set_range(left + delta, right + delta)
1440 self.__force_full_redraw = True
1441 self.__moving_top_start = event.x
1442 self.queue_draw()
1443 return True
1444 (d_x, d_y, d_width, d_height) = self.__data.get_data_rectangle()
1445 if event.y > y and event.y < y + height:
1446 if abs(event.x - x) < 5 or abs(event.x - (x + width)) < 5:
1447 widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.SB_H_DOUBLE_ARROW))
1448 return True
1449 if event.x > x and event.x < x + width:
1450 widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.FLEUR))
1451 return True
1452 if event.y > d_y and event.y < (d_y + d_height):
1453 if event.x > d_x and event.x < (d_x + d_width):
1454 widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.FLEUR))
1455 return True
1456 widget.window.set_cursor(None)
1457 return False
1458 def size_allocate(self, widget, allocation):
1459 """! Size Allocate
1460 @param self this object
1461 @param widget widget
1462 @param allocation allocation
1463 @return none
1464 """
1465 self.__width = allocation.width
1466 self.__height = allocation.height
1467 self.__data.layout(allocation.width, allocation.height)
1468 self.__force_full_redraw = True
1469 self.queue_draw()
1470 def expose(self, widget, event):
1471 """! Expose
1472 @param self this object
1473 @param widget widget
1474 @param event event
1475 @return false
1476 """
1477 if self.__force_full_redraw:
1478 self.__buffer_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
1479 self.__data.get_width(),
1480 self.__data.get_height())
1481 ctx = cairo.Context(self.__buffer_surface)
1482 self.__data.draw(ctx)
1483 self.__force_full_redraw = False
1484 ctx = widget.window.cairo_create()
1485 ctx.rectangle(event.area.x, event.area.y,
1486 event.area.width, event.area.height)
1487 ctx.clip()
1488 ctx.set_source_surface(self.__buffer_surface)
1489 ctx.paint()
1490 (x, y, width, height) = self.__data.get_selection_rectangle()
1491 if self.__moving_left:
1492 ctx.move_to(max(self.__moving_left_cur, 2), y)
1493 ctx.rel_line_to(0, height)
1494 ctx.close_path()
1495 ctx.set_line_width(1)
1496 ctx.set_source_rgb(0, 0, 0)
1497 ctx.stroke()
1498 if self.__moving_right:
1499 ctx.move_to(min(self.__moving_right_cur, self.__width - 2), y)
1500 ctx.rel_line_to(0, height)
1501 ctx.close_path()
1502 ctx.set_line_width(1)
1503 ctx.set_source_rgb(0, 0, 0)
1504 ctx.stroke()
1505 if self.__moving_both:
1506 delta_x = self.__moving_both_cur - self.__moving_both_start
1507 left_x = x + delta_x
1508 ctx.move_to(x + delta_x, y)
1509 ctx.rel_line_to(0, height)
1510 ctx.close_path()
1511 ctx.move_to(x + width + delta_x, y)
1512 ctx.rel_line_to(0, height)
1513 ctx.close_path()
1514 ctx.set_source_rgb(0, 0, 0)
1515 ctx.set_line_width(1)
1516 ctx.stroke()
1517 return False
1518
1519
1521
1527 def __init__(self):
1528 """! Initializer
1529 @param self this object
1530 """
1531 return
1532 def run(self, graphic):
1533 """! Run function
1534 @param self this object
1535 @param graphic graphic
1536 @return none
1537 """
1538 window = gtk.Window()
1539 self.__window = window
1540 window.set_default_size(200, 200)
1541 vbox = gtk.VBox()
1542 window.add(vbox)
1543 render = GtkGraphicRenderer(graphic)
1544 self.__render = render
1545 vbox.pack_end(render, True, True, 0)
1546 hbox = gtk.HBox()
1547 vbox.pack_start(hbox, False, False, 0)
1548 smaller_zoom = gtk.Button("Zoom Out")
1549 smaller_zoom.connect("clicked", self.__set_smaller_cb)
1550 hbox.pack_start(smaller_zoom)
1551 bigger_zoom = gtk.Button("Zoom In")
1552 bigger_zoom.connect("clicked", self.__set_bigger_cb)
1553 hbox.pack_start(bigger_zoom)
1554 output_png = gtk.Button("Output Png")
1555 output_png.connect("clicked", self.__output_png_cb)
1556 hbox.pack_start(output_png)
1557 window.connect('destroy', gtk.main_quit)
1558 window.show_all()
1559 #gtk.bindings_activate(gtk.main_quit, 'q', 0)
1560 gtk.main()
1561 def __set_smaller_cb(self, widget):
1562 """! Set Smaller Callback
1563 @param self this object
1564 @param widget widget
1565 @return none
1566 """
1567 self.__render.set_smaller_zoom()
1568 def __set_bigger_cb(self, widget):
1569 """! Set Bigger Callback
1570 @param self this object
1571 @param widget widget
1572 @return none
1573 """
1574 self.__render.set_bigger_zoom()
1575 def __output_png_cb(self, widget):
1576 """! Output PNG Callback
1577 @param self this object
1578 @param widget widget
1579 @return none
1580 """
1581 dialog = gtk.FileChooserDialog("Output Png", self.__window,
1582 gtk.FILE_CHOOSER_ACTION_SAVE, ("Save", 1))
1583 self.__dialog = dialog
1584 dialog.set_default_response(1)
1585 dialog.connect("response", self.__dialog_response_cb)
1586 dialog.show()
1587 return
1588 def __dialog_response_cb(self, widget, response):
1589 """! Dialog Response Callback
1590 @param self this object
1591 @param widget widget
1592 @param response response
1593 @return none
1594 """
1595 if response == 1:
1596 filename = self.__dialog.get_filename()
1597 self.__render.output_png(filename)
1598 widget.hide()
1599 return
1600
1601
1602
1603def read_data(filename):
1604 timelines = Timelines()
1605 colors = Colors()
1606 m1 = re.compile('range ([^ ]+) ([^ ]+) ([^ ]+) ([0-9]+) ([0-9]+)')
1607 m2 = re.compile('event-str ([^ ]+) ([^ ]+) ([^ ]+) ([0-9]+)')
1608 m3 = re.compile('event-int ([^ ]+) ([^ ]+) ([0-9]+) ([0-9]+)')
1609 m4 = re.compile('color ([^ ]+) #([a-fA-F0-9]{2,2})([a-fA-F0-9]{2,2})([a-fA-F0-9]{2,2})')
1610
1611 with open(filename) as fh:
1612 for line in fh.readlines():
1613 m = m1.match(line)
1614 if m:
1615 line_name = m.group(1)
1616 timeline = timelines.get(m.group(1))
1617 rang = timeline.get_range(m.group(2))
1618 data_range = DataRange()
1619 data_range.value = m.group(3)
1620 data_range.start = int(m.group(4))
1621 data_range.end = int(m.group(5))
1622 rang.add_range(data_range)
1623 continue
1624 m = m2.match(line)
1625 if m:
1626 line_name = m.group(1)
1627 timeline = timelines.get(m.group(1))
1628 ev = timeline.get_event_str(m.group(2))
1629 event = EventString()
1630 event.value = m.group(3)
1631 event.at = int(m.group(4))
1632 ev.add_event(event)
1633 continue
1634 m = m3.match(line)
1635 if m:
1636 line_name = m.group(1)
1637 timeline = timelines.get(m.group(1))
1638 ev = timeline.get_event_int(m.group(2))
1639 event = EventInt()
1640 event.value = int(m.group(3))
1641 event.at = int(m.group(4))
1642 ev.add_event(event)
1643 continue
1644
1645 m = m4.match(line)
1646 if m:
1647 r = int(m.group(2), 16)
1648 g = int(m.group(3), 16)
1649 b = int(m.group(4), 16)
1650 color = Color(r / 255, g / 255, b / 255)
1651 colors.add(m.group(1), color)
1652 continue
1653 timelines.sort()
1654 return (colors, timelines)
1655
1656
1657
1658def main():
1659 (colors, timelines) = read_data(sys.argv[1])
1660 (lower_bound, upper_bound) = timelines.get_bounds()
1661 graphic = GraphicRenderer(lower_bound, upper_bound)
1662 top_legend = TopLegendRenderer()
1663 range_values = timelines.get_all_range_values()
1664 range_colors = []
1665 for range_value in range_values:
1666 range_colors.append(colors.lookup(range_value))
1667 top_legend.set_legends(range_values,
1668 range_colors)
1669 graphic.set_top_legend(top_legend)
1670 data = TimelinesRenderer()
1671 data.set_timelines(timelines, colors)
1672 graphic.set_data(data)
1673
1674 # default range
1675 range_mid = (upper_bound - lower_bound) / 2
1676 range_width = (upper_bound - lower_bound) / 10
1677 range_lo = range_mid - range_width / 2
1678 range_hi = range_mid + range_width / 2
1679 graphic.set_range(range_lo, range_hi)
1680
1681 main_window = MainWindow()
1682 main_window.run(graphic)
1683
1684
1685main()
#define min(a, b)
Definition: 80211b.c:41
#define max(a, b)
Definition: 80211b.c:42
Color class.
Definition: grid.py:429
def __init__(self, r=0.0, g=0.0, b=0.0)
Initializer.
Definition: grid.py:436
def set(self, r, g, b)
Set color.
Definition: grid.py:446
r
red
Definition: grid.py:443
g
green
Definition: grid.py:444
b
blue
Definition: grid.py:445
Colors class.
Definition: grid.py:459
def __init__(self)
Initializer.
Definition: grid.py:466
def lookup(self, name)
Lookup name.
Definition: grid.py:479
def add(self, name, color)
Add.
Definition: grid.py:471
list default_colors
default colors XXX add more
Definition: grid.py:465
__colors
colors
Definition: grid.py:470
DataRange class.
Definition: grid.py:10
value
value
Definition: grid.py:26
start
start
Definition: grid.py:24
def __init__(self, start=0, end=0, value='')
Initializer.
Definition: grid.py:17
EventFloat class.
Definition: grid.py:42
def __init__(self, at=0, value=0.0)
Initializer.
Definition: grid.py:47
value
value
Definition: grid.py:54
EventInt class.
Definition: grid.py:56
def __init__(self, at=0, value=0.0)
Initializer.
Definition: grid.py:61
value
value
Definition: grid.py:68
EventString class.
Definition: grid.py:28
value
value
Definition: grid.py:40
def __init__(self, at=0, value='')
Initializer.
Definition: grid.py:33
GraphicRenderer class.
Definition: grid.py:969
__mid_scale
mid scale
Definition: grid.py:1000
def set_top_legend(self, top_legend)
Set Top Legend.
Definition: grid.py:1085
def get_range(self)
Get Range.
Definition: grid.py:1072
def draw(self, ctx)
Draw.
Definition: grid.py:1117
def get_selection_rectangle(self)
Get Selection Rectangle.
Definition: grid.py:1038
def set_range(self, start, end)
Set Range.
Definition: grid.py:1056
def get_height(self)
Get Height.
Definition: grid.py:1013
def get_data_rectangle(self)
Get Data Rectangle.
Definition: grid.py:1020
__bot_scale
bottom scale
Definition: grid.py:1002
def scale_selection(self, x)
Scale Selection.
Definition: grid.py:1048
__top_legend
top legend
Definition: grid.py:1091
def layout(self, width, height)
Set Layout.
Definition: grid.py:1092
def set_data(self, data)
Set Date.
Definition: grid.py:1078
def __x_pixel(self, x, width)
X Pixel.
Definition: grid.py:1107
def __init__(self, start, end)
Initializer.
Definition: grid.py:992
def get_width(self)
Get Width.
Definition: grid.py:1007
def scale_data(self, x)
Get Data Rectangle.
Definition: grid.py:1028
GtkGraphicRenderer class.
Definition: grid.py:1255
__force_full_redraw
full redraw
Definition: grid.py:1297
__moving_top_start
moving top start
Definition: grid.py:1360
def set_smaller_zoom(self)
Set Smaller Zoom.
Definition: grid.py:1306
def motion_notify(self, widget, event)
Motion Notify.
Definition: grid.py:1398
__moving_both_cur
moving both cur
Definition: grid.py:1355
__moving_right
moving right
Definition: grid.py:1294
__moving_left
moving left
Definition: grid.py:1293
__moving_right_cur
moving right cur
Definition: grid.py:1419
__buffer_surface
buffer surface
Definition: grid.py:1478
__moving_top_cur
moving top cur
Definition: grid.py:1361
def size_allocate(self, widget, allocation)
Size Allocate.
Definition: grid.py:1458
__moving_top
moving top
Definition: grid.py:1296
__moving_both_start
moving both start
Definition: grid.py:1354
def set_bigger_zoom(self)
Set Bigger Zoom.
Definition: grid.py:1315
def button_press(self, widget, event)
Button Press.
Definition: grid.py:1336
def button_release(self, widget, event)
Button Release.
Definition: grid.py:1364
__moving_both
moving both
Definition: grid.py:1295
__moving_left_cur
moving left cur
Definition: grid.py:1408
def output_png(self, filename)
Output PNG.
Definition: grid.py:1324
def __init__(self, data)
Initializer.
Definition: grid.py:1286
def expose(self, widget, event)
Expose.
Definition: grid.py:1470
MainWindow class.
Definition: grid.py:1520
def run(self, graphic)
Run function.
Definition: grid.py:1532
def __dialog_response_cb(self, widget, response)
Dialog Response Callback.
Definition: grid.py:1588
def __init__(self)
Initializer.
Definition: grid.py:1527
def __set_smaller_cb(self, widget)
Set Smaller Callback.
Definition: grid.py:1561
__dialog
dialog
Definition: grid.py:1583
__window
window
Definition: grid.py:1539
def __output_png_cb(self, widget)
Output PNG Callback.
Definition: grid.py:1575
def __set_bigger_cb(self, widget)
Set Bigger Callback.
Definition: grid.py:1568
__render
render
Definition: grid.py:1544
ScaleRenderer class.
Definition: grid.py:836
def layout(self, width)
Layout.
Definition: grid.py:886
def draw(self, ctx)
Draw.
Definition: grid.py:924
max_text_height
maximum text height
Definition: grid.py:914
def get_position(self, x)
Get Position.
Definition: grid.py:866
def set_bot(self)
Set Bottom.
Definition: grid.py:880
__height
height
Definition: grid.py:916
def set_top(self)
Set Top.
Definition: grid.py:874
def __init__(self)
Initializer.
Definition: grid.py:851
def get_height(self)
Get Height.
Definition: grid.py:918
TimelineDataRange.
Definition: grid.py:86
def __init__(self, name='')
Initializer.
Definition: grid.py:91
def get_bounds(self)
Get bounds.
Definition: grid.py:170
def add_range(self, range)
Add range.
Definition: grid.py:117
def __search(self, key)
Search.
Definition: grid.py:99
def get_ranges_bounds(self, start, end)
Get ranges bounds.
Definition: grid.py:147
def get_ranges(self, start, end)
Get selected ranges.
Definition: grid.py:130
def sort(self)
Sort ranges.
Definition: grid.py:164
def get_all(self)
Get all ranges.
Definition: grid.py:124
TimelineEvent class.
Definition: grid.py:182
def add_event(self, event)
Add Event.
Definition: grid.py:212
def get_events(self, start, end)
Get Events.
Definition: grid.py:219
def __init__(self, name='')
Get ranges bounds.
Definition: grid.py:187
def get_events_bounds(self, start, end)
Get Events Bounds.
Definition: grid.py:229
def sort(self)
Sort function.
Definition: grid.py:239
def get_bounds(self)
Get Bounds.
Definition: grid.py:245
def __search(self, key)
Search function.
Definition: grid.py:194
events
events
Definition: grid.py:193
Timeline class.
Definition: grid.py:258
def get_ranges(self)
Get Ranges.
Definition: grid.py:312
def get_range(self, name)
Get range.
Definition: grid.py:276
def get_event_int(self, name)
Get Event Int.
Definition: grid.py:300
event_int
event int
Definition: grid.py:274
def get_events_int(self)
Get Events int.
Definition: grid.py:324
ranges
ranges
Definition: grid.py:272
def get_event_str(self, name)
Get Event String.
Definition: grid.py:288
def __init__(self, name='')
Initializer.
Definition: grid.py:267
event_str
event string
Definition: grid.py:273
def get_bounds(self)
Get Bounds.
Definition: grid.py:341
def get_events_str(self)
Get Events string.
Definition: grid.py:318
def sort(self)
Sort the ranges and events.
Definition: grid.py:330
name
name
Definition: grid.py:275
Timelines class.
Definition: grid.py:369
def get_bounds(self)
Get Bounds.
Definition: grid.py:402
def __init__(self)
Definition: grid.py:372
def get(self, name)
Get Timeline.
Definition: grid.py:377
timelines
timelines
Definition: grid.py:376
def get_all_range_values(self)
Get All Ranges.
Definition: grid.py:416
def get_all(self)
Get All Timeline.
Definition: grid.py:389
def sort(self)
Sort the timelines.
Definition: grid.py:395
TimelinesRenderer class.
Definition: grid.py:593
right_width
right width
Definition: grid.py:695
def set_timelines(self, timelines, colors)
Set Timelines.
Definition: grid.py:628
grey_background
grey background
Definition: grid.py:796
def draw_line(self, ctx, x, y, width, height)
Draw Line.
Definition: grid.py:699
def get_data_x_start(self)
Get Data X Start.
Definition: grid.py:646
def set_render_range(self, start, end)
Set Render Range.
Definition: grid.py:637
timelines
timelines
Definition: grid.py:635
def layout(self, width)
Get Data X Start.
Definition: grid.py:652
def draw(self, ctx)
Draw.
Definition: grid.py:779
max_text_height
maximum text height
Definition: grid.py:696
def draw_events(self, ctx, events, x, y, width, height)
Draw Event.
Definition: grid.py:716
def __init__(self)
Initializer.
Definition: grid.py:616
def get_height(self)
Get Height.
Definition: grid.py:622
def draw_ranges(self, ctx, ranges, x, y, width, height)
Draw Ranges.
Definition: grid.py:745
left_width
left width
Definition: grid.py:694
TopLegendRenderer class.
Definition: grid.py:490
def get_height(self)
Set padding.
Definition: grid.py:549
def layout(self, width)
Set padding.
Definition: grid.py:522
def __init__(self)
Initializer.
Definition: grid.py:501
def draw(self, ctx)
Set padding.
Definition: grid.py:555
def set_padding(self, padding)
Set padding.
Definition: grid.py:506
def set_legends(self, legends, colors)
Set padding.
Definition: grid.py:513
def ranges_cmp(a, b)
Definition: grid.py:69
def events_cmp(a, b)
Definition: grid.py:77
def read_data(filename)
read_data function
Definition: grid.py:1603