Class: Cosmos::CanvasWidget

Inherits:
Qt::Widget show all
Includes:
LayoutWidget, Widget
Defined in:
lib/cosmos/tools/tlm_viewer/widgets/canvas_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 LayoutWidget

#complete, included

Methods included from Widget

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

Constructor Details

#initialize(parent_layout, width, height) ⇒ CanvasWidget

Returns a new instance of CanvasWidget.



25
26
27
28
29
30
31
# File 'lib/cosmos/tools/tlm_viewer/widgets/canvas_widget.rb', line 25

def initialize(parent_layout, width, height)
  super()
  @repaintObjects = []
  self.minimumWidth = width.to_i
  self.minimumHeight = height.to_i
  parent_layout.addWidget(self) if parent_layout
end

Instance Method Details

#add_repaint(obj) ⇒ Object

add_repaint - Child widgets to the canvas must call add_repaint to register itself with the canvas so that they are painted when the canvas is. Note, the order in which child widgets are painted is the order in which they are created.



37
38
39
# File 'lib/cosmos/tools/tlm_viewer/widgets/canvas_widget.rb', line 37

def add_repaint(obj)
  @repaintObjects << obj
end

#paintEvent(event) ⇒ Object



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

def paintEvent(event)
  begin
    painter = Qt::Painter.new
    painter.begin(self)
    painter.setBackgroundMode(Qt::OpaqueMode)
    painter.setBackground(Cosmos.getBrush(Qt::white))
    @repaintObjects.each do |obj|
      obj.paint(painter)
    end
    painter.end
    painter.dispose
  rescue Exception => err
    Cosmos.handle_fatal_exception(err)
  end
end

#update_widgetObject



57
58
59
# File 'lib/cosmos/tools/tlm_viewer/widgets/canvas_widget.rb', line 57

def update_widget
  self.update
end