Class: Disp3D::NodeCollection
- Inherits:
-
Node
- Object
- Node
- Disp3D::NodeCollection
show all
- Defined in:
- lib/node/node_collection.rb
Instance Attribute Summary
Attributes inherited from Node
#instance_id, #name, #parents
Instance Method Summary
collapse
Methods inherited from Node
#ancestors, #post_draw, #pre_draw
Constructor Details
Returns a new instance of NodeCollection.
5
6
7
8
|
# File 'lib/node/node_collection.rb', line 5
def initialize(name = nil)
super
@children = Hash.new()
end
|
Instance Method Details
#add(node) ⇒ Object
returns generated path_id
15
16
17
18
19
20
21
|
# File 'lib/node/node_collection.rb', line 15
def add(node)
if(node.kind_of?(Symbol))
add_node_by_name(node)
else
add_node(node)
end
end
|
#box ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/node/node_collection.rb', line 35
def box
return nil if @children == nil || @children.size == 0
rtnbox = nil
@children.each do |key, node|
adding_box = box_transform(node.box)
if rtnbox.nil?
rtnbox = adding_box
else
rtnbox += adding_box
end
end
return rtnbox
end
|
#child(path_id) ⇒ Object
53
54
55
|
# File 'lib/node/node_collection.rb', line 53
def child(path_id)
return @children[path_id]
end
|
#child_nodes ⇒ Object
57
58
59
|
# File 'lib/node/node_collection.rb', line 57
def child_nodes
return @children.values
end
|
#child_path_id ⇒ Object
61
62
63
|
# File 'lib/node/node_collection.rb', line 61
def child_path_id
return @children.keys
end
|
#draw(currnet_view) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/node/node_collection.rb', line 23
def draw currnet_view
pre_draw()
@children.each do |key, node|
if(node.kind_of?(NodeLeaf))
NodePathDB.add(key, node)
GL.LoadName(key)
end
node.draw currnet_view
end
post_draw()
end
|
#include?(path_id) ⇒ Boolean
49
50
51
|
# File 'lib/node/node_collection.rb', line 49
def include?(path_id)
@children.include?(path_id)
end
|
#open(&block) ⇒ Object
10
11
12
|
# File 'lib/node/node_collection.rb', line 10
def open(&block)
self.instance_eval(&block)
end
|