Class: Roby::GUI::SchedulerView

Inherits:
Qt::Widget
  • Object
show all
Defined in:
lib/roby/gui/scheduler_view.rb

Overview

View for scheduling-related log events

Instance Method Summary collapse

Constructor Details

#initialize ⇒ SchedulerView

Returns a new instance of SchedulerView.



10
11
12
13
14
15
16
17
18
# File 'lib/roby/gui/scheduler_view.rb', line 10

def initialize(*)
    super

    @text_view = Qt::TextBrowser.new
    @text_view.read_only = true
    @text_view.accept_rich_text = true
    @layout = Qt::VBoxLayout.new(self)
    @layout.add_widget(@text_view)
end

Instance Method Details

#contents_height ⇒ Object



66
67
68
# File 'lib/roby/gui/scheduler_view.rb', line 66

def contents_height
    size_hint.height
end

#display(state) ⇒ Object

Displays the state of the scheduler. It clears existing information

Parameters:



57
58
59
60
61
62
63
64
# File 'lib/roby/gui/scheduler_view.rb', line 57

def display(state)
    code = erb.result(binding)
    return if @code == code

    scroll_position = @text_view.vertical_scroll_bar.slider_position
    @code = @text_view.html = code
    @text_view.vertical_scroll_bar.slider_position = scroll_position
end

#erb ⇒ Object



28
29
30
31
32
33
34
# File 'lib/roby/gui/scheduler_view.rb', line 28

def erb
    unless @erb
        template = File.read(scheduler_view_rhtml)
        @erb = ERB.new(template)
    end
    @erb
end

#format_msg_string(msg, *args) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/roby/gui/scheduler_view.rb', line 41

def format_msg_string(msg, *args)
    string = args.each_with_index.inject(msg) do |updated_msg, (a, i)|
        a = if a.respond_to?(:map)
                a.map(&:to_s).join(", ")
            else
                a.to_s
            end
        updated_msg.gsub "%#{i + 1}", a
    end
    CGI.escapeHTML(string)
end

#format_pp(object) ⇒ Object



36
37
38
39
# File 'lib/roby/gui/scheduler_view.rb', line 36

def format_pp(object)
    object_s = CGI.escapeHTML(PP.pp(object, +""))
    "<pre>#{object_s}</pre>"
end

#resources_dir ⇒ Object



20
21
22
# File 'lib/roby/gui/scheduler_view.rb', line 20

def resources_dir
    File.expand_path(__dir__)
end

#scheduler_view_rhtml ⇒ Object



24
25
26
# File 'lib/roby/gui/scheduler_view.rb', line 24

def scheduler_view_rhtml
    File.join(resources_dir, "scheduler_view.html.erb")
end