Class: Fox::FXGLGroup
- Inherits:
-
FXGLObject
- Object
- FXGLObject
- Fox::FXGLGroup
- Includes:
- Enumerable
- Defined in:
- lib/fox16/glgroup.rb
Overview
A group of OpenGL objects
Constant Summary
- FLT_MAX =
1.0e+20- FLT_MIN =
-1.0e+20
Instance Method Summary (collapse)
-
- (Object) [](pos)
Return child at position pos.
-
- (Object) []=(pos, obj)
Set child at position pos to obj.
-
- (Object) append(obj)
(also: #<<)
Append child object.
-
- (Object) bounds
Return bounding box for this group (an FXRangef instance).
-
- (Object) canDrag
Return true if group can be dragged.
-
- (Object) clear
Remove all children from this group.
-
- (Object) drag(viewer, fx, fy, tx, ty)
Drag group object around in viewer (an FXGLViewer instance), from (fx, fy) to (tx, ty).
-
- (Object) draw(viewer)
Draw this group into viewer (an FXGLViewer instance).
-
- (Object) each_child
(also: #each)
Iterate over child objects.
-
- (Object) hit(viewer)
Perform hit test in viewer (an FXGLViewer instance).
-
- (Object) identify(path)
Identify object by means of path.
-
- (FXGLGroup) initialize
constructor
Returns an initialized FXGLGroup instance.
-
- (Object) insert(pos, obj)
Insert child object (obj) at position pos.
-
- (Object) prepend(obj)
Prepend child object (obj).
-
- (Object) remove(obj)
(also: #erase)
If obj is a reference to an FXGLObject in this group, remove the child object from the list.
-
- (Object) replace(pos, obj)
Replace child object at position pos with obj.
-
- (Object) size
Return number of objects in this group.
Constructor Details
- (FXGLGroup) initialize
Returns an initialized FXGLGroup instance
21 22 23 24 |
# File 'lib/fox16/glgroup.rb', line 21 def initialize super @list = [] end |
Instance Method Details
- (Object) [](pos)
Return child at position pos.
36 37 38 |
# File 'lib/fox16/glgroup.rb', line 36 def [](pos) @list[pos] end |
- (Object) []=(pos, obj)
Set child at position pos to obj.
43 44 45 |
# File 'lib/fox16/glgroup.rb', line 43 def []=(pos, obj) @list[pos] = obj end |
- (Object) append(obj) Also known as: <<
Append child object
131 132 133 |
# File 'lib/fox16/glgroup.rb', line 131 def append(obj) @list << obj end |
- (Object) bounds
Return bounding box for this group (an FXRangef instance)
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fox16/glgroup.rb', line 60 def bounds box = nil if @list.empty? box = FXRangef.new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0) else box = FXRangef.new(FLT_MAX, -FLT_MAX, FLT_MAX, -FLT_MAX, FLT_MAX, -FLT_MAX) @list.each { |obj| box.include!(obj.bounds) } end box end |
- (Object) canDrag
Return true if group can be dragged.
102 103 104 |
# File 'lib/fox16/glgroup.rb', line 102 def canDrag true end |
- (Object) clear
Remove all children from this group.
162 163 164 |
# File 'lib/fox16/glgroup.rb', line 162 def clear @list.clear end |
- (Object) drag(viewer, fx, fy, tx, ty)
Drag group object around in viewer (an FXGLViewer instance), from (fx, fy) to (tx, ty).
110 111 112 |
# File 'lib/fox16/glgroup.rb', line 110 def drag(viewer, fx, fy, tx, ty) @list.each { |obj| obj.drag(viewer, fx, fy, tx, ty) } end |
- (Object) draw(viewer)
Draw this group into viewer (an FXGLViewer instance).
74 75 76 |
# File 'lib/fox16/glgroup.rb', line 74 def draw(viewer) @list.each { |obj| obj.draw(viewer) } end |
- (Object) each_child Also known as: each
Iterate over child objects
50 51 52 53 |
# File 'lib/fox16/glgroup.rb', line 50 def each_child # :yields: childObject @list.each { |child| yield child } self end |
- (Object) hit(viewer)
Perform hit test in viewer (an FXGLViewer instance).
81 82 83 84 85 86 87 88 89 |
# File 'lib/fox16/glgroup.rb', line 81 def hit(viewer) # GL.PushName(0xffffffff) GL.PushName(1000000) @list.each_with_index do |obj, i| GL.LoadName(i) obj.hit(viewer) end GL.PopName end |
- (Object) identify(path)
Identify object by means of path.
94 95 96 97 |
# File 'lib/fox16/glgroup.rb', line 94 def identify(path) objIndex = path.shift @list[objIndex].identify(path) end |
- (Object) insert(pos, obj)
Insert child object (obj) at position pos.
117 118 119 |
# File 'lib/fox16/glgroup.rb', line 117 def insert(pos, obj) raise NotImplementedError end |
- (Object) prepend(obj)
Prepend child object (obj).
124 125 126 |
# File 'lib/fox16/glgroup.rb', line 124 def prepend(obj) @list.unshift(obj) end |
- (Object) remove(obj) Also known as: erase
If obj is a reference to an FXGLObject in this group, remove the child object from the list. If obj is an integer, remove the child object at that position from the list.
149 150 151 152 153 154 155 |
# File 'lib/fox16/glgroup.rb', line 149 def remove(obj) if obj.is_a? FXGLObject @list.delete(obj) else @list.delete_at(obj) end end |
- (Object) replace(pos, obj)
Replace child object at position pos with obj.
140 141 142 |
# File 'lib/fox16/glgroup.rb', line 140 def replace(pos, obj) @list[pos] = obj end |
- (Object) size
Return number of objects in this group.
29 30 31 |
# File 'lib/fox16/glgroup.rb', line 29 def size @list.size end |