-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSelective.js
115 lines (89 loc) · 2.89 KB
/
Selective.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* $RCSfile: Selective.js,v $
* $Revision: 1.6 $ $Date: 2012/08/14 18:58:30 $
* Auth: Jochen Fritz ([email protected])
*
* Copyright (c) 1991-2012 by STEP Tools Inc.
* All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation is hereby granted, provided that this copyright
* notice and license appear on all copies of the software.
*
* STEP TOOLS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
* SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. STEP TOOLS
* SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A
* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES.
*
* ----------------------------------------
*/
function Selective(builder, id)
{
var ret = builder.make(id, this, "selective");
if (ret) return ret;
var el = builder.getElement(id);
this.initExecutable(builder, el);
this.elements = [];
var els = el["elements"];
for (var i=0; i<els.length; i++) {
// console.log ("Sel element:" +els[i]);
var ex = Executable(builder, els[i]);
if (ex)
this.elements.push(ex);
}
}
Executable.RegisterSubtype("selective", Selective);
SUBTYPE(Executable, Selective);
METHODS (Selective, {
getName : function() {return "Selective";},
getBoundingBox : function() {
var bbox = new BoundingBox();
for (var i=0; i<this.elements.length; i++) {
// console.log ("sel elements="+this.elements[i].getName());
bbox.updateFrom(this.elements[i].getBoundingBox());
}
// console.log ("Selective bbox="+bbox);
return bbox;
},
makeSceneGraph : function(cx, loadables, xform) {
var ret = new SGNode(cx, this);
for (var i=0; i<this.elements.length; i++)
ret.appendChild(this.elements[i].makeSceneGraph(cx, loadables,xform));
this.makeSceneGraphExecutable(cx, loadables);
return ret;
},
makeProjectTree : function(dom_parent, tn) {
var doc = dom_parent.ownerDocument;
var li = doc.createElement("li");
dom_parent.appendChild(li);
var n = this.appendTreeText(li, "SEL: "+this.name);
n.treenode = tn;
n.onclick = function() {
this.treenode.setActive();
this.treenode.redraw();
};
var ul = doc.createElement("ul");
li.appendChild(ul);
for (var i=0; i<this.elements.length; i++) {
var child = this.elements[i];
var child_tn = tn.getChild(i);
child.makeProjectTree(ul, child_tn);
}
},
// FIXME - make SGNode subtype
draw : function(gl, tn) {
for (var i=0; i<this.elements.length; i++) {
var el = this.elements[i];
if (!el.isEnabled) {
console.log ("el type="+el.getName());
throw new Error ("No isenabled method");
}
if (el.isEnabled())
tn.getChild(i).draw(gl);
}
},
getActive : function() {
}
});