Module: Roby::GUI::GraphvizTask
- Includes:
- GraphvizPlanObject
- Included in:
- Task, Transaction::TaskProxy
- Defined in:
- lib/roby/gui/plan_dot_layout.rb
Instance Method Summary collapse
- #apply_layout(bounding_rects, positions, display) ⇒ Object
- #dot_label(display) ⇒ Object
- #to_dot_events(display, io) ⇒ Object
Methods included from GraphvizPlanObject
Instance Method Details
#apply_layout(bounding_rects, positions, display) ⇒ Object
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 219 def apply_layout(bounding_rects, positions, display) unless (task = positions[dot_id]) puts "No layout for #{self}" return end each_event do |ev| next unless display.displayed?(ev) positions[ev.dot_id] += task end # Apply the layout on the events each_event do |ev| # rubocop:disable Style/CombinableLoops ev.apply_layout(bounding_rects, positions, display) end # And recalculate the bounding box bounding_rect = Qt::RectF.new each_event.map do |ev| next unless display.displayed?(ev) graphics = display[ev] bounding_rect |= graphics.map_rect_to_scene(graphics.bounding_rect) bounding_rect |= graphics.text.map_rect_to_scene(graphics.text.bounding_rect) end raise "no graphics for #{self}" unless (graphics_item = display[self]) if bounding_rect.null? # no events, we need to take the bounding box from the fake task node bounding_rect = Qt::RectF.new( task.x - DEFAULT_TASK_WIDTH / 2, task.y - DEFAULT_TASK_HEIGHT / 2, DEFAULT_TASK_WIDTH, DEFAULT_TASK_HEIGHT) else bounding_rect.y -= 5 end graphics_item.rect = bounding_rect text_pos = Qt::PointF.new( bounding_rect.x + bounding_rect.width / 2 - graphics_item.text.bounding_rect.width / 2, bounding_rect.y + bounding_rect.height) graphics_item.text.pos = text_pos end |
#dot_label(display) ⇒ Object
207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 207 def dot_label(display) event_names = each_event.find_all { |ev| display.displayed?(ev) } .map { |ev| ev.dot_label(display) } .join(" ") own = super if own.size > event_names.size then own else event_names end end |
#to_dot_events(display, io) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 185 def to_dot_events(display, io) return unless display.displayed?(self) io << "subgraph cluster_#{dot_id} {\n" graphics = display.graphics[self] text_bb = graphics.text.bounding_rect has_event = false each_event do |ev| if display.displayed?(ev) ev.to_dot(display, io) has_event = true end end task_height = if !has_event then DEFAULT_TASK_HEIGHT + text_bb.height else text_bb.height end io << " #{dot_id}[width=#{[DEFAULT_TASK_WIDTH, text_bb.width].max},height=#{task_height},fixedsize=true];\n" io << "}\n" end |