Class: Cosmos::TabbedPlotsTool

Inherits:
QtTool show all
Defined in:
lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb

Overview

Displays multiple plots that perform various analysis on data.

Direct Known Subclasses

TlmGrapher

Constant Summary collapse

MINIMUM_LEFT_PANEL_WIDTH =
200
DEFAULT_LEFT_PANEL_WIDTH =
250

Instance Method Summary collapse

Methods inherited from QtTool

#about, #complete_initialize, create_default_options, graceful_kill, #initialize_help_menu, post_options_parsed_hook, pre_window_new_hook, redirect_io, restore_io, run

Constructor Details

#initialize(options) ⇒ TabbedPlotsTool

Returns a new instance of TabbedPlotsTool.



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
80
81
82
83
84
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb', line 32

def initialize(options)
  super(options) # MUST BE FIRST - All code before super is executed twice in RubyQt Based classes
  @base_title = self.windowTitle
  Cosmos.load_cosmos_icon("tlm_grapher.png")

  statusBar.showMessage(tr("")) # Show blank message to initialize status bar

  initialize_actions()
  initialize_menus(options)
  initialize_central_widget()
  complete_initialize()

  # Define instance variables
  @log_filenames = []
  @log_dir = System.paths['LOGS']
  @log_dir += '/' unless @log_dir[-1..-1] == '\\' or @log_dir[-1..-1] == '/'
  @time_start = nil
  @time_end = nil
  @screenshot_dir = @log_dir.clone
  @export_dir = @log_dir.clone
  @data_object_types = options.data_object_types
  @adder_orientation = options.adder_orientation
  @adder_types = options.adder_types
  @tool_short_name = options.tool_short_name
  @plot_types = options.plot_types
  @tabbed_plots_type = options.tabbed_plots_type
  @items = options.items
  @plot_type_to_data_object_type_mapping = options.plot_type_to_data_object_type_mapping
  @start = options.start
  @packet_log_reader = PacketLogReader.new
  @tabbed_plots_config = nil
  @tabbed_plots = nil
  @realtime_thread = nil
  @config_modified = false

  # Bring up slash screen for long duration tasks after creation
  Splash.execute(self) do |splash|
    # Configure CosmosConfig to interact with splash screen
    ConfigParser.splash = splash

    # Load telemetry
    System.telemetry

    # Create tabbed plots definition
    @config_filename = File.join(Cosmos::USERPATH, 'config', 'tools', options.config_dir, options.config_file)
    Qt.execute_in_main_thread(true) do
      load_configuration()
    end

    # Unconfigure CosmosConfig to interact with splash screen
    ConfigParser.splash = nil
  end
end

Instance Method Details

#initialize_actionsObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb', line 86

def initialize_actions
  super()

  # File Menu Actions
  @file_process = Qt::Action.new(tr('&Open Log'), self)
  @file_process_keyseq = Qt::KeySequence.new(tr('Ctrl+O'))
  @file_process.shortcut = @file_process_keyseq
  @file_process.statusTip = tr('Open Log File')
  @file_process.connect(SIGNAL('triggered()')) { on_file_process_log() }

  @file_load = Qt::Action.new(Cosmos.get_icon('open.png'), tr('&Load Config'), self)
  @file_load.statusTip = tr('Load Saved Configuration')
  @file_load.connect(SIGNAL('triggered()')) { on_file_load_config() }

  @file_save = Qt::Action.new(Cosmos.get_icon('save.png'), tr('&Save Config'), self)
  @file_save_keyseq = Qt::KeySequence.new(tr('Ctrl+S'))
  @file_save.shortcut = @file_save_keyseq
  @file_save.statusTip = tr('Save Current Configuration')
  @file_save.connect(SIGNAL('triggered()')) { on_file_save_config() }

  @file_screenshot = Qt::Action.new(Cosmos.get_icon('screenshot.png'), tr('Screensho&t'), self)
  @file_screenshot.statusTip = tr('Screenshot of Application')
  @file_screenshot.connect(SIGNAL('triggered()')) { on_file_screenshot() }

  # Tab Menu Actions
  @tab_add = Qt::Action.new(Cosmos.get_icon('add_tab.png'), tr('&Add Tab'), self)
  @tab_add.statusTip = tr('Add New Tab')
  @tab_add.connect(SIGNAL('triggered()')) { on_tab_add() }

  @tab_delete = Qt::Action.new(Cosmos.get_icon('delete_tab.png'), tr('&Delete Tab'), self)
  @tab_delete.statusTip = tr('Delete Active Tab')
  @tab_delete.connect(SIGNAL('triggered()')) { on_tab_delete() }

  @tab_edit = Qt::Action.new(Cosmos.get_icon('edit_tab.png'), tr('&Edit Tab'), self)
  @tab_edit.statusTip = tr('Edit Active Tab')
  @tab_edit.connect(SIGNAL('triggered()')) { on_tab_edit() }

  @tab_screenshot = Qt::Action.new(Cosmos.get_icon('screenshot.png'), tr('&Screenshot Tab'), self)
  @tab_screenshot.statusTip = tr('Screenshot of Active Tab')
  @tab_screenshot.connect(SIGNAL('triggered()')) { on_tab_screenshot() }

  @tab_export = Qt::Action.new(tr('E&xport Tab Data Objects'), self)
  @tab_export.statusTip = tr('Export Tab Data Object(s)')
  @tab_export.connect(SIGNAL('triggered()')) { on_tab_export() }

  @tab_reset = Qt::Action.new(tr('&Reset Tab Data Objects'), self)
  @tab_reset.statusTip = tr('Reset Tab Data Object(s)')
  @tab_reset.connect(SIGNAL('triggered()')) { on_tab_reset() }

  # Plot Menu Actions
  @plot_add = Qt::Action.new(Cosmos.get_icon('add_plot.png'), tr('&Add Plot'), self)
  @plot_add.statusTip = tr('Add New Plot')
  @plot_add.connect(SIGNAL('triggered()')) { on_plot_add() }

  @plot_delete = Qt::Action.new(Cosmos.get_icon('delete_plot.png'), tr('&Delete Plot'), self)
  @plot_delete.statusTip = tr('Delete Selected Plot')
  @plot_delete.connect(SIGNAL('triggered()')) { on_plot_delete() }

  @plot_edit = Qt::Action.new(Cosmos.get_icon('edit_plot.png'), tr('&Edit Plot'), self)
  @plot_edit.statusTip = tr('Edit Selected Plot')
  @plot_edit.connect(SIGNAL('triggered()')) { on_plot_edit() }

  @plot_screenshot = Qt::Action.new(Cosmos.get_icon('screenshot.png'), tr('&Screenshot Plot'), self)
  @plot_screenshot.statusTip = tr('Screenshot Selected Plot')
  @plot_screenshot.connect(SIGNAL('triggered()')) { on_plot_screenshot() }

  @plot_add_data = Qt::Action.new(Cosmos.get_icon('add_database.png'), tr('Add Data &Object'), self)
  @plot_add_data.statusTip = tr('Add Data Object')
  @plot_add_data.connect(SIGNAL('triggered()')) { on_data_object_add() }

  @plot_edit_data = Qt::Action.new(Cosmos.get_icon('edit_database.png'), tr('Edit &Plot Data Objects'), self)
  @plot_edit_data.statusTip = tr('Edit Plot Data Object(s)')
  @plot_edit_data.connect(SIGNAL('triggered()')) { on_plot_data_object_edit() }

  @plot_export = Qt::Action.new(tr('E&xport Plot Data Objects'), self)
  @plot_export.statusTip = tr('Export Plot Data Object(s)')
  @plot_export.connect(SIGNAL('triggered()')) { on_plot_export() }

  @plot_reset = Qt::Action.new(tr('&Reset Plot Data Objects'), self)
  @plot_reset.statusTip = tr('Reset Plot Data Object(s)')
  @plot_reset.connect(SIGNAL('triggered()')) { on_plot_reset() }

  # Data Object Menu
  @data_add = Qt::Action.new(Cosmos.get_icon('add_database.png'), tr('&Add Data Object'), self)
  @data_add.statusTip = tr('Add Data Object')
  @data_add.connect(SIGNAL('triggered()')) { on_data_object_add() }

  @data_delete = Qt::Action.new(Cosmos.get_icon('delete_database.png'), tr('&Delete Data Object'), self)
  @data_delete.statusTip = tr('Delete Selected Data Object(s)')
  @data_delete.connect(SIGNAL('triggered()')) { on_data_object_delete() }

  @data_edit = Qt::Action.new(Cosmos.get_icon('edit_database.png'), tr('&Edit Data Object'), self)
  @data_edit.statusTip = tr('Edit Selected Data Object(s)')
  @data_edit.connect(SIGNAL('triggered()')) { on_data_object_edit() }

  @data_duplicate = Qt::Action.new(tr('Du&plicate Data Object'), self)
  @data_duplicate.statusTip = tr('Duplicate Selected Data Object(s)')
  @data_duplicate.connect(SIGNAL('triggered()')) { on_data_object_duplicate() }

  @data_export = Qt::Action.new(tr('E&xport Data Object'), self)
  @data_export.statusTip = tr('Export Selected Data Object(s)')
  @data_export.connect(SIGNAL('triggered()')) { on_data_object_export() }

  @data_export_all = Qt::Action.new(tr('Expor&t All Data Objects'), self)
  @data_export_all.statusTip = tr('Export All Data Objects')
  @data_export_all.connect(SIGNAL('triggered()')) { on_data_object_export_all() }

  @data_reset = Qt::Action.new(tr('&Reset Data Object'), self)
  @data_reset.statusTip = tr('Reset Selected Data Object(s)')
  @data_reset.connect(SIGNAL('triggered()')) { on_data_object_reset() }

  @data_reset_all = Qt::Action.new(tr('Re&set All Data Objects'), self)
  @data_reset_all.statusTip = tr('Reset All Data Objects')
  @data_reset_all.connect(SIGNAL('triggered()')) { on_data_object_reset_all() }
end

#initialize_central_widgetObject



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb', line 254

def initialize_central_widget
  # Create a splitter to break application into to halves
  @splitter = Qt::Splitter.new(Qt::Horizontal, central_widget)
  setCentralWidget(@splitter)

  # Create a Vertical Frame for the left contents
  @left_widget = Qt::Widget.new(self)
  @left_frame = Qt::VBoxLayout.new
  @left_widget.setLayout(@left_frame)
  @splitter.addWidget(@left_widget)

  # Create a Vertical Frame for the right contents
  @right_widget = Qt::Widget.new(self)
  @right_frame = Qt::VBoxLayout.new
  @right_widget.setLayout(@right_frame)
  @splitter.addWidget(@right_widget)
  @splitter.setStretchFactor(0,0) # Set the left side stretch factor to 0
  @splitter.setStretchFactor(1,1) # Set the right side stretch factor to 1 to give it priority for space

  # Realtime Button Bar
  @realtime_button_bar = RealtimeButtonBar.new(self, Qt::Vertical)
  @realtime_button_bar.start_callback = method(:handle_start)
  @realtime_button_bar.pause_callback = method(:handle_pause)
  @realtime_button_bar.stop_callback = method(:handle_stop)
  @realtime_button_bar.state = 'Stopped'
  @left_frame.addWidget(@realtime_button_bar)

  # Separator after RBB
  @sep = Qt::Frame.new
  @sep.setFrameStyle(Qt::Frame::HLine | Qt::Frame::Sunken)
  @left_frame.addWidget(@sep)
end

#initialize_menus(options) ⇒ Object



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb', line 202

def initialize_menus(options)
  # File Menu
  @file_menu = menuBar.addMenu(tr('&File'))
  @file_menu.addAction(@file_process)
  @file_menu.addSeparator()
  @file_menu.addAction(@file_load)
  @file_menu.addAction(@file_save)
  @file_menu.addSeparator()
  @file_menu.addAction(@file_screenshot)
  @file_menu.addSeparator()
  @file_menu.addAction(@exit_action)

  @tab_menu = menuBar.addMenu(tr('&Tab'))
  @tab_menu.addAction(@tab_add)
  @tab_menu.addAction(@tab_delete)
  @tab_menu.addAction(@tab_edit)
  @tab_menu.addSeparator()
  @tab_menu.addAction(@tab_screenshot)
  @tab_menu.addAction(@tab_export)
  @tab_menu.addSeparator()
  @tab_menu.addAction(@tab_reset)

  @plot_menu = menuBar.addMenu(tr('&Plot'))
  @plot_menu.addAction(@plot_add)
  @plot_menu.addAction(@plot_delete)
  @plot_menu.addAction(@plot_edit)
  @plot_menu.addSeparator()
  @plot_menu.addAction(@plot_add_data)
  @plot_menu.addAction(@plot_edit_data)
  @plot_menu.addSeparator()
  @plot_menu.addAction(@plot_screenshot)
  @plot_menu.addAction(@plot_export)
  @plot_menu.addSeparator()
  @plot_menu.addAction(@plot_reset)

  @data_menu = menuBar.addMenu(tr('&Data Object'))
  @data_menu.addAction(@data_add)
  @data_menu.addAction(@data_delete)
  @data_menu.addAction(@data_edit)
  @data_menu.addSeparator()
  @data_menu.addAction(@data_duplicate)
  @data_menu.addAction(@data_export)
  @data_menu.addAction(@data_export_all)
  @data_menu.addSeparator()
  @data_menu.addAction(@data_reset)
  @data_menu.addAction(@data_reset_all)

  # Help Menu
  @about_string = options.about_string
  initialize_help_menu()
end