Class: QtWidgetGL

Inherits:
Qt::GLWidget
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/qt_widget_gl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, width = 400, height = 400) ⇒ QtWidgetGL

Returns a new instance of QtWidgetGL.



18
19
20
21
22
23
24
25
# File 'lib/qt_widget_gl.rb', line 18

def initialize(parent, width = 400, height = 400)
  super(parent)
  @width = width
  @height = height

  @min_width = 50
  @min_height = 50
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



10
11
12
# File 'lib/qt_widget_gl.rb', line 10

def height
  @height
end

#load_procObject (readonly)

Returns the value of attribute load_proc.



12
13
14
# File 'lib/qt_widget_gl.rb', line 12

def load_proc
  @load_proc
end

#widthObject

Returns the value of attribute width.



9
10
11
# File 'lib/qt_widget_gl.rb', line 9

def width
  @width
end

Instance Method Details

#disposeObject



27
28
29
# File 'lib/qt_widget_gl.rb', line 27

def dispose()
  super
end

#get_GLUT_button(event) ⇒ Object



47
48
49
50
51
52
# File 'lib/qt_widget_gl.rb', line 47

def get_GLUT_button(event)
  return GLUT::GLUT_RIGHT_BUTTON if( event.button == Qt::RightButton)
  return GLUT::GLUT_MIDDLE_BUTTON if( event.button == Qt::MidButton)
  return GLUT::GLUT_LEFT_BUTTON if( event.button == Qt::LeftButton)
  return nil
end

#idle_process(wait_msec = nil, &block) ⇒ Object



79
80
81
82
# File 'lib/qt_widget_gl.rb', line 79

def idle_process(wait_msec = nil, &block)
  @idle_proc = block
  @idle_process_timer_id = startTimer(wait_msec)
end

#initializeGLObject



35
36
37
# File 'lib/qt_widget_gl.rb', line 35

def initializeGL()
  @view = Disp3D::GLView.new(@width, @height)
end

#minimumSizeHintObject



39
40
41
# File 'lib/qt_widget_gl.rb', line 39

def minimumSizeHint()
  return Qt::Size.new(@min_width, @min_height)
end

#mouseMoveEvent(event) ⇒ Object



64
65
66
67
68
69
# File 'lib/qt_widget_gl.rb', line 64

def mouseMoveEvent(event)
  need_update = @view.mouse_move_process(event.pos.x,event.pos.y)
  if(need_update)
    updateGL()
  end
end

#mousePressEvent(event) ⇒ Object



59
60
61
62
# File 'lib/qt_widget_gl.rb', line 59

def mousePressEvent(event)
  glut_button = get_GLUT_button(event)
  @view.mouse_press_process(glut_button, event.pos.x, event.pos.y)
end

#mouseReleaseEvent(event) ⇒ Object



54
55
56
57
# File 'lib/qt_widget_gl.rb', line 54

def mouseReleaseEvent(event)
  glut_button = get_GLUT_button(event)
  @view.mouse_release_process(glut_button, event.pos.x, event.pos.y)
end

#paintGLObject



71
72
73
# File 'lib/qt_widget_gl.rb', line 71

def paintGL
  @view.gl_display
end

#resizeGL(width, height) ⇒ Object



75
76
77
# File 'lib/qt_widget_gl.rb', line 75

def resizeGL(width, height)
  @view.reshape(width, height)
end

#set_load_proc(proc) ⇒ Object



31
32
33
# File 'lib/qt_widget_gl.rb', line 31

def set_load_proc(proc)
  @load_proc = proc
end

#sizeHintObject



43
44
45
# File 'lib/qt_widget_gl.rb', line 43

def sizeHint()
  return Qt::Size.new(@width, @height)
end

#timerEvent(event) ⇒ Object



84
85
86
87
88
# File 'lib/qt_widget_gl.rb', line 84

def timerEvent(event)
  if( event.timerId == @idle_process_timer_id)
    @idle_proc.call
  end
end