Class: Cosmos::CanvaslineWidget

Inherits:
Object
  • Object
show all
Includes:
Widget
Defined in:
lib/cosmos/tools/tlm_viewer/widgets/canvasline_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 included from Widget

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

Constructor Details

#initialize(parent_layout, x1, y1, x2, y2, color = 'black', width = 1, connector = 'NO_CONNECTOR') ⇒ CanvaslineWidget

Returns a new instance of CanvaslineWidget.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cosmos/tools/tlm_viewer/widgets/canvasline_widget.rb', line 18

def initialize(parent_layout, x1, y1, x2, y2, color='black', width=1, connector='NO_CONNECTOR')
  super()
  @x1 = x1.to_i
  @y1 = y1.to_i
  @x2 = x2.to_i
  @y2 = y2.to_i
  @point = Qt::Point.new(@x2, @y2)
  @width = width.to_i
  if connector.to_s.upcase == 'CONNECTOR'
    @connector = true
  else
    @connector = false
  end
  @color = Cosmos::getColor(color)
  @pen = Cosmos.getPen(color)
  parent_layout.add_repaint(self)
end

Instance Method Details

#disposeObject



49
50
51
52
# File 'lib/cosmos/tools/tlm_viewer/widgets/canvasline_widget.rb', line 49

def dispose
  super()
  @point.dispose
end

#paint(painter) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cosmos/tools/tlm_viewer/widgets/canvasline_widget.rb', line 36

def paint(painter)
  painter.save
  @pen.setWidth(@width)
  painter.setPen(@pen)
  painter.drawLine(@x1, @y1, @x2, @y2)
  painter.drawLine(@x1, @y1, @x2, @y2)
  if (@connector == true)
    painter.setBrush(@color)
    painter.drawEllipse(@point, @width, @width)
  end
  painter.restore
end