Module: Roby::GUI

Defined in:
lib/roby/gui/styles.rb,
lib/roby/gui/stepping.rb,
lib/roby/gui/log_display.rb,
lib/roby/gui/task_state_at.rb,
lib/roby/gui/chronicle_view.rb,
lib/roby/gui/exception_view.rb,
lib/roby/gui/relations_view.rb,
lib/roby/gui/scheduler_view.rb,
lib/roby/gui/plan_dot_layout.rb,
lib/roby/gui/chronicle_widget.rb,
lib/roby/gui/model_views/task.rb,
lib/roby/gui/object_info_view.rb,
lib/roby/gui/plan_rebuilder_widget.rb,
lib/roby/gui/task_display_configuration.rb,
lib/roby/gui/model_views/action_interface.rb,
lib/roby/gui/relations_view/relations_canvas.rb

Defined Under Namespace

Modules: GraphvizPlan, GraphvizPlanObject, GraphvizTask, GraphvizTaskEventGenerator, ModelViews, RelationsCanvasEventGenerator, RelationsCanvasPlan, RelationsCanvasPlanObject, RelationsCanvasTask, RelationsCanvasTaskEventGenerator, RelationsCanvasTaskProxy, TaskDisplayConfiguration Classes: ChronicleView, ChronicleWidget, ExceptionRendering, ExceptionView, LogDisplay, ObjectInfoView, PlanDotLayout, PlanRebuilderWidget, RelationsCanvas, RelationsView, SchedulerView, Stepping

Constant Summary collapse

EVENT_CIRCLE_RADIUS =
3
TASK_EVENT_SPACING =
5
DEFAULT_TASK_WIDTH =
20
DEFAULT_TASK_HEIGHT =
10
ARROW_COLOR =
Qt::Color.new("black")
ARROW_OPENING =
30
ARROW_SIZE =
10
TASK_BRUSH_COLORS =
{
    pending: Qt::Color.new("#6DF3FF"),
    running: Qt::Color.new("#B0FFA6"),
    success: Qt::Color.new("#E2E2E2"),
    finished: Qt::Color.new("#E2A8A8"),
    finalized: Qt::Color.new("#555555")
}.freeze
TASK_BRUSHES =
TASK_BRUSH_COLORS.transform_values { |color| Qt::Brush.new(color) }
.freeze
TASK_PEN_COLORS =
{
    pending: Qt::Color.new("#6DF3FF"),
    running: Qt::Color.new("#B0FFA6"),
    success: Qt::Color.new("#E2E2E2"),
    finished: Qt::Color.new("#E2A8A8"),
    finalized: Qt::Color.new("#555555")
}.freeze
TASK_PENS =
TASK_PEN_COLORS.transform_values { |color| Qt::Pen.new(color) }
.freeze
TASK_NAME_COLOR =
Qt::Color.new("black")
TASK_NAME_PEN =
Qt::Pen.new(TASK_NAME_COLOR)
TASK_MESSAGE_COLOR =
Qt::Color.new("#606060")
TASK_MESSAGE_PEN =
Qt::Pen.new(TASK_MESSAGE_COLOR)
TASK_MESSAGE_MARGIN =
10
EVENT_NAME_COLOR =
Qt::Color.new("black")
EVENT_NAME_PEN =
Qt::Pen.new(EVENT_NAME_COLOR)
TASK_FONTSIZE =
10
PENDING_EVENT_COLOR =

default color for events

"black"
FIRED_EVENT_COLOR =
"green"
EVENT_FONTSIZE =
8
PLAN_LAYER =
0
TASK_LAYER =
PLAN_LAYER + 20
EVENT_LAYER =
PLAN_LAYER + 30
EVENT_PROPAGATION_LAYER =
PLAN_LAYER + 40
FIND_MARGIN =
10
EVENT_CALLED =
1
EVENT_EMITTED =
2
EVENT_CALLED_AND_EMITTED =
EVENT_CALLED | EVENT_EMITTED
EVENT_CONTROLABLE =
4
EVENT_CONTINGENT =
8
FAILED_EMISSION =
16
EVENT_COLORS =
{
    (EVENT_CONTROLABLE | EVENT_CALLED) =>
        [PENDING_EVENT_COLOR, PENDING_EVENT_COLOR],
    (EVENT_CONTROLABLE | EVENT_EMITTED) =>
        [FIRED_EVENT_COLOR, FIRED_EVENT_COLOR],
    (EVENT_CONTROLABLE | EVENT_CALLED_AND_EMITTED) =>
        [FIRED_EVENT_COLOR, PENDING_EVENT_COLOR],
    (EVENT_CONTINGENT | EVENT_EMITTED) => ["white", FIRED_EVENT_COLOR],
    (EVENT_CONTROLABLE | FAILED_EMISSION) => %w[red red],
    (EVENT_CONTINGENT | FAILED_EMISSION) => %w[red red]
}.freeze
EVENT_STYLES =
EVENT_COLORS.transform_values do |colors|
    [Qt::Brush.new(Qt::Color.new(colors[0])),
     Qt::Pen.new(Qt::Color.new(colors[1]))]
end.freeze
TIMELINE_RULER_LINE_LENGTH =
10

Class Method Summary collapse

Class Method Details

.arrow_set(arrow, start_object, end_object) ⇒ Object



431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/roby/gui/relations_view/relations_canvas.rb', line 431

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) ⇒ Object



427
428
429
# File 'lib/roby/gui/relations_view/relations_canvas.rb', line 427

def self.correct_line(from, to, rect)
    intersect_rect(rect.width, rect.height, from, to)
end

.intersect_rect(w, h, from, to) ⇒ Object



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/roby/gui/relations_view/relations_canvas.rb', line 397

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) ⇒ Symbol

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

Parameters:

  • task (Task)
  • time (Time)

Returns:

  • (Symbol)

    one of :pending, :running, :success or :finished



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/roby/gui/task_state_at.rb', line 11

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

    unless last_emitted_event
        return :pending
    end

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