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')
}
TASK_BRUSHES =
Hash.new
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')
}
TASK_PENS =
Hash.new
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_STYLES =
Hash.new
TIMELINE_RULER_LINE_LENGTH =
10

Class Method Summary collapse

Class Method Details

.arrow_set(arrow, start_object, end_object) ⇒ Object



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# 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) ⇒ Object



388
389
390
# 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) ⇒ Object



358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# 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) ⇒ 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



9
10
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
# 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