summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorNicolas Schodet2012-10-08 09:50:13 +0200
committerNicolas Schodet2012-10-19 15:17:48 +0200
commitf6929ea00790d83e33a10be79bebb743753d259e (patch)
tree8ac0102cc2186ecd525ee6f2b1fe11ff767cc0c4 /cesar
parent0669215124558a3a1c38f8859461ed7acd2fa31d (diff)
cesar/common/tools/traceviewer: add duration display, refs #3428
Diffstat (limited to 'cesar')
-rw-r--r--cesar/common/tools/traceviewer/trace_view.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/cesar/common/tools/traceviewer/trace_view.py b/cesar/common/tools/traceviewer/trace_view.py
index fa5446a69c..2c8e75c99b 100644
--- a/cesar/common/tools/traceviewer/trace_view.py
+++ b/cesar/common/tools/traceviewer/trace_view.py
@@ -177,7 +177,7 @@ class TraceView (gtk.DrawingArea):
xend - x, lyb - lyt)
self.window.draw_line (self.trace_gc, x, lyb, xend, lyb)
# Annotation function, executed late.
- def draw_annotation (entry, d, dend):
+ def draw_annotation (entry, d, d2, dend):
if hasattr (entry, 'view_attr'):
gc = self.attr (entry.view_attr)
else:
@@ -190,7 +190,7 @@ class TraceView (gtk.DrawingArea):
if hasattr (entry, 'view_text'):
text = self.create_pango_layout (entry.view_text)
size = text.get_pixel_size ()
- if d + size[0] < dend:
+ if d + size[0] < dend and (d2 is None or d + size[0] < d2):
self.window.draw_layout (gc, d + 1, lyb - size[1] + 4,
text)
# Draw a tick for each date corresponding to a trace event (avoid
@@ -198,7 +198,7 @@ class TraceView (gtk.DrawingArea):
date_min = long (x // self.zoom) + self.base
date_max = long (((x + w) + self.zoom) // self.zoom) + self.base
imin, imax = trace.range (date_min, date_max)
- dlast = None
+ dlast, d2last, d2 = None, None, None
for i in xrange (max (0, imin - 1), imax):
d = long ((trace.trace[i].date - self.base) * self.zoom)
# Draw if not drawn yet.
@@ -210,11 +210,19 @@ class TraceView (gtk.DrawingArea):
gc = self.trace_gc
# Draw tick.
self.window.draw_line (gc, d, lyt, d, lyb)
+ if trace.trace[i].duration:
+ d2 = long ((trace.trace[i].date + trace.trace[i].duration
+ - self.base) * self.zoom)
+ self.window.draw_line (gc, d, lyt, d2, lyt)
+ self.window.draw_line (gc, d2, lyt, d2, lyb)
+ else:
+ d2 = None
# Draw previous text if there is room.
if dlast is not None:
- draw_annotation (trace.trace[i - 1], dlast, d)
+ draw_annotation (trace.trace[i - 1], dlast, d2last, d)
# Remember for next iteration.
dlast = d
+ d2last = d2
# Draw last annotation.
if dlast is not None:
try:
@@ -222,7 +230,7 @@ class TraceView (gtk.DrawingArea):
dend = long ((next_entry.date - self.base) * self.zoom)
except IndexError:
dend = xgend
- draw_annotation (trace.trace[i], dlast, dend)
+ draw_annotation (trace.trace[i], dlast, d2last, dend)
def zoom_fit (self, px):
self.zoom = float (px) / (self.end - self.base)