module Roby::GUI::GraphvizTask

Public Instance Methods

apply_layout(bounding_rects, positions, display) click to toggle source
# File lib/roby/gui/plan_dot_layout.rb, line 195
def apply_layout(bounding_rects, positions, display)
    if !(task = positions[dot_id])
        puts "No layout for #{self}"
        return
    end
    each_event do |ev|
        next if !display.displayed?(ev)
        positions[ev.dot_id] += task
    end
    # Apply the layout on the events
    each_event do |ev|
        ev.apply_layout(bounding_rects, positions, display)
    end
    # And recalculate the bounding box
    bounding_rect = Qt::RectF.new
    each_event.map do |ev|
        next if !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
    if !graphics_item = display[self]
        raise "no graphics for #{self}" unless graphics_item = display[self]
    end
    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) click to toggle source
Calls superclass method Roby::GUI::GraphvizPlanObject#dot_label
# File lib/roby/gui/plan_dot_layout.rb, line 184
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) click to toggle source
# File lib/roby/gui/plan_dot_layout.rb, line 164
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