-
Notifications
You must be signed in to change notification settings - Fork 87
/
2dview.html
85 lines (75 loc) · 2.65 KB
/
2dview.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
<div class="twodview">
<div class="alert alert-warning">
THIS IS IN DEVELOPMENT
</div>
<div id="viewport2d" class="viewport2d">
<svg xmlns="http://www.w3.org/2000/svg"></svg>
</div>
</div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script>
function TwoDView(containerDiv, projectPage) {
var o = this;
this.resize = function(){
$("#viewport").width($("panel-body").width() + "px");
$("#viewport").height(($(window).height() - $(".navbar").outerHeight() - $(".rightpanel .panel-heading").outerHeight() - 88) + "px");
};
this.show = function(){
o.resize();
$(window).resize(o.resize);
};
this.selected = function(groupId, id){
};
this.unselected = function(groupId, id){
};
this.objectVisibilityChanged = function(objects, oldModes){
};
this.unloadRevision = function(poid, roid) {
};
this.loadRevision = function(project, roid, types){
var model = projectPage.models[roid];
model.getAllOfType("IfcWall", true, function(ifcProduct){
ifcProduct.getObjectPlacement(function(objectPlacement){
if (objectPlacement.getType() == "IfcLocalPlacement") {
objectPlacement.getRelativePlacement(function(relPlace){
relPlace.getLocation(function(location){
var locCoords = location.getCoordinates();
ifcProduct.getRepresentation(function(representation){
if (representation != null) {
representation.getRepresentations(function(rep){
if (rep.getType() == "IfcShapeRepresentation") {
if (rep.getRepresentationType() == "Curve2D") {
rep.getItems(function(item){
if (item.getType() == "IfcPolyline") {
var polyline = d3.select("svg").append("polyline").attr("style", "fill:white;stroke:black;stroke-width:1");
var points = [];
var scale = 10;
item.getPoints(function(cartesianPoint){
var coords = cartesianPoint.getCoordinates();
points.push((coords[0] + locCoords[0]) * scale, (coords[1] + locCoords[1]) * scale);
}).done(function(){
polyline.attr("points", points)
});
}
});
} else {
console.log("Unimplemented " + rep.getRepresentationType());
}
}
});
}
});
});
});
}
});
});
};
projectPage.selectListeners.register(o.selected);
projectPage.unselectListeners.register(o.unselected);
projectPage.objectVisibilityListeners.register(o.objectVisibilityChanged);
projectPage.modelLoadedListeners.register(o.loadRevision);
projectPage.modelUnloadedListeners.register(o.unloadRevision);
o.show();
}
</script>