Class: Cosmos::OverviewTabbedPlots
- Inherits:
-
Qt::Widget
- Object
- Qt::Base
- Qt::Widget
- Cosmos::OverviewTabbedPlots
- Defined in:
- lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb
Overview
Implements a widget to display a set of plots in tabs with an overview graph
Constant Summary collapse
- MINIMUM_OVERVIEW_POINTS_PLOTTED =
Minimum Overview Points Per Line
100
- MINIMUM_REFRESH_DELAY_MS =
Minimum delay between redraws
10
Instance Attribute Summary collapse
-
#config_modified_callback ⇒ Object
Callback when a change to modifies the configuration occurs.
-
#data_object_adders ⇒ Object
Accessor to adders.
-
#data_object_right_button_release_callback ⇒ Object
Callback when right button is released on a data object.
-
#plot_right_button_release_callback ⇒ Object
Callback when right button is released on a plot.
-
#status_bar ⇒ Object
readonly
Give access to the status bar to other widgets.
-
#tab_item_right_button_release_callback ⇒ Object
Callback when right button is released on a tab item.
-
#tabbed_plots_config ⇒ Object
Accessor to tabbed_plots_config.
Instance Method Summary collapse
-
#add_data_object(tab_index = nil, plot_index = nil, data_object = nil) ⇒ Object
Adds a data object to a plot - defaults to selected plot on the current tab.
-
#add_plot(tab_index = nil, dialog = true) ⇒ Object
Add a new plot to a tab - defaults to the current tab.
-
#add_tab(tab_text = nil) ⇒ Object
Add a new tab.
-
#current_tab_index ⇒ Object
Returns the index of the current tab or nil if no tabs exist.
-
#delete_data_object(tab_index = nil, plot_index = nil, data_object_index = nil) ⇒ Object
Deletes a data object from a plot - defaults to the selected data objects on the selected plot on the current tab.
-
#delete_plot(tab_index = nil, plot_index = nil) ⇒ Object
Delete a plot - defaults to the selected plot on the current tab.
-
#delete_tab(tab_index = nil) ⇒ Object
Delete a tab - defaults to the current tab.
-
#duplicate_data_object(tab_index = nil, plot_index = nil, data_object_index = nil) ⇒ Object
Duplicates a data object on a plot - defaults to the selected data objects on the selected plot on the current tab.
-
#edit_data_object(tab_index = nil, plot_index = nil, data_object_index = nil) ⇒ Object
Edits a data object on a plot - defaults to the selected data objects on the selected plot on the current tab.
-
#edit_plot(tab_index = nil, plot_index = nil) ⇒ Object
Edit a plot - defaults to the selected plot on the current tab.
-
#edit_tab(tab_index = nil) ⇒ Object
Edit a tab - defaults to the current tab.
-
#export_all_data_objects(filename, progress) ⇒ Object
Exports all data objects.
-
#export_data_object(filename, progress, tab_index = nil, plot_index = nil, data_object_index = nil) ⇒ Object
Exports a data object on a plot - defaults to the selected data objects on the selected plot on the current tab.
-
#export_plot(filename, progress, tab_index = nil, plot_index = nil) ⇒ Object
Exports data objects on a plot - defaults to selected plot on the current tab.
-
#export_tab(filename, progress, tab_index = nil) ⇒ Object
Export all data objects on a tab - defaults to current tab.
-
#initialize(parent, left_frame, right_frame, status_bar) ⇒ OverviewTabbedPlots
constructor
A new instance of OverviewTabbedPlots.
-
#pause ⇒ Object
Pause plotting.
-
#paused? ⇒ Boolean
Are we paused?.
-
#plot_has_data_objects?(tab_index = nil, plot_index = nil) ⇒ Boolean
Indicates if the plot has any data objects.
-
#redraw_plots(force_redraw = false, force_move_window = false) ⇒ Object
Redraws all plots that need to be redrawn.
-
#reset_all_data_objects ⇒ Object
Resets all data objects.
-
#reset_data_object(tab_index = nil, plot_index = nil, data_object_index = nil) ⇒ Object
Resets a data object on a plot - defaults to the selected data objects on the selected plot on the current tab.
-
#reset_plot(tab_index = nil, plot_index = nil) ⇒ Object
Reset all data objects on a plot - defaults to the selected plot on the current tab.
-
#reset_tab(tab_index = nil) ⇒ Object
Reset all data objects on a tab - defaults to current tab.
-
#resume ⇒ Object
Resume plotting if paused.
-
#screenshot_plot(filename, plot_index = nil) ⇒ Object
Take screenshot of a plot on the current tab and write to filename - defaults to selected plot.
-
#screenshot_tab(filename) ⇒ Object
Take screenshot of current tab and write to filename.
-
#selected_data_object_indexes ⇒ Object
Returns an array with the indexes of the selected data objects.
-
#selected_plot_index(tab_index = nil) ⇒ Object
Returns the index of the selected plot or nil - looks at current tab by default.
-
#shutdown ⇒ Object
Shutdown GUI interaction.
-
#startup(tabbed_plots_config, adder_orientation, adder_types) ⇒ Object
Startup GUI interaction.
-
#tab_has_data_objects?(tab_index = nil) ⇒ Boolean
Indicates if the tab has any data objects.
-
#update ⇒ Object
Update.
Constructor Details
#initialize(parent, left_frame, right_frame, status_bar) ⇒ OverviewTabbedPlots
Returns a new instance of OverviewTabbedPlots.
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/overview_tabbed_plots.rb', line 63 def initialize(parent, left_frame, right_frame, ) super(parent) # Save Constructor Arguments @left_frame = left_frame @right_frame = right_frame @status_bar = # Default startup arguments @tabbed_plots_config = nil @adder_orientation = Qt::Horizontal # Additional instance variables @data_object_adders = [] @tab_item_right_button_release_callback = nil @plot_right_button_release_callback = nil @data_object_right_button_release_callback = nil @config_modified_callback = nil @paused = false @timeout = nil @refresh_rate_ms = (1000.0 / TabbedPlotsConfig::DEFAULT_REFRESH_RATE_HZ).round @context_menu_plot = nil end |
Instance Attribute Details
#config_modified_callback ⇒ Object
Callback when a change to modifies the configuration occurs
58 59 60 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 58 def config_modified_callback @config_modified_callback end |
#data_object_adders ⇒ Object
Accessor to adders
46 47 48 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 46 def data_object_adders @data_object_adders end |
#data_object_right_button_release_callback ⇒ Object
Callback when right button is released on a data object
55 56 57 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 55 def @data_object_right_button_release_callback end |
#plot_right_button_release_callback ⇒ Object
Callback when right button is released on a plot
52 53 54 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 52 def @plot_right_button_release_callback end |
#status_bar ⇒ Object (readonly)
Give access to the status bar to other widgets
61 62 63 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 61 def @status_bar end |
#tab_item_right_button_release_callback ⇒ Object
Callback when right button is released on a tab item
49 50 51 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 49 def @tab_item_right_button_release_callback end |
#tabbed_plots_config ⇒ Object
Accessor to tabbed_plots_config
43 44 45 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 43 def tabbed_plots_config @tabbed_plots_config end |
Instance Method Details
#add_data_object(tab_index = nil, plot_index = nil, data_object = nil) ⇒ Object
Adds a data object to a plot - defaults to selected plot on the current tab
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 531 def add_data_object(tab_index = nil, plot_index = nil, data_object = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index # Select selected plot by default plot_index = selected_plot_index(tab_index) if tab_index and not plot_index unless plot_index Qt::MessageBox.information(self, 'Information', 'Please select a plot') return false end # Get plot plot = @tabbed_plots_config.tabs[tab_index].plots[plot_index] # Start data object editor to create new data object unless data_object data_object_editor = TabbedPlotsDataObjectEditor.new(self,'Add Data Object', @tabbed_plots_config.plot_type_to_data_object_type_mapping[plot.plot_type]) data_object = data_object_editor.execute data_object_editor.dispose unless data_object @status_bar.showMessage(tr("Add Data Object Canceled")) return false end end # Assign color to data object data_object.color = get_free_color(@tabbed_plots_config.tabs[tab_index]) unless data_object.assigned_color # Add to config @tabbed_plots_config.add_data_object(tab_index, plot_index, data_object) @tabbed_plots_config.update_max_points_saved(@points_saved.value) # Update Plot @tabbed_plots_config.tabs[tab_index].plots[plot_index].gui_object.update(true) # Update data object list fill_data_object_list_for_plot(@tabbed_plots_config.tabs[tab_index].plots[plot_index]) @status_bar.showMessage(tr("Add Data Object Succeeded")) @config_modified_callback.call() if @config_modified_callback return true end |
#add_plot(tab_index = nil, dialog = true) ⇒ Object
Add a new plot to a tab - defaults to the current tab
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 307 def add_plot(tab_index = nil, dialog = true) # Select the current tab by default tab_index = current_tab_index() unless tab_index if tab_index # Get Tab tab = @tabbed_plots_config.tabs[tab_index] # Add to config if dialog plot_editor = TabbedPlotsPlotEditor.new(self, 'Add Plot', @tabbed_plots_config.plot_types) plot = plot_editor.execute plot_editor.dispose else plot = @tabbed_plots_config.create_plot(@tabbed_plots_config.plot_types[0]) end if plot @tabbed_plots_config.add_plot(tab_index, plot) @status_bar.showMessage(tr("Add Plot Succeeded")) else @status_bar.showMessage(tr("Add Plot Canceled")) return false end # Create new plot gui object filename = plot.plot_type.downcase + '_plot_gui_object.rb' gui_object = Cosmos.require_class(filename).new(tab.gui_item, tab, plot, self) tab.gui_layout.addWidget(gui_object) plot.gui_object = gui_object #~ plot.gui_object.connect(SEL_RIGHTBUTTONRELEASE, method(:handle_plot_right_button_release)) if plot.gui_object.respond_to? :mouse_left_button_press_callback current_tab = tab plot.gui_object. = lambda do |calling_gui_object| current_tab.plots.each_with_index do |current_plot, index| if current_plot.gui_object == calling_gui_object select_plot(current_plot) else unselect_plot(current_plot) end end @overview_graphs[@tab_book.currentIndex].setFocus end end # Auto-select plot unselect_all_plots(tab_index) select_plot(plot) end @config_modified_callback.call() if @config_modified_callback return true end |
#add_tab(tab_text = nil) ⇒ Object
Add a new tab
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 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 138 def add_tab(tab_text = nil) unless tab_text # If the last tab text is "Tab X" the next tab should be "Tab X+1" if (@tabbed_plots_config.tabs.length > 0) && (@tabbed_plots_config.tabs[-1].tab_text =~ /Tab (\d*)/) tab_text = "Tab #{$1.to_i + 1}" # $1 is the match from the regexp else # Set text to the total number of tabs tab_text = "Tab #{@tabbed_plots_config.tabs.length + 1}" end end tab = @tabbed_plots_config.add_tab(tab_text) # Create tab item for the tab tab_item = Qt::Widget.new tab_item.setContextMenuPolicy(Qt::CustomContextMenu) connect(tab_item, SIGNAL('customContextMenuRequested(const QPoint&)'), self, SLOT('plot_context_menu(const QPoint&)')) tab.gui_item = tab_item # Create overall vertical layout manager for tab. tab_layout = Qt::VBoxLayout.new() tab_item.setLayout(tab_layout) tab.gui_frame = tab_layout # Create layout manager to hold plots based on number of plots layout = Qt::AdaptiveGridLayout.new tab_layout.addLayout(layout, 1) # Add with stretch factor 1 to give it priority over everything else # Add stretch in case they delete the last plot. This will force the overview graph (which doesn't get deleted) # to stay at the bottom of the layout instead of moving tab_layout.addStretch() tab.gui_layout = layout # Add an overview graph to the tab @overview_graphs << OverviewGraph.new(self) @overview_graphs[-1].callback = method(:overview_graph_callback) @overview_graphs[-1].window_size = @seconds_plotted.value tab_layout.addWidget(@overview_graphs[-1]) # Add an initial plot to the tab add_plot(-1, false) # Add and select the new tab index = @tab_book.addTab(tab_item, tab_text) @tab_book.setCurrentIndex(index) @config_modified_callback.call() if @config_modified_callback end |
#current_tab_index ⇒ Object
Returns the index of the current tab or nil if no tabs exist
271 272 273 274 275 276 277 278 279 280 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 271 def current_tab_index tab_index = -1 unless @tabbed_plots_config.tabs.empty? Qt.execute_in_main_thread(true) do tab_index = @tab_book.currentIndex end end return tab_index if tab_index >= 0 nil end |
#delete_data_object(tab_index = nil, plot_index = nil, data_object_index = nil) ⇒ Object
Deletes a data object from a plot - defaults to the selected data objects on the selected plot on the current tab
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 575 def delete_data_object(tab_index = nil, plot_index = nil, data_object_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index # Select selected plot by default plot_index = selected_plot_index(tab_index) if tab_index and not plot_index plot = @tabbed_plots_config.tabs[tab_index].plots[plot_index] data_object_indexes = get_data_object_indexes(plot, tab_index, plot_index, data_object_index) data_object_indexes.reverse_each do |data_object_idx| @tabbed_plots_config.remove_data_object(tab_index, plot_index, data_object_idx) end if plot plot.gui_object.update(true) fill_data_object_list_for_plot(plot) end @config_modified_callback.call() if @config_modified_callback end |
#delete_plot(tab_index = nil, plot_index = nil) ⇒ Object
Delete a plot - defaults to the selected plot on the current tab
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 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 362 def delete_plot(tab_index = nil, plot_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index # Select selected plot by default plot_index = selected_plot_index(tab_index) if tab_index and not plot_index # Make sure the plot exists if plot_index # Get Tab tab = @tabbed_plots_config.tabs[tab_index] # Remove from config plot = @tabbed_plots_config.remove_plot(tab_index, plot_index) # Potentially clear data object list clear_data_object_list() if plot.gui_object.selected? # Remove the widget tab.gui_layout.removeWidget(plot.gui_object) plot.gui_object.dispose # Create new layout layout = Qt::AdaptiveGridLayout.new # Add existing gui objects into new layout (0...tab.gui_layout.count).each do |index| layout.addWidget(tab.gui_layout.takeAt(0).) end # Select the first plot just to be nice select_plot(tab.plots[0]) if tab.plots[0] # Remove existing layout from frame tab.gui_frame.removeItem(tab.gui_layout) # Assign new layout to tab tab.gui_frame.insertLayout(0, layout, 1) tab.gui_layout = layout #~ tab.gui_layout.connect(SEL_RIGHTBUTTONRELEASE, method(:handle_plot_right_button_release)) @status_bar.showMessage(tr("Plot Deleted")) @config_modified_callback.call() if @config_modified_callback else Qt::MessageBox.information(self, 'Information', 'Please select a plot') end end |
#delete_tab(tab_index = nil) ⇒ Object
Delete a tab - defaults to the current tab
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 185 def delete_tab(tab_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index if tab_index # Remove from config @tabbed_plots_config.remove_tab(tab_index) # Remove knowledge of overview graph @overview_graphs.delete_at(tab_index) # Remove tab item and frame from tab book @tab_book.(tab_index).dispose # Call tab change callback @tab_book.current is not valid at this point if tab_index > (@tabbed_plots_config.tabs.length - 1) @tab_book.setCurrentIndex(tab_index - 1) else @tab_book.setCurrentIndex(tab_index) end end @config_modified_callback.call() if @config_modified_callback end |
#duplicate_data_object(tab_index = nil, plot_index = nil, data_object_index = nil) ⇒ Object
Duplicates a data object on a plot - defaults to the selected data objects on the selected plot on the current tab
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 637 def duplicate_data_object(tab_index = nil, plot_index = nil, data_object_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index # Select selected plot by default plot_index = selected_plot_index(tab_index) if tab_index and not plot_index if plot_index plot = @tabbed_plots_config.tabs[tab_index].plots[plot_index] data_object_indexes = get_data_object_indexes(plot, tab_index, plot_index, data_object_index) data_object_indexes.each do |data_object_idx| data_object = @tabbed_plots_config.duplicate_data_object(tab_index, plot_index, data_object_idx) data_object.color = get_free_color(@tabbed_plots_config.tabs[tab_index]) unless data_object.assigned_color end @status_bar.showMessage(tr("Data Object(s) Duplicated")) plot.gui_object.update(true) fill_data_object_list_for_plot(@tabbed_plots_config.tabs[tab_index].plots[plot_index]) @config_modified_callback.call() if @config_modified_callback end end |
#edit_data_object(tab_index = nil, plot_index = nil, data_object_index = nil) ⇒ Object
Edits a data object on a plot - defaults to the selected data objects on the selected plot on the current tab
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 599 def edit_data_object(tab_index = nil, plot_index = nil, data_object_index = nil) edited = false # Select the current tab by default tab_index = current_tab_index() unless tab_index # Select selected plot by default plot_index = selected_plot_index(tab_index) if tab_index and not plot_index if plot_index plot = @tabbed_plots_config.tabs[tab_index].plots[plot_index] data_object_indexes = get_data_object_indexes(plot, tab_index, plot_index, data_object_index) data_object_indexes.each do |data_object_idx| data_object = @tabbed_plots_config.tabs[tab_index].plots[plot_index].data_objects[data_object_idx] data_object_editor = TabbedPlotsDataObjectEditor.new(self, 'Edit Data Object', @tabbed_plots_config.plot_type_to_data_object_type_mapping[plot.plot_type], data_object) data_object = data_object_editor.execute data_object_editor.dispose if data_object @tabbed_plots_config.edit_data_object(tab_index, plot_index, data_object_idx, data_object) @status_bar.showMessage(tr("Data Object(s) Edited")) edited = true @config_modified_callback.call() if @config_modified_callback else @status_bar.showMessage(tr("Edit Data Object Canceled")) end end plot.gui_object.update(true) fill_data_object_list_for_plot(plot) end return edited end |
#edit_plot(tab_index = nil, plot_index = nil) ⇒ Object
Edit a plot - defaults to the selected plot on the current tab
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 410 def edit_plot(tab_index = nil, plot_index = nil) edited = false # Select the current tab by default tab_index = current_tab_index() unless tab_index if tab_index # Get tab tab = @tabbed_plots_config.tabs[tab_index] # Select selected plot by default plot_index = selected_plot_index(tab_index) unless plot_index unless plot_index Qt::MessageBox.information(self, 'Information', 'Please select a plot') return end plot = tab.plots[plot_index] # Edit Plot plot_editor = TabbedPlotsPlotEditor.new(self, 'Edit Plot', @tabbed_plots_config.plot_types, plot) plot = plot_editor.execute plot_editor.dispose if plot plot.gui_object.update(true) @status_bar.showMessage(tr("Plot Edited")) edited = true @config_modified_callback.call() if @config_modified_callback else @status_bar.showMessage(tr("Plot Edit Canceled")) end end return edited end |
#edit_tab(tab_index = nil) ⇒ Object
Edit a tab - defaults to the current tab
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 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 210 def edit_tab(tab_index = nil) edited = false # Select the current tab by default tab_index = current_tab_index() unless tab_index if tab_index # Get the tab object tab = @tabbed_plots_config.tabs[tab_index] # Create simple dialog box to edit the tab result = Qt::Boolean.new string = Qt::InputDialog::getText(self, "Edit Tab", "Tab Text:", Qt::LineEdit::Normal, tab.tab_text, result) if !result.nil? and not string.strip.empty? and @tab_book.tabText(tab_index) != string tab.tab_text = string @tab_book.setTabText(tab_index, string) edited = true @config_modified_callback.call() if @config_modified_callback end end return edited end |
#export_all_data_objects(filename, progress) ⇒ Object
Exports all data objects
686 687 688 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 686 def export_all_data_objects(filename, progress) export_data_objects(filename, progress) end |
#export_data_object(filename, progress, tab_index = nil, plot_index = nil, data_object_index = nil) ⇒ Object
Exports a data object on a plot - defaults to the selected data objects on the selected plot on the current tab
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 663 def export_data_object(filename, progress, tab_index = nil, plot_index = nil, data_object_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index # Select selected plot by default plot_index = selected_plot_index(tab_index) if tab_index and not plot_index if plot_index plot = @tabbed_plots_config.tabs[tab_index].plots[plot_index] data_object_indexes = get_data_object_indexes(plot, tab_index, plot_index, data_object_index) columns = [] data_object_indexes.each do |data_object_idx| columns.concat(@tabbed_plots_config.export_data_objects(progress, tab_index, plot_index, data_object_idx)) end write_export_file(filename, columns, progress) end end |
#export_plot(filename, progress, tab_index = nil, plot_index = nil) ⇒ Object
Exports data objects on a plot - defaults to selected plot on the current tab
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 449 def export_plot(filename, progress, tab_index = nil, plot_index = nil) Qt.execute_in_main_thread(true) do # Select the current tab by default tab_index = current_tab_index() unless tab_index # Select selected plot by default plot_index = selected_plot_index(tab_index) if tab_index and not plot_index unless plot_index Qt::MessageBox.information(self, 'Information', 'Please select a plot') return end end export_data_objects(filename, progress, tab_index, plot_index) end |
#export_tab(filename, progress, tab_index = nil) ⇒ Object
Export all data objects on a tab - defaults to current tab
240 241 242 243 244 245 246 247 248 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 240 def export_tab(filename, progress, tab_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index if tab_index # Export the tab's data objects export_data_objects(filename, progress, tab_index) if @tabbed_plots_config.tabs[tab_index] end end |
#pause ⇒ Object
Pause plotting
119 120 121 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 119 def pause @paused = true end |
#paused? ⇒ Boolean
Are we paused?
129 130 131 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 129 def paused? @paused end |
#plot_has_data_objects?(tab_index = nil, plot_index = nil) ⇒ Boolean
Indicates if the plot has any data objects
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 509 def plot_has_data_objects?(tab_index = nil, plot_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index # Select selected plot by default plot_index = selected_plot_index(tab_index) if tab_index and not plot_index return_value = false if plot_index @tabbed_plots_config.mu_synchronize do return_value = true unless @tabbed_plots_config.tabs[tab_index].plots[plot_index].data_objects.empty? end end return_value end |
#redraw_plots(force_redraw = false, force_move_window = false) ⇒ Object
Redraws all plots that need to be redrawn
727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 727 def redraw_plots(force_redraw = false, force_move_window = false) if not @paused or force_redraw overview_redraw_needed = force_redraw move_window = force_move_window points_plotted = @points_plotted.value # Determine if overview redraws are needed @tabbed_plots_config.mu_synchronize do tab_index = @tab_book.currentIndex return if tab_index < 0 or tab_index > (@tabbed_plots_config.tabs.length - 1) @tabbed_plots_config.tabs[tab_index].plots.each do |plot| if plot.redraw_needed overview_redraw_needed = true move_window = true unless @paused break end end end # Redraw overview overview_graph = @overview_graphs[@tab_book.currentIndex] if overview_redraw_needed num_lines = 0 @tabbed_plots_config.tabs[@tab_book.currentIndex].plots.each {|plot| num_lines += plot.data_objects.length} if num_lines > 0 overview_points_plotted = points_plotted / num_lines overview_points_plotted = MINIMUM_OVERVIEW_POINTS_PLOTTED if overview_points_plotted < MINIMUM_OVERVIEW_POINTS_PLOTTED else overview_points_plotted = points_plotted end overview_graph.clear_lines @tabbed_plots_config.mu_synchronize do @tabbed_plots_config.tabs[@tab_book.currentIndex].plots.each {|plot| plot.gui_object.update_overview(overview_points_plotted, overview_graph)} end overview_graph.graph(move_window) end # Sync other overview graph positions @overview_graphs.each do |other_overview_graph| if overview_graph != other_overview_graph other_overview_graph.set_window_pos(overview_graph.window_min_x, overview_graph.window_max_x, false) end end # Determine if plot redraws needed gui_objects = [] redraw_needed = [] @tabbed_plots_config.mu_synchronize do @tabbed_plots_config.tabs[@tab_book.currentIndex].plots.each do |plot| gui_objects << plot.gui_object if force_redraw or overview_redraw_needed redraw_needed << true else redraw_needed << plot.redraw_needed end if redraw_needed[-1] plot.gui_object.update_plot(points_plotted, overview_graph.window_min_x, overview_graph.window_max_x) end end end # Redraw plots gui_objects.length.times do |index| if redraw_needed[index] gui_objects[index].redraw end end end end |
#reset_all_data_objects ⇒ Object
Resets all data objects
709 710 711 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 709 def reset_all_data_objects reset_data_objects() end |
#reset_data_object(tab_index = nil, plot_index = nil, data_object_index = nil) ⇒ Object
Resets a data object on a plot - defaults to the selected data objects on the selected plot on the current tab
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 691 def reset_data_object(tab_index = nil, plot_index = nil, data_object_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index # Select selected plot by default plot_index = selected_plot_index(tab_index) if tab_index and not plot_index if plot_index data_object_indexes = selected_data_object_indexes() data_object_indexes.reverse_each do |data_object_idx| @tabbed_plots_config.reset_data_objects(tab_index, plot_index, data_object_idx) end redraw_plots(true, true) @status_bar.showMessage(tr("Data Object(s) Reset")) end end |
#reset_plot(tab_index = nil, plot_index = nil) ⇒ Object
Reset all data objects on a plot - defaults to the selected plot on the current tab
478 479 480 481 482 483 484 485 486 487 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 478 def reset_plot(tab_index = nil, plot_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index # Select selected plot by default plot_index = selected_plot_index(tab_index) if tab_index and not plot_index # Reset the data objects reset_data_objects(tab_index, plot_index) if plot_index end |
#reset_tab(tab_index = nil) ⇒ Object
Reset all data objects on a tab - defaults to current tab
251 252 253 254 255 256 257 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 251 def reset_tab(tab_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index # Reset the data objects reset_data_objects(tab_index) if tab_index end |
#resume ⇒ Object
Resume plotting if paused
124 125 126 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 124 def resume @paused = false end |
#screenshot_plot(filename, plot_index = nil) ⇒ Object
Take screenshot of a plot on the current tab and write to filename - defaults to selected plot
466 467 468 469 470 471 472 473 474 475 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 466 def screenshot_plot(filename, plot_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index # Select selected plot by default plot_index = selected_plot_index(tab_index) if tab_index and not plot_index # Take screenshot Screenshot.screenshot_window(@tabbed_plots_config.tabs[tab_index].plots[plot_index].gui_object, filename) if plot_index end |
#screenshot_tab(filename) ⇒ Object
Take screenshot of current tab and write to filename
260 261 262 263 264 265 266 267 268 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 260 def screenshot_tab(filename) # Select the current tab tab_index = current_tab_index() if tab_index # Take screenshot Screenshot.screenshot_window(@tab_book.currentWidget(), filename) end end |
#selected_data_object_indexes ⇒ Object
Returns an array with the indexes of the selected data objects
714 715 716 717 718 719 720 721 722 723 724 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 714 def selected_data_object_indexes selected = [] index = 0 Qt.execute_in_main_thread(true) do @data_object_list.each do |list_item| selected << index if list_item.selected? and @data_object_list.item(index).text != 'No Plot Selected' index += 1 end end selected end |
#selected_plot_index(tab_index = nil) ⇒ Object
Returns the index of the selected plot or nil - looks at current tab by default
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 490 def selected_plot_index(tab_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index plot_index = nil if tab_index Qt.execute_in_main_thread(true) do @tabbed_plots_config.tabs[tab_index].plots.each_with_index do |plot, index| if plot.gui_object.selected? plot_index = index break end end end end return plot_index end |
#shutdown ⇒ Object
Shutdown GUI interaction
100 101 102 103 104 105 106 107 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 100 def shutdown # Shutdown drawing timeout @timeout.method_missing(:stop) if @timeout # Remove GUI elements @tabbed_plots_left_frame.removeAll @tabbed_plots_right_frame.removeAll end |
#startup(tabbed_plots_config, adder_orientation, adder_types) ⇒ Object
Startup GUI interaction
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 87 def startup(tabbed_plots_config, adder_orientation, adder_types) # Save parameters @tabbed_plots_config = tabbed_plots_config @adder_orientation = adder_orientation @adder_types = adder_types # Create GUI elements build_right_frame() build_left_frame() create() end |
#tab_has_data_objects?(tab_index = nil) ⇒ Boolean
Indicates if the tab has any data objects
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 283 def tab_has_data_objects?(tab_index = nil) # Select the current tab by default tab_index = current_tab_index() unless tab_index return_value = false if tab_index @tabbed_plots_config.mu_synchronize do @tabbed_plots_config.tabs[tab_index].plots.each do |plot| if not plot.data_objects.empty? return_value = true break end end end end return_value end |
#update ⇒ Object
Update
110 111 112 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb', line 110 def update @data_object_adders.each {|adder| adder.update} end |