Class: Cosmos::LimitscolumnWidget
- Inherits:
-
LimitsWidget
- Object
- Qt::Label
- LimitsWidget
- Cosmos::LimitscolumnWidget
- Defined in:
- lib/cosmos/tools/tlm_viewer/widgets/limitscolumn_widget.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes included from Widget
#item, #item_name, #limits_set, #limits_state, #packet, #packet_name, #polling_period, #screen, #settings, #target_name, #value, #value_type
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(parent_layout, target_name, packet_name, item_name, value_type = :CONVERTED, width = 30, height = 100) ⇒ LimitscolumnWidget
constructor
A new instance of LimitscolumnWidget.
- #paint_implementation(dc) ⇒ Object
Methods inherited from LimitsWidget
#calculate_widths, #get_limits, #paintEvent, #value=
Methods included from Widget
#context_menu, #get_tooltip_text, included, #process_settings, #set_setting, #set_subsetting, #shutdown, #update_widget
Constructor Details
#initialize(parent_layout, target_name, packet_name, item_name, value_type = :CONVERTED, width = 30, height = 100) ⇒ LimitscolumnWidget
Returns a new instance of LimitscolumnWidget.
17 18 19 |
# File 'lib/cosmos/tools/tlm_viewer/widgets/limitscolumn_widget.rb', line 17 def initialize(parent_layout, target_name, packet_name, item_name, value_type = :CONVERTED, width = 30, height = 100) super(parent_layout, target_name, packet_name, item_name, value_type, width, height) end |
Class Method Details
.takes_value? ⇒ Boolean
21 22 23 |
# File 'lib/cosmos/tools/tlm_viewer/widgets/limitscolumn_widget.rb', line 21 def LimitscolumnWidget.takes_value? return true end |
Instance Method Details
#paint_implementation(dc) ⇒ Object
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/cosmos/tools/tlm_viewer/widgets/limitscolumn_widget.rb', line 25 def paint_implementation(dc) limits = get_limits() return unless limits widths = calculate_widths(limits, @bar_height) # Set starting points x_pos = @x_pad y_pos = @y_pad # Draw RED_LOW bar dc.addRectColorFill(x_pos, y_pos, @bar_width, widths.red_low, 'red') dc.addRectColor(x_pos, y_pos, @bar_width, widths.red_low) y_pos += widths.red_low # Draw YELLOW_LOW bar dc.addRectColorFill(x_pos, y_pos, @bar_width, widths.yellow_low, 'yellow') dc.addRectColor(x_pos, y_pos, @bar_width, widths.yellow_low) y_pos += widths.yellow_low if widths.green_high # Draw GREEN_LOW bar dc.addRectColorFill(x_pos, y_pos, @bar_width, widths.green_low, 'lime') dc.addRectColor(x_pos, y_pos, @bar_width, widths.green_low) y_pos += widths.green_low # Draw BLUE bar dc.addRectColorFill(x_pos, y_pos, @bar_width, widths.blue, 'dodgerblue') dc.addRectColor(x_pos, y_pos, @bar_width, widths.blue) y_pos += widths.blue # Draw GREEN_HIGH bar dc.addRectColorFill(x_pos, y_pos, @bar_width, widths.green_high, 'lime') dc.addRectColor(x_pos, y_pos, @bar_width, widths.green_high) y_pos += widths.green_high else # Draw GREEN bar dc.addRectColorFill(x_pos, y_pos, @bar_width, widths.green, 'lime') dc.addRectColor(x_pos, y_pos, @bar_width, widths.green) y_pos += widths.green end # Draw YELLOW_HIGH bar dc.addRectColorFill(x_pos, y_pos, @bar_width, widths.yellow_high, 'yellow') dc.addRectColor(x_pos, y_pos, @bar_width, widths.yellow_high) y_pos += widths.yellow_high # Draw RED_HIGH bar dc.addRectColorFill(x_pos, y_pos, @bar_width, widths.red_high, 'red') dc.addRectColor(x_pos, y_pos, @bar_width, widths.red_high) y_pos += widths.red_high # Draw line at current value red_low = limits[0] red_high = limits[3] @bar_scale = (red_high - red_low) / 0.8 @low_value = red_low - 0.1 * @bar_scale @high_value = red_high + 0.1 * @bar_scale @line_pos = @height - (@y_pad + (@value - @low_value) / @bar_scale * @bar_height).to_i if @line_pos < @y_pad @line_pos = @y_pad end if @line_pos > @y_pad + @bar_height @line_pos = @bar_height + @y_pad end dc.addLineColor(@x_pad - 3, @line_pos, @x_pad + @bar_width + 3, @line_pos) # Draw triangle next to current value line top_triangle = Qt::Polygon.new(3) top_triangle.setPoint(0, @x_pad + @bar_width, @line_pos) top_triangle.setPoint(1, @x_pad + @bar_width + 5, @line_pos + 5) top_triangle.setPoint(2, @x_pad + @bar_width + 5, @line_pos - 5) dc.setBrush(Cosmos::BLACK) dc.drawPolygon(top_triangle) top_triangle.dispose # Additional drawing for subclasses additional_drawing(dc) end |