clean code and display profil windows once a marker is added

This commit is contained in:
monodo 2016-04-19 10:06:20 +02:00
parent 7cc0832623
commit 95a5171402
3 changed files with 16 additions and 48 deletions

View File

@ -11,8 +11,7 @@ Potree.Viewer.Profile = function(viewer, element){
this.margin = {top: 0, right: 0, bottom: 20, left: 40};
this.maximized = false;
this.threshold = 20*1000;
$('#closeProfileContainer').click(function(){
scope.hide();
scope.enabled = false;
@ -151,7 +150,6 @@ Potree.Viewer.Profile = function(viewer, element){
// user data
// point source id
view.setUint16(boffset + 18, point.pointSourceID);
view.setUint16(boffset + 20, (point.color[0] * 255), true);
view.setUint16(boffset + 22, (point.color[1] * 255), true);
view.setUint16(boffset + 24, (point.color[2] * 255), true);
@ -159,7 +157,6 @@ Potree.Viewer.Profile = function(viewer, element){
boffset += 28;
}
// max x 179 8
view.setFloat64(179, boundingBox.max.x, true);
@ -715,6 +712,7 @@ Potree.Viewer.Profile = function(viewer, element){
viewer.addEventListener("material_changed", function(){
drawOnChange({profile: scope.currentProfile});
});
viewer.addEventListener("height_range_changed", function(){
drawOnChange({profile: scope.currentProfile});
});
@ -723,19 +721,17 @@ Potree.Viewer.Profile = function(viewer, element){
var height = document.getElementById('profile_window').clientHeight;
function resizeLoop(){
requestAnimationFrame(resizeLoop);
var newWidth = document.getElementById('profile_window').clientWidth;
var newHeight = document.getElementById('profile_window').clientHeight;
if(newWidth !== width || newHeight !== height){
setTimeout(drawOnChange, 50, {profile: scope.currentProfile});
}
width = newWidth;
height = newHeight;
};
requestAnimationFrame(resizeLoop);
};

View File

@ -483,9 +483,7 @@ function initMeasurementDetails(){
elPanelHeader.appendChild(elPanelStretch);
elPanelHeader.appendChild(elPanelRemove);
elPanel.appendChild(elPanelBody);
//elPanelBody.appendChild(document.createTextNode("lala"));
//$('#measurement_details').append(elLi);
document.getElementById("measurement_details").appendChild(elLi);
var widthListener;
@ -496,7 +494,7 @@ function initMeasurementDetails(){
profile.removeEventListener("width_changed", widthListener);
}
}
$(elPanelBody).empty();
if(profile){
@ -593,11 +591,7 @@ function initMeasurementDetails(){
var elNodeAngle = $('<div>').addClass("measurement-detail-node-angle");
elNodeAngle.html(txt);
$(elPanelBody).append(elNodeAngle);
//if(i < positions.length - 1){
// var elEdge = $('<div>').addClass("measurement-detail-edge");
// $(elPanelBody).append(elEdge);
//}
}
if(i < positions.length - 1){
@ -605,7 +599,7 @@ function initMeasurementDetails(){
$(elPanelBody).append(elEdge);
}
}
if(points && points.length === 1){
var point = points[0];
@ -702,7 +696,7 @@ function initMeasurementDetails(){
$(elPanelBody).append(elNodeArea);
}
if(profile){
// show 2d profile button
var elOpenProfileWindow = $('<input type="button" value="show 2d profile">')
@ -731,7 +725,11 @@ function initMeasurementDetails(){
}
});
}else if(profile){
viewer.profileTool.addEventListener("marker_added", updateDisplay);
viewer.profileTool.addEventListener("marker_added", function(){
viewer._2dprofile.show();
viewer._2dprofile.draw(profile);
updateDisplay();
});
viewer.profileTool.addEventListener("marker_removed", updateDisplay);
viewer.profileTool.addEventListener("marker_moved", updateDisplay);
viewer.profileTool.addEventListener("profile_removed", function(event){

View File

@ -68,32 +68,6 @@ Potree.Viewer = function(domElement, args){
this.showSkybox = false;
this.referenceFrame;
//------------------------------------------------------------------------------------
// Viewer API
//------------------------------------------------------------------------------------
@ -1220,6 +1194,7 @@ Potree.Viewer = function(domElement, args){
scope.toGeo);
});
};
});
@ -1254,7 +1229,6 @@ Potree.Viewer = function(domElement, args){
}
function onKeyDown(event){
//console.log(event.keyCode);
if(event.keyCode === 69){
// e pressed