Class: Cosmos::RangebarWidget
- Inherits:
-
LimitsbarWidget
- Object
- Qt::Label
- LimitsWidget
- LimitsbarWidget
- Cosmos::RangebarWidget
- Defined in:
- lib/cosmos/tools/tlm_viewer/widgets/rangebar_widget.rb
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
Instance Method Summary collapse
-
#initialize(parent_layout, target_name, packet_name, item_name, low_value, high_value, value_type = :CONVERTED, width = 160, height = 25) ⇒ RangebarWidget
constructor
A new instance of RangebarWidget.
- #paint_implementation(dc) ⇒ Object
Methods inherited from LimitsbarWidget
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, low_value, high_value, value_type = :CONVERTED, width = 160, height = 25) ⇒ RangebarWidget
Returns a new instance of RangebarWidget.
17 18 19 20 21 |
# File 'lib/cosmos/tools/tlm_viewer/widgets/rangebar_widget.rb', line 17 def initialize (parent_layout, target_name, packet_name, item_name, low_value, high_value, value_type = :CONVERTED, width = 160, height = 25) super(parent_layout, target_name, packet_name, item_name, value_type, width, height) @low_value = low_value.to_s.convert_to_value @high_value = high_value.to_s.convert_to_value end |
Instance Method Details
#paint_implementation(dc) ⇒ Object
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 |
# File 'lib/cosmos/tools/tlm_viewer/widgets/rangebar_widget.rb', line 23 def paint_implementation(dc) # Fill the rectangle with white dc.addRectColorFill(@x_pad, @y_pad, @width - @x_pad - @x_pad, @height - @y_pad - @y_pad, "white") # Draw line at current value @bar_scale = @high_value - @low_value @line_pos = (@x_pad + (@value - @low_value) / @bar_scale * @bar_width).to_i if @line_pos < @x_pad @line_pos = @x_pad end if @line_pos > @x_pad + @bar_width @line_pos = @bar_width + @x_pad end dc.addLineColor(@line_pos, @y_pad - 3, @line_pos, @y_pad + @bar_height + 3) # Draw triangle above current value line top_triangle = Qt::Polygon.new(3) top_triangle.setPoint(0, @line_pos, @y_pad - 1) top_triangle.setPoint(1, @line_pos-5, @y_pad - 6) top_triangle.setPoint(2, @line_pos+5, @y_pad - 6) dc.setBrush(Cosmos::BLACK) dc.drawPolygon(top_triangle) # Draw overall border dc.addRectColor(@x_pad, @y_pad, @width - @x_pad - @x_pad, @height - @y_pad - @y_pad) #Additional drawing for subclasses additional_drawing(dc) end |