module Roby::GUI

Constants

ARROW_COLOR
ARROW_OPENING
ARROW_SIZE
DEFAULT_TASK_HEIGHT
DEFAULT_TASK_WIDTH
EVENT_CALLED
EVENT_CALLED_AND_EMITTED
EVENT_CIRCLE_RADIUS
EVENT_CONTINGENT
EVENT_CONTROLABLE
EVENT_EMITTED
EVENT_FONTSIZE
EVENT_LAYER
EVENT_NAME_COLOR
EVENT_NAME_PEN
EVENT_PROPAGATION_LAYER
EVENT_STYLES
FAILED_EMISSION
FIND_MARGIN
FIRED_EVENT_COLOR
PENDING_EVENT_COLOR
PLAN_LAYER
TASK_BRUSHES
TASK_BRUSH_COLORS
TASK_EVENT_SPACING
TASK_FONTSIZE
TASK_LAYER
TASK_MESSAGE_COLOR
TASK_MESSAGE_MARGIN
TASK_MESSAGE_PEN
TASK_NAME_COLOR
TASK_NAME_PEN
TASK_PENS
TASK_PEN_COLORS
TIMELINE_RULER_LINE_LENGTH

Public Class Methods

arrow_set(arrow, start_object, end_object) click to toggle source
# File lib/roby/gui/relations_view/relations_canvas.rb, line 392
def self.arrow_set(arrow, start_object, end_object)
    start_br    = start_object.scene_bounding_rect
    end_br      = end_object.scene_bounding_rect
    start_point = start_br.center
    end_point   = end_br.center

    #from = intersect_rect(start_br.width, start_br.height, end_point, start_point)
    from = [start_point.x, start_point.y]
    to   = intersect_rect(end_br.width, end_br.height, from, [end_point.x, end_point.y])

    dy = to[1] - from[1]
    dx = to[0] - from[0]
    alpha  = Math.atan2(dy, dx)
    length = Math.sqrt(dx ** 2 + dy ** 2)

    #arrow.line.set_line from[0], from[1], to[0], to[1]
    arrow.resetMatrix
    arrow.line.set_line(-length, 0, 0, 0)
    arrow.translate to[0], to[1]
    arrow.rotate(alpha * 180 / Math::PI)
    arrow
end
correct_line(from, to, rect) click to toggle source
# File lib/roby/gui/relations_view/relations_canvas.rb, line 388
def self.correct_line(from, to, rect)
    intersect_rect(rect.width, rect.height, from, to)
end
intersect_rect(w, h, from, to) click to toggle source
# File lib/roby/gui/relations_view/relations_canvas.rb, line 358
def self.intersect_rect(w, h, from, to)
    to_x, to_y = *to
    from_x, from_y = *from

    # We only use half dimensions since 'to' is supposed to be be the
    # center of the rectangle we are intersecting
    w /= 2
    h /= 2

    dx    = (to_x - from_x)
    dy    = (to_y - from_y)
    delta_x = dx / dy * h
    if dy != 0 && delta_x.abs < w
        if dy > 0
            [to_x - delta_x, to_y - h]
        else
            [to_x + delta_x, to_y + h]
        end
    elsif dx != 0
        delta_y = dy / dx * w
        if dx > 0
            [to_x - w, to_y - delta_y]
        else
            [to_x + w, to_y + delta_y]
        end
    else
        [0, 0]
    end
end
task_state_at(task, time) click to toggle source

Determine the state a task had at a certain point in time, for display purposes

@param [Task] task @param [Time] time @return [Symbol] one of :pending, :running, :success or :finished

# File lib/roby/gui/task_state_at.rb, line 9
def self.task_state_at(task, time)
    if task.failed_to_start?
        if task.failed_to_start_time > time
            return :pending
        else
            return :finished
        end
    end

    last_emitted_event = nil
    task.history.each do |ev|
        break if ev.time > time
        last_emitted_event = ev
    end

    if !last_emitted_event
        return :pending
    end

    gen = last_emitted_event.generator
    if !gen
        return :pending
    elsif gen.terminal?
        return [:success, :finished, :running].find { |flag| task.send("#{flag}?") } 
    else
        return :running
    end
end