Class: Fox::FXGLGroup
- Inherits:
-
FXGLObject
- Object
- FXObject
- FXGLObject
- Fox::FXGLGroup
- Includes:
- Enumerable
- Defined in:
- lib/fox16/glgroup.rb
Overview
A group of OpenGL objects
Constant Summary collapse
- FLT_MAX =
1.0e+20
- FLT_MIN =
-1.0e+20
Instance Method Summary collapse
-
#[](pos) ⇒ Object
Return child at position pos.
-
#[]=(pos, obj) ⇒ Object
Set child at position pos to obj.
-
#append(obj) ⇒ Object
(also: #<<)
Append child object.
-
#bounds ⇒ Object
Return bounding box for this group (an FXRangef instance).
-
#canDrag ⇒ Object
Return
true
if group can be dragged. -
#clear ⇒ Object
Remove all children from this group.
-
#drag(viewer, fx, fy, tx, ty) ⇒ Object
Drag group object around in viewer (an FXGLViewer instance), from (fx, fy) to (tx, ty).
-
#draw(viewer) ⇒ Object
Draw this group into viewer (an FXGLViewer instance).
-
#each_child ⇒ Object
(also: #each)
Iterate over child objects.
-
#hit(viewer) ⇒ Object
Perform hit test in viewer (an FXGLViewer instance).
-
#identify(path) ⇒ Object
Identify object by means of path.
-
#initialize ⇒ FXGLGroup
constructor
Returns an initialized FXGLGroup instance.
-
#insert(pos, obj) ⇒ Object
Insert child object (obj) at position pos.
-
#prepend(obj) ⇒ Object
Prepend child object (obj).
-
#remove(obj) ⇒ Object
(also: #erase)
If obj is a reference to an FXGLObject in this group, remove the child object from the list.
-
#replace(pos, obj) ⇒ Object
Replace child object at position pos with obj.
-
#size ⇒ Object
Return number of objects in this group.
Methods inherited from FXGLObject
Methods inherited from FXObject
#bind, #handle, #load, #save, subclasses
Constructor Details
#initialize ⇒ FXGLGroup
Returns an initialized FXGLGroup instance
20 21 22 23 |
# File 'lib/fox16/glgroup.rb', line 20 def initialize super @list = [] end |
Instance Method Details
#[](pos) ⇒ Object
Return child at position pos.
35 36 37 |
# File 'lib/fox16/glgroup.rb', line 35 def [](pos) @list[pos] end |
#[]=(pos, obj) ⇒ Object
Set child at position pos to obj.
42 43 44 |
# File 'lib/fox16/glgroup.rb', line 42 def []=(pos, obj) @list[pos] = obj end |
#append(obj) ⇒ Object Also known as: <<
Append child object
130 131 132 |
# File 'lib/fox16/glgroup.rb', line 130 def append(obj) @list << obj end |
#bounds ⇒ Object
Return bounding box for this group (an FXRangef instance)
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fox16/glgroup.rb', line 59 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 |
#canDrag ⇒ Object
Return true
if group can be dragged.
101 102 103 |
# File 'lib/fox16/glgroup.rb', line 101 def canDrag true end |
#clear ⇒ Object
Remove all children from this group.
161 162 163 |
# File 'lib/fox16/glgroup.rb', line 161 def clear @list.clear end |
#drag(viewer, fx, fy, tx, ty) ⇒ Object
Drag group object around in viewer (an FXGLViewer instance), from (fx, fy) to (tx, ty).
109 110 111 |
# File 'lib/fox16/glgroup.rb', line 109 def drag(viewer, fx, fy, tx, ty) @list.each { |obj| obj.drag(viewer, fx, fy, tx, ty) } end |
#draw(viewer) ⇒ Object
Draw this group into viewer (an FXGLViewer instance).
73 74 75 |
# File 'lib/fox16/glgroup.rb', line 73 def draw(viewer) @list.each { |obj| obj.draw(viewer) } end |
#each_child ⇒ Object Also known as: each
Iterate over child objects
49 50 51 52 |
# File 'lib/fox16/glgroup.rb', line 49 def each_child # :yields: childObject @list.each { |child| yield child } self end |
#hit(viewer) ⇒ Object
Perform hit test in viewer (an FXGLViewer instance).
80 81 82 83 84 85 86 87 88 |
# File 'lib/fox16/glgroup.rb', line 80 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 |
#identify(path) ⇒ Object
Identify object by means of path.
93 94 95 96 |
# File 'lib/fox16/glgroup.rb', line 93 def identify(path) objIndex = path.shift @list[objIndex].identify(path) end |
#insert(pos, obj) ⇒ Object
Insert child object (obj) at position pos.
116 117 118 |
# File 'lib/fox16/glgroup.rb', line 116 def insert(pos, obj) raise NotImplementedError end |
#prepend(obj) ⇒ Object
Prepend child object (obj).
123 124 125 |
# File 'lib/fox16/glgroup.rb', line 123 def prepend(obj) @list.unshift(obj) end |
#remove(obj) ⇒ Object 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.
148 149 150 151 152 153 154 |
# File 'lib/fox16/glgroup.rb', line 148 def remove(obj) if obj.is_a? FXGLObject @list.delete(obj) else @list.delete_at(obj) end end |
#replace(pos, obj) ⇒ Object
Replace child object at position pos with obj.
139 140 141 |
# File 'lib/fox16/glgroup.rb', line 139 def replace(pos, obj) @list[pos] = obj end |
#size ⇒ Object
Return number of objects in this group.
28 29 30 |
# File 'lib/fox16/glgroup.rb', line 28 def size @list.size end |