Method: Roby::LoggedTask#layout_events

Defined in:
lib/roby/log/relations.rb

#layout_events(display) ⇒ Object



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
# File 'lib/roby/log/relations.rb', line 108

def layout_events(display)
    graphics_item = display[self]

    width, height = 0, 0
    events = self.events.map do |_, e| 
  next unless display.displayed?(e)
  next unless circle = display[e]
  br = (circle.bounding_rect | circle.children_bounding_rect)
  [e, circle, br]
    end
    events.compact!
    events = events.sort_by { |ev, _| EventGeneratorDisplay.priorities[ev] }

    events.each do |_, circle, br|
  w, h = br.width, br.height
  height = h if h > height
  width += w
    end
    width  += Log::TASK_EVENT_SPACING * (events.size + 1)
    height += Log::TASK_EVENT_SPACING

    x = -width  / 2 + Log::TASK_EVENT_SPACING
    events.each do |e, circle, br|
  w  = br.width
  circle.set_pos(x + w / 2, -br.height / 2 + Log::EVENT_CIRCLE_RADIUS + Log::TASK_EVENT_SPACING)
  x += w + Log::TASK_EVENT_SPACING
    end

    width = Log::DEFAULT_TASK_WIDTH unless width > Log::DEFAULT_TASK_WIDTH
    height = Log::DEFAULT_TASK_HEIGHT unless height > Log::DEFAULT_TASK_HEIGHT

    if @width != width || @height != height
  @width, @height = width, height
  coords = Qt::RectF.new -(width / 2), -(height / 2), width, height
  graphics_item.rect = coords
    end

    text = graphics_item.text
    text.set_pos(- text.bounding_rect.width / 2, height / 2 + Log::TASK_EVENT_SPACING)
end