-
Notifications
You must be signed in to change notification settings - Fork 87
/
properties.html
221 lines (203 loc) · 6.97 KB
/
properties.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<div class="properties">
<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 Properties(containerDiv, parent, oid) {
var othis = this;
othis.selected = null;
this.close = function(){};
this.loaded = false;
this.objectClick = function(){
var oid = $(this).data("oid");
parent.rightPanel.loadBrowser(function(){
this.loadObject(parent.project.oid, oid);
}, true);
};
this.selected = function(origin, groupId, object) {
if (othis.selected == object) {
return;
}
othis.selected = object;
containerDiv.find("table").hide();
containerDiv.find("table tbody tr").remove();
if (object != null) {
containerDiv.find("table tbody").append("<tr class=\"active\"><td colspan=\"2\"><b>" + object.getType() + "</b></td></tr>");
if (object.getName() != null) {
containerDiv.find("table tbody").append("<tr><td>Name</td><td>" + object.getName() + "</td></tr>");
}
if (object.getDescription() != null && object.getDescription() != "") {
containerDiv.find("table tbody").append("<tr><td>Description</td><td>" + object.getDescription() + "</td></tr>");
}
if (object.object._rOwnerHistory != null) {
var a = $("<a>Owner History</a>");
a.data("oid", object.object._rOwnerHistory);
a.click(othis.objectClick);
var td = $("<td>");
td.append(a);
var tr = $("<tr><td>Owner History</td></tr>");
tr.append(td);
containerDiv.find("table tbody").append(tr);
}
if (object.getGlobalId() != null) {
containerDiv.find("table tbody").append("<tr><td>GUID</td><td>" + object.getGlobalId() + "</td></tr>");
}
if (object.object._u != null) {
containerDiv.find("table tbody").append("<tr><td>UUID (BIMserver)</td><td>" + object.object._u + "</td></tr>");
}
object.getIsDefinedBy(function(isDefinedBy){
if (isDefinedBy.getType() == "IfcRelDefinesByProperties") {
isDefinedBy.getRelatingPropertyDefinition(function(propertySet){
if (propertySet.getType() == "IfcPropertySet") {
containerDiv.find("table tbody tr.noprop").remove();
othis.showPropertySet(propertySet);
}
});
}
});
var headerTr = $("<tr class=\"active\"></tr>");
containerDiv.find("table tbody").append(headerTr);
var headerTd = $("<td colspan=\"2\"></td>");
headerTr.append(headerTd).hide();
headerTd.append("<b>Calculated</b>");
object.getGeometry(function(geometryInfo){
if (geometryInfo != null) {
var knownTranslations = {
TOTAL_SURFACE_AREA: "Total surface area",
TOTAL_SHAPE_VOLUME: "Total shape volume",
SURFACE_AREA_ALONG_X: "Surface area along X axis",
SURFACE_AREA_ALONG_Y: "Surface area along Y axis",
SURFACE_AREA_ALONG_Z: "Surface area along Z axis",
WALKABLE_SURFACE_AREA: "Walkable surface area",
LARGEST_FACE_AREA: "Largest face area",
BOUNDING_BOX_SIZE_ALONG_X: "Bounding box size along X axis",
BOUNDING_BOX_SIZE_ALONG_Y: "Bounding box size along Y axis",
BOUNDING_BOX_SIZE_ALONG_Z: "Bounding box size along Z axis",
LARGEST_FACE_DIRECTION: "Largest face direction"
};
if (geometryInfo.object.additionalData != null) {
var additionalData = JSON.parse(geometryInfo.object.additionalData);
for (const key in additionalData) {
headerTr.show();
const tr = $("<tr></tr>");
if (knownTranslations[key] == null) {
tr.append("<td>" + key + "</td>");
} else {
tr.append("<td>" + knownTranslations[key] + "</td>");
}
const value = additionalData[key];
if (value.toFixed == null) {
tr.append("<td>" + value + "</td>");
} else {
tr.append("<td>" + value.toFixed(2) + "</td>");
}
headerTr.after(tr);
}
};
}
});
var current = parent.rightPanel.tabChanger.current;
if (current != null) {
var node = current.viewer.scene.findNode(object.gid);
if (node != null) {
var geometryInfo = {
nrTriangles: 0,
nrVertices: 0
};
othis.processGeometryInfo(node, geometryInfo);
}
} else {
console.log(parent.rightPanel.tabChanger);
}
} else {
if (this.loaded) {
containerDiv.find("table tbody").append("<tr class=\"noprop\"><td>No object selected</td></tr>");
}
}
containerDiv.find("table").show();
};
this.processGeometryInfo = function(node, geometryInfo){
if (node.type == "geometry") {
if (node._core.indexBuf != null) {
geometryInfo.nrTriangles += node._core.indexBuf.length / 3;
geometryInfo.nrVertices += node._core.vertexBuf.length / 3;
}
}
node.nodes.forEach(function(subNode){
othis.processGeometryInfo(subNode, geometryInfo);
});
};
this.hide = function(){
containerDiv.hide();
};
this.show = function(){
containerDiv.show();
};
this.getSelected = function(){
return othis.selected;
};
this.unselected = function(groupId, id){
othis.selected = null;
containerDiv.find("table tbody tr").remove();
containerDiv.find("table tbody").append("<tr class=\"noprop\"><td>No object selected</td></tr>");
};
this.showProperty = function (propertySet, property, headerTr){
var tr = $("<tr></tr>");
tr.attr("oid", property.oid);
tr.attr("psetoid", propertySet.oid);
headerTr.after(tr);
tr.append("<td>" + property.getName() + "</td>");
othis.getValue(tr, property);
};
this.showProperties = function(propertySet, headerTr) {
propertySet.getHasProperties(function(property){
if (property.getType() == "IfcPropertySingleValue") {
othis.showProperty(propertySet, property, headerTr);
}
});
}
this.showPropertySet = function(propertySet) {
var headerTr = $("<tr class=\"active\"></tr>");
headerTr.attr("oid", propertySet.oid);
headerTr.attr("uri", propertySet.getName());
containerDiv.find("table tbody").append(headerTr);
var headerTd = $("<td colspan=\"2\"></td>");
headerTr.append(headerTd);
headerTd.append("<b>" + propertySet.getName() + "</b>");
othis.showProperties(propertySet, headerTr);
}
this.getValue = function(tr, property) {
(function (tr) {
property.getNominalValue(function(value){
var td = $("<td>");
var v = value == null ? "" : value._v;
var span = $("<span class=\"value nonEditable\">" + v + "</span>");
td.append(span);
tr.append(td);
});
} )(tr);
}
this.loadRevision = function(){
containerDiv.find(".modelLoader").hide();
containerDiv.find(".noprop").remove();
containerDiv.find("table tbody").append("<tr class=\"noprop\"><td>No object selected</td></tr>");
this.loaded = true;
};
this.unloadRevision = function(){};
parent.selectListeners.register(othis.selected);
parent.unselectListeners.register(othis.unselected);
parent.modelLoadedListeners.register(othis.loadRevision);
parent.modelUnloadedListeners.register(othis.unloadRevision);
containerDiv.find(".btnLoad").click(parent.loadModel);
if (othis.selected != null) {
othis.selected(othis.selected);
}
}
</script>