-
Notifications
You must be signed in to change notification settings - Fork 87
/
types.html
160 lines (144 loc) · 4.35 KB
/
types.html
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<div class="types">
<div class="spaced modelLoader">
No models loaded
<button class="btn btn-default btn-xs btnLoad">Load all</button>
</div>
<table class="table table-no-top">
<thead></thead>
<tbody>
</tbody>
</table>
</div>
<script>
function Types(containerDiv, parent) {
var othis = this;
othis.types = {};
this.close = function(){};
this.toggleEye = function(type, mode){
for (var roid in parent.models) {
var model = parent.models[roid];
var oids = [];
model.getAllOfType(type, false, function(object){
oids.push(object.oid);
});
parent.setObjectVisibility(roid, oids, mode);
}
};
this.getSelectedId = function(){
return -1;
};
this.hide = function(){
containerDiv.hide();
};
this.show = function(){
containerDiv.show();
};
this.objectVisibilityChanged = function(objects, oldModes){
for (var i=0; i<objects.length; i++) {
var object = objects[i];
var oldMode = oldModes[i];
var item = othis.types[object.getType()];
if (item != null) {
var tr = item.tr;
if (oldMode == 0) {
item.visible--;
} else if (oldMode == 1) {
item.transparent--;
}
var newMode = object.trans.mode;
if (newMode == 0) {
item.visible++;
} else if (newMode == 1) {
item.transparent++;
}
var eye = item.eye;
if (eye != null) {
if (item.visible == item.total) {
eye.attr("mode", 0);
eye.removeClass("eyeclosed").removeClass("eyehalfopen").addClass("eyeopen");
} else if (item.transparent == item.total) {
eye.attr("mode", 1);
eye.removeClass("eyeopen").removeClass("eyeclosed").addClass("eyehalfopen");
} else if (item.visible == 0) {
eye.attr("mode", 2);
eye.removeClass("eyehalfopen").removeClass("eyeopen").addClass("eyeclosed");
}
}
}
}
};
this.loadRevision = function(project, roid){
containerDiv.find(".modelLoader").hide();
if (roid != -1 && project.nrSubProjects == 0 || project.subProjects.length == 0) {
var model = parent.models[roid];
var t = 0;
model.getAllOfType("IfcProduct", true, function(object){
t++;
if (object.isA("IfcProduct")) {
var type = object.getType();
if (othis.types[type] == null) {
othis.types[type] = {visible: 0, transparent: 0, total: 0};
}
if (object.trans.mode == 0) {
othis.types[type].visible = othis.types[type].visible + 1;
} else if (object.trans.mode == 1) {
othis.types[type].transparent = othis.types[type].transparent + 1;
}
othis.types[type].total = othis.types[type].total + 1;
}
}).done(function(){
if (Object.keys(othis.types).length == 0) {
containerDiv.find("table tbody").append("<tr><td>No types</td></tr>");
} else {
containerDiv.find("table tbody tr").remove();
for (var key in othis.types) {
var tr = $("<tr>");
var state = othis.types[key];
if (state == null) {
console.log("Wrong state");
} else {
var count = state.total;
tr.attr("type", key);
var td = $("<td>" + stripIfc(key) + "</td>");
tr.append(td);
containerDiv.find("table tbody").append(tr);
var eye = $("<div>");
eye.addClass("eye");
var mode = state.visible == state.total ? 0 : 2;
if (mode == 0) {
eye.addClass("eyeopen");
} else if (mode == 1) {
eye.addClass("eyehalfopen");
} else if (mode == 2) {
eye.addClass("eyeclosed");
}
eye.attr("type", key);
eye.attr("mode", mode);
eye.toggle(parent.threeDAspectVisible.get());
eye.click(function(){
var eye = $(this);
var mode = parseInt(eye.attr("mode"));
othis.toggleEye(eye.attr("type"), (mode + 1) % 3);
});
td.append(eye);
state.eye = eye;
state.tr = tr;
td.append(" <span class=\"badge\" style=\"float: right\">" + count + "</span>");
}
}
}
});
}
};
othis.unloadRevision = function(poid, roid) {
};
this.setShowEyes = function(show){
containerDiv.find(".eye").toggle(show);
};
containerDiv.find(".btnLoad").click(parent.loadModel);
parent.objectVisibilityListeners.register(othis.objectVisibilityChanged);
parent.modelLoadedListeners.register(othis.loadRevision);
parent.modelUnloadedListeners.register(othis.unloadRevision);
parent.threeDAspectVisible.register(othis.setShowEyes);
};
</script>