Sha256: c87842188089e2e303fdd9de5363f3816b0b5ce591432acaf52afbc286f63bcf
Contents?: true
Size: 1.91 KB
Versions: 9
Compression:
Stored size: 1.91 KB
Contents
# encoding: ascii-8bit # Copyright 2014 Ball Aerospace & Technologies Corp. # All Rights Reserved. # # This program is free software; you can modify and/or redistribute it # under the terms of the GNU General Public License # as published by the Free Software Foundation; version 3 with # attribution addendums as found in the LICENSE.txt require 'cosmos/tools/tlm_viewer/widgets/limitsbar_widget' module Cosmos class RangebarWidget < LimitsbarWidget 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 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.getBrush(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 end end # module Cosmos
Version data entries
9 entries across 9 versions & 1 rubygems