Class: Cosmos::ArrayWidget

Inherits:
Qt::TextEdit show all
Includes:
AgingWidget, Widget
Defined in:
lib/cosmos/tools/tlm_viewer/widgets/array_widget.rb

Instance Attribute Summary

Attributes included from AgingWidget

#coloring

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 included from AgingWidget

included, #process_aging_settings, #setup_aging

Methods included from Widget

#context_menu, #get_tooltip_text, included, #set_setting, #set_subsetting, #shutdown, #update_widget

Methods inherited from Qt::TextEdit

#setColors

Constructor Details

#initialize(parent_layout, target_name, packet_name, item_name, width = 200, height = 100, format_string = nil, items_per_row = 4, value_type = :CONVERTED) ⇒ ArrayWidget

Returns a new instance of ArrayWidget.



21
22
23
24
25
26
27
28
29
30
# File 'lib/cosmos/tools/tlm_viewer/widgets/array_widget.rb', line 21

def initialize(parent_layout, target_name, packet_name, item_name, width = 200, height = 100, format_string = nil, items_per_row = 4, value_type = :CONVERTED)
  super(target_name, packet_name, item_name, value_type)
  setup_aging
  @format_string = ConfigParser.handle_nil(format_string)
  @items_per_row = items_per_row.to_i
  setFixedSize(width.to_i, height.to_i)
  setReadOnly(true)
  setFont(Cosmos.get_default_font)
  parent_layout.addWidget(self) if parent_layout
end

Instance Method Details

#process_settingsObject



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

def process_settings
  super
  process_aging_settings
end

#value=(data) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/cosmos/tools/tlm_viewer/widgets/array_widget.rb', line 32

def value=(data)
  scroll_pos = self.verticalScrollBar.value
  text = ""
  space = ' '
  new_line = "\n"
  count = 0
  if data.respond_to? :each
    data.each do |value|
      if @format_string
        text << sprintf(@format_string, value) << space
      else
        text << value.to_s << space
      end
      count += 1
      if (count % @items_per_row) == 0
        count = 0
        text << new_line
      end
    end
  else
    text = data.to_s
  end
  self.text = super(data, text)
  self.setColors(@foreground, @background)
  self.verticalScrollBar.value = scroll_pos
end