Class: Cosmos::LinegraphPlotGuiObject
- Defined in:
- lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb
Overview
Represents the entire line graph plot in the graphing system. This class extends LineGraph by implementing callbacks and the update methods which are called by higher level classes.
Direct Known Subclasses
Constant Summary collapse
- SELECTED_FRAME_COLOR =
Color of a linegraph frame when selected
'lightgreen'
Constants inherited from LineGraph
Cosmos::LineGraph::DOUBLE_CLICK_SECONDS, Cosmos::LineGraph::FRAME_OFFSET, Cosmos::LineGraph::GRAPH_SPACER, Cosmos::LineGraph::LABEL_TICK_SIZE, Cosmos::LineGraph::LEFT_X_LABEL_WIDTH_ADJUST
Instance Attribute Summary
Attributes inherited from LineGraph
#draw_cursor_line_callback, #horizontal_lines, #left_y_max, #left_y_min, #mouse_leave_callback, #mouse_left_button_press_callback, #post_error_callback, #pre_error_callback, #right_y_max, #right_y_min, #x_max, #x_max_label, #x_min, #x_min_label
Instance Method Summary collapse
-
#initialize(parent, tab, plot, tabbed_plots) ⇒ LinegraphPlotGuiObject
constructor
A new instance of LinegraphPlotGuiObject.
-
#redraw ⇒ Object
Redraws the line graph.
-
#select ⇒ Object
Selects the plot.
-
#selected? ⇒ Boolean
Indicates if the plot is selected.
-
#unselect ⇒ Object
Unselects plot.
-
#update(redraw_needed = false) ⇒ Object
Update the GraphView object properties.
-
#update_overview(points_plotted, overview_graph) ⇒ Object
Update the overview graph associated with the line graph.
-
#update_plot(points_plotted, min_x_value, max_x_value) ⇒ Object
Update the GraphView lines.
Methods inherited from LineGraph
#add_horizontal_line, #add_line, #add_popups_for_lines, #adjust_popup_positions, attr_accessor_with_redraw, #auto_scale_x, #auto_scale_y, #auto_scale_y_axis, #build_popups_from_x_value, #build_x_grid_lines, #build_y_grid_lines, #calculate_base, #calculate_scaling_factors, #calculate_x_grid_lines, #calculate_y_grid_lines, #calculate_y_labels, #clear_horizontal_lines, #clear_lines, #convert_x_value_to_text, #convert_y_value_to_text, #determine_graph_size, #draw_cursor_line_and_popups, #draw_cursor_line_and_popups_at_x, #draw_error_icon, #draw_frame, #draw_graph_background, #draw_graph_into_back_buffer, #draw_graph_to_screen, #draw_horizontal_lines, #draw_legend, #draw_legend_text, #draw_line, #draw_lines, #draw_origin_lines, #draw_popups, #draw_title, #draw_x_axis_grid_lines, #draw_x_axis_title, #draw_x_label, #draw_y_axis_grid_lines, #draw_y_axis_title, #draw_y_label, #get_legend_position, #graph, #leaveEvent, #manual_scale_x, #manual_scale_y, #mouseMoveEvent, #mousePressEvent, #mouseReleaseEvent, #paintEvent, #remote_draw_cursor_line_at_x, #resizeEvent, #scale_graph, #scale_graph_to_value_x, #scale_left_to_right_y, #scale_value_to_graph_x, #scale_value_to_graph_y, #update_graph_size
Constructor Details
#initialize(parent, tab, plot, tabbed_plots) ⇒ LinegraphPlotGuiObject
Returns a new instance of LinegraphPlotGuiObject.
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 |
# File 'lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb', line 25 def initialize(parent, tab, plot, tabbed_plots) # Add new line graph super(parent) @plot = plot @paused = nil update() # Setup callbacks for multi-graph mouse-overs self.draw_cursor_line_callback = lambda do |calling_line_graph, x, | tab.plots.each do |current_plot| current_plot.gui_object.remote_draw_cursor_line_at_x(x, ) if current_plot.gui_object != calling_line_graph and current_plot.gui_object.respond_to? :remote_draw_cursor_line_at_x end end self.mouse_leave_callback = lambda do |calling_line_graph| tab.plots.each do |current_plot| current_plot.gui_object.remote_draw_cursor_line_at_x(nil, false) if current_plot.gui_object != calling_line_graph and current_plot.gui_object.respond_to? :remote_draw_cursor_line_at_x end end # Setup callbacks for viewing errors self.pre_error_callback = lambda do |calling_line_graph| @paused = tabbed_plots.paused? tabbed_plots.pause end self.post_error_callback = lambda do |calling_line_graph| tabbed_plots.resume unless @paused end show() end |
Instance Method Details
#redraw ⇒ Object
Redraws the line graph
167 168 169 |
# File 'lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb', line 167 def redraw self.graph end |
#select ⇒ Object
Selects the plot
149 150 151 152 153 154 155 |
# File 'lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb', line 149 def select if self.frame_color != SELECTED_FRAME_COLOR self.frame_color = SELECTED_FRAME_COLOR self.frame_size = 3 redraw() end end |
#selected? ⇒ Boolean
Indicates if the plot is selected
144 145 146 |
# File 'lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb', line 144 def selected? self.frame_color == SELECTED_FRAME_COLOR end |
#unselect ⇒ Object
Unselects plot
158 159 160 161 162 163 164 |
# File 'lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb', line 158 def unselect if self.frame_color == SELECTED_FRAME_COLOR self.frame_color = 'black' self.frame_size = 0 redraw() end end |
#update(redraw_needed = false) ⇒ Object
Update the GraphView object properties
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb', line 57 def update(redraw_needed = false) self.title = @plot.title self.x_axis_title = @plot.x_axis_title self.left_y_axis_title = @plot.left_y_axis_title self.right_y_axis_title = @plot.right_y_axis_title self.show_x_grid_lines = @plot.show_x_grid_lines self.show_y_grid_lines = @plot.show_y_grid_lines self.point_size = @plot.point_size self.show_lines = @plot.show_lines self.show_legend = @plot.show_legend if @plot.manual_left_y_scale self.manual_scale_y(*(@plot.manual_left_y_scale)) else self.auto_scale_y(:LEFT) end if @plot.manual_right_y_scale self.manual_scale_y(*(@plot.manual_right_y_scale)) else self.auto_scale_y(:RIGHT) end self.manual_x_grid_line_scale = @plot.manual_x_grid_line_scale self.manual_y_grid_line_scale = @plot.manual_y_grid_line_scale self.unix_epoch_x_values = @plot.unix_epoch_x_values self.utc_time = @plot.utc_time # Update horizontal lines self.clear_horizontal_lines @plot.data_objects.each do |data_object| if data_object.kind_of? LinegraphDataObject axis = data_object.y_axis data_object.horizontal_lines.each do |y_value, color| self.add_horizontal_line(y_value, color, axis) end if data_object.kind_of?(HousekeepingDataObject) && data_object.show_limits_lines axis = data_object.y_axis data_object.limits_lines.each do |y_value, color| self.add_horizontal_line(y_value, color, axis) end end end end redraw() if redraw_needed end |
#update_overview(points_plotted, overview_graph) ⇒ Object
Update the overview graph associated with the line graph
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb', line 103 def update_overview(points_plotted, overview_graph) @plot.data_objects.each do |data_object| begin overview_graph.add_line(data_object.name, data_object.y_values, data_object.x_values, nil, nil, nil, nil, data_object.color, :LEFT, points_plotted) unless data_object.y_values.empty? rescue Exception => error # Ignore errors in overview graph raise error if error.class == NoMemoryError end end end |
#update_plot(points_plotted, min_x_value, max_x_value) ⇒ Object
Update the GraphView lines
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 |
# File 'lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb', line 115 def update_plot(points_plotted, min_x_value, max_x_value) self.clear_lines self.manual_scale_x(min_x_value, max_x_value, false) @plot.data_objects.each do |data_object| unless data_object.x_values.empty? begin raise "GraphView x data must be Numeric" unless data_object.x_values[0].kind_of?(Numeric) range = data_object.x_values.range_within(min_x_value, max_x_value) x_values = data_object.x_values[range] if x_values[0] and x_values[0] >= min_x_value and x_values[0] <= max_x_value y_values = data_object.y_values[range] formatted_x_values = nil formatted_x_values = data_object.formatted_x_values[range] unless data_object.formatted_x_values.empty? self.add_line(data_object.name, y_values, x_values, nil, formatted_x_values, data_object.y_states, data_object.x_states, data_object.color, data_object.y_axis, points_plotted) unless y_values.empty? end rescue Exception => error raise error if error.class == NoMemoryError self.error = error unless self.error end end if data_object.error self.error = data_object.error data_object.error = nil end end @plot.redraw_needed = false end |