Class: Cosmos::CanvasimagevalueWidget

Inherits:
CanvasvalueWidget show all
Defined in:
lib/cosmos/tools/tlm_viewer/widgets/canvasimagevalue_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, filename, x, y, value_type = :RAW) ⇒ CanvasimagevalueWidget

Returns a new instance of CanvasimagevalueWidget.



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

def initialize(parent_layout, target_name, packet_name, item_name, filename, x, y, value_type=:RAW)
  super(parent_layout, target_name, packet_name, item_name, value_type)
  @x = x.to_i
  @y = y.to_i
  @imageOn = nil
  @imageOff = nil

  filenameOn = File.join(::Cosmos::USERPATH, 'config', 'data', filename+'on.gif')
  unless File.exist?(filenameOn)
    raise "Can't find the file #{filenameOn} in #{::Cosmos::USERPATH}/config/data"
  end
  @imageOn = Qt::Image.new(filenameOn)

  filenameOff = File.join(::Cosmos::USERPATH, 'config', 'data', filename+'off.gif')
  unless File.exist?(filenameOff)
    raise "Can't find the file #{filenameOff} in #{::Cosmos::USERPATH}/config/data"
  end
  @imageOff = Qt::Image.new(filenameOff)
end

Instance Method Details

#disposeObject



50
51
52
53
54
# File 'lib/cosmos/tools/tlm_viewer/widgets/canvasimagevalue_widget.rb', line 50

def dispose
  super()
  @imageOn.dispose
  @imageOff.dispose
end

#draw_widget(painter, on_value) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/cosmos/tools/tlm_viewer/widgets/canvasimagevalue_widget.rb', line 42

def draw_widget(painter, on_value)
  if on_value
    painter.drawImage(@x, @y, @imageOn) if @imageOn
  else
    painter.drawImage(@x, @y, @imageOff) if @imageOff
  end
end