Sha256: 68084a7dc4a1a74e4e6dc41383e86eb19f1dc543817c10371eb2a0bea4c6dc17
Contents?: true
Size: 1.89 KB
Versions: 23
Compression:
Stored size: 1.89 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 # This file contains the implementation of the CanvaslinevalueWidget class. This # widget displays a line within a CanvasWidget. The color of the line depends # on the telemetry point value of 1 or 0 for 'on' or 'off' respectively. require 'cosmos/tools/tlm_viewer/widgets/canvasvalue_widget' module Cosmos class CanvaslinevalueWidget < CanvasvalueWidget def initialize(parent_layout, target_name, packet_name, item_name, x1, y1, x2, y2, color_on = 'green', color_off = 'blue', width = 3, connector = 'NO_CONNECTOR', value_type = :RAW) super(parent_layout, target_name, packet_name, item_name, value_type) @x1 = x1.to_i @y1 = y1.to_i @x2 = x2.to_i @y2 = y2.to_i @point = Qt::Point.new(@x2, @y2) if connector.to_s.upcase == 'CONNECTOR' @connector = true else @connector = false end @color_on = Cosmos::getColor(color_on) @color_off = Cosmos::getColor(color_off) @pen_on = Cosmos::getPen(color_on) @pen_off = Cosmos::getPen(color_off) @width = width.to_i end def draw_widget(painter, on_state) painter.save if (on_state == true) pen = @pen_on color = @color_on else pen = @pen_off color = @color_off end pen.setWidth(@width) painter.setPen(pen) painter.drawLine(@x1, @y1, @x2, @y2) if (@connector == true) painter.setBrush(color) painter.drawEllipse(@point, @width, @width) end painter.restore end def dispose super() @point.dispose end end end
Version data entries
23 entries across 23 versions & 1 rubygems