Class: Roby::GUI::ChronicleView
- Defined in:
- lib/roby/gui/chronicle_view.rb
Overview
Integration of a ChronicleWidget to use with a PlanRebuilderWidget
Constant Summary collapse
- PLAY_STEP =
0.1
Instance Attribute Summary collapse
-
#chronicle ⇒ Object
readonly
The underlying ChronicleWidget instance.
-
#history_widget ⇒ Object
readonly
The historyw widget instance.
Instance Method Summary collapse
- #addedSnapshot(cycle) ⇒ Object
-
#apply_options(options) ⇒ Object
Apply saved configuration.
-
#initialize(history_widget, parent = nil) ⇒ ChronicleView
constructor
A new instance of ChronicleView.
- #play ⇒ Object
-
#save_options ⇒ Object
Save view configuration.
- #setCurrentTime(time) ⇒ Object
- #setDisplayTime(time) ⇒ Object
- #show_options ⇒ Object
- #sort_options ⇒ Object
- #step ⇒ Object
- #stop ⇒ Object
- #update_display_time(display_time) ⇒ Object
- #update_time_range(start_time, current_time) ⇒ Object
- #updateWindowTitle ⇒ Object
Constructor Details
#initialize(history_widget, parent = nil) ⇒ ChronicleView
Returns a new instance of ChronicleView.
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/roby/gui/chronicle_view.rb', line 12 def initialize(, parent = nil) super(parent) @layout = Qt::VBoxLayout.new(self) @menu_layout = Qt::HBoxLayout.new @layout.add_layout(@menu_layout) @history_widget = @chronicle = ChronicleWidget.new(self) Qt::Object.connect(@chronicle, SIGNAL('selectedTime(QDateTime)'), , SLOT('seek(QDateTime)')) chronicle.add_tasks_info(*.tasks_info) Qt::Object.connect(, SIGNAL('addedSnapshot(int)'), self, SLOT('addedSnapshot(int)')) @layout.(@chronicle) # Now setup the menu bar @btn_play = Qt::PushButton.new("Play", self) @menu_layout.(@btn_play) @btn_play.connect(SIGNAL('clicked()')) do if @play_timer stop @btn_play.text = "Play" else play @btn_play.text = "Stop" end end @btn_sort = Qt::PushButton.new("Sort", self) @menu_layout.(@btn_sort) @btn_sort. = @btn_show = Qt::PushButton.new("Show", self) @menu_layout.(@btn_show) @btn_show. = @menu_layout.add_stretch(1) @restrict_to_jobs_btn = Qt::CheckBox.new("Restrict to jobs", self) @restrict_to_jobs_btn.checkable = true @restrict_to_jobs_btn.connect(SIGNAL('toggled(bool)')) do |set| chronicle.restrict_to_jobs = set end @menu_layout.(@restrict_to_jobs_btn) @filter_lbl = Qt::Label.new("Filter", self) @filter_box = Qt::LineEdit.new(self) @filter_box.connect(SIGNAL('textChanged(QString const&)')) do |text| if text.empty? chronicle.filter = nil else chronicle.filter = Regexp.new(text.split(' ').join("|")) end end @menu_layout.(@filter_lbl) @menu_layout.(@filter_box) @filter_out_lbl = Qt::Label.new("Filter out", self) @filter_out_box = Qt::LineEdit.new(self) @filter_out_box.connect(SIGNAL('textChanged(QString const&)')) do |text| if text.empty? chronicle.filter_out = nil else chronicle.filter_out = Regexp.new(text.split(' ').join("|")) end end @menu_layout.(@filter_out_lbl) @menu_layout.(@filter_out_box) @menu_layout.add_stretch(1) resize(500, 300) end |
Instance Attribute Details
#chronicle ⇒ Object (readonly)
The underlying ChronicleWidget instance
8 9 10 |
# File 'lib/roby/gui/chronicle_view.rb', line 8 def chronicle @chronicle end |
#history_widget ⇒ Object (readonly)
The historyw widget instance
10 11 12 |
# File 'lib/roby/gui/chronicle_view.rb', line 10 def @history_widget end |
Instance Method Details
#addedSnapshot(cycle) ⇒ Object
81 82 83 |
# File 'lib/roby/gui/chronicle_view.rb', line 81 def addedSnapshot(cycle) chronicle.add_tasks_info(*.tasks_info_of_snapshot(cycle)) end |
#apply_options(options) ⇒ Object
Apply saved configuration
208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/roby/gui/chronicle_view.rb', line 208 def () if scale = ['time_scale'] chronicle.time_scale = scale end if mode = ['show_mode'] @act_show[mode].checked = true end if mode = ['sort_mode'] @act_sort[mode].checked = true end if mode = ['restrict_to_jobs'] @restrict_to_jobs_btn.checked = true end end |
#play ⇒ Object
136 137 138 139 140 |
# File 'lib/roby/gui/chronicle_view.rb', line 136 def play @play_timer = Qt::Timer.new(self) Qt::Object.connect(@play_timer, SIGNAL('timeout()'), self, SLOT('step()')) @play_timer.start(Integer(1000 * PLAY_STEP)) end |
#save_options ⇒ Object
Save view configuration
198 199 200 201 202 203 204 205 |
# File 'lib/roby/gui/chronicle_view.rb', line 198 def result = Hash.new result['show_mode'] = chronicle.show_mode result['sort_mode'] = chronicle.sort_mode result['time_scale'] = chronicle.time_scale result['restrict_to_jobs'] = chronicle.restrict_to_jobs? result end |
#setCurrentTime(time) ⇒ Object
188 189 190 191 192 193 194 |
# File 'lib/roby/gui/chronicle_view.rb', line 188 def setCurrentTime(time) if !chronicle.base_time chronicle.update_base_time(.start_time) chronicle.update_current_time(.current_time) end @chronicle.setCurrentTime(time) end |
#setDisplayTime(time) ⇒ Object
179 180 181 182 183 184 185 |
# File 'lib/roby/gui/chronicle_view.rb', line 179 def setDisplayTime(time) if !chronicle.base_time chronicle.update_base_time(.start_time) chronicle.update_current_time(.current_time) end @chronicle.setDisplayTime(time) end |
#show_options ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/roby/gui/chronicle_view.rb', line 110 def @mnu_show = Qt::Menu.new(self) @actgrp_show = Qt::ActionGroup.new(@mnu_show) @act_show = Hash.new { "All" => :all, "Running" => :running, "Current" => :current }. each do |text, value| act = Qt::Action.new(text, self) act.checkable = true act.connect(SIGNAL('toggled(bool)')) do |onoff| if onoff @chronicle.show_mode = value @chronicle.setDisplayTime end end @actgrp_show.add_action(act) @mnu_show.add_action(act) @act_show[value] = act end @act_show[:all].checked = true @mnu_show end |
#sort_options ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/roby/gui/chronicle_view.rb', line 86 def @mnu_sort = Qt::Menu.new(self) @actgrp_sort = Qt::ActionGroup.new(@mnu_sort) @act_sort = Hash.new { "Start time" => :start_time, "Last event" => :last_event }. each do |text, value| act = Qt::Action.new(text, self) act.checkable = true act.connect(SIGNAL('toggled(bool)')) do |onoff| if onoff @chronicle.sort_mode = value @chronicle.update end end @actgrp_sort.add_action(act) @mnu_sort.add_action(act) @act_sort[value] = act end @act_sort[:start_time].checked = true @mnu_sort end |
#step ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/roby/gui/chronicle_view.rb', line 143 def step if chronicle.display_time == chronicle.current_time return end new_time = chronicle.display_time + PLAY_STEP if new_time >= chronicle.current_time new_time = chronicle.current_time end chronicle.setDisplayTime(new_time) end |
#stop ⇒ Object
156 157 158 159 |
# File 'lib/roby/gui/chronicle_view.rb', line 156 def stop @play_timer.stop @play_timer = nil end |
#update_display_time(display_time) ⇒ Object
175 176 177 |
# File 'lib/roby/gui/chronicle_view.rb', line 175 def update_display_time(display_time) chronicle.update_display_time(display_time) end |
#update_time_range(start_time, current_time) ⇒ Object
171 172 173 |
# File 'lib/roby/gui/chronicle_view.rb', line 171 def update_time_range(start_time, current_time) chronicle.update_time_range(start_time, current_time) end |
#updateWindowTitle ⇒ Object
162 163 164 165 166 167 168 |
# File 'lib/roby/gui/chronicle_view.rb', line 162 def updateWindowTitle if parent_title = .window_title self.window_title = parent_title + ": Chronicle" else self.window_title = "roby-display: Chronicle" end end |