Class: Cosmos::CanvaslinevalueWidget

Inherits:
CanvasvalueWidget show all
Defined in:
lib/cosmos/tools/tlm_viewer/widgets/canvaslinevalue_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

Methods inherited from CanvasvalueWidget

#paint, #process_settings, #set_item_settings, takes_value?, #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, x1, y1, x2, y2, coloron = 'green', coloroff = 'blue', width = 3, connector = 'NO_CONNECTOR', value_type = :RAW) ⇒ CanvaslinevalueWidget

Returns a new instance of CanvaslinevalueWidget.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cosmos/tools/tlm_viewer/widgets/canvaslinevalue_widget.rb', line 21

def initialize (parent_layout, target_name, packet_name, item_name, x1, y1, x2, y2, coloron='green', coloroff='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
  @coloron = Cosmos::getColor(coloron)
  @coloroff = Cosmos::getColor(coloroff)
  @pen_on = Cosmos::getPen(coloron)
  @pen_off = Cosmos::getPen(coloroff)
  @width = width.to_i
end

Instance Method Details

#disposeObject



60
61
62
63
# File 'lib/cosmos/tools/tlm_viewer/widgets/canvaslinevalue_widget.rb', line 60

def dispose
  super()
  @point.dispose
end

#draw_widget(painter, on_state) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/cosmos/tools/tlm_viewer/widgets/canvaslinevalue_widget.rb', line 40

def draw_widget(painter, on_state)
  painter.save
  if (on_state == true)
    pen = @pen_on
    color = @coloron
  else
    pen = @pen_off
    color = @coloroff
  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