diff --git a/src/viewer/potree.css b/src/viewer/potree.css index 395b0b32..4c8f897f 100644 --- a/src/viewer/potree.css +++ b/src/viewer/potree.css @@ -70,7 +70,7 @@ #potree_sidebar_container{ position: absolute; z-index: 0; - width: 300px; + width: 350px; height: 100%; overflow-y: auto; font-size: 85%; @@ -764,5 +764,18 @@ label:hover{ */ +.input-grid-cell{ + flex-grow: 1; margin: 0px 3px 0px 3px; +} +.input-grid-label{ + flex-grow: 1; + margin: 0px 3px 0px 3px; + text-align:center; + font-weight: bold; +} + +.input-grid-cell > input{ + width: 100% +} diff --git a/src/viewer/sidebar.js b/src/viewer/sidebar.js index 74c0984f..c99b9ede 100644 --- a/src/viewer/sidebar.js +++ b/src/viewer/sidebar.js @@ -1121,8 +1121,50 @@ function initMeasurementDetails(){ this.elIcon.attr("src", this.icon); + this.values = {}; + this.elContent = $(`
+ +
+
+ x + y + z +
+
+ + + +
+
+ +
+
+ length + width + height +
+
+ + + +
+
+ +
+
+ α + β + γ +
+
+ + + +
+
+ @@ -1137,6 +1179,104 @@ function initMeasurementDetails(){ `); this.elContentContainer.append(this.elContent); + this.elX = this.elContent.find(`#volume_input_x_${this.measurement.id}`); + this.elY = this.elContent.find(`#volume_input_y_${this.measurement.id}`); + this.elZ = this.elContent.find(`#volume_input_z_${this.measurement.id}`); + + this.elLength = this.elContent.find(`#volume_input_length_${this.measurement.id}`); + this.elWidth = this.elContent.find(`#volume_input_width_${this.measurement.id}`); + this.elHeight = this.elContent.find(`#volume_input_height_${this.measurement.id}`); + + this.elAlpha = this.elContent.find(`#volume_input_alpha_${this.measurement.id}`); + this.elBeta = this.elContent.find(`#volume_input_beta_${this.measurement.id}`); + this.elGamma = this.elContent.find(`#volume_input_gamma_${this.measurement.id}`); + + + this.elX.on("change", (e) => { + let val = this.elX.val(); + if($.isNumeric(val)){ + val = parseFloat(val); + + this.measurement.position.x = val; + } + }); + + this.elY.on("change", (e) => { + let val = this.elY.val(); + if($.isNumeric(val)){ + val = parseFloat(val); + + this.measurement.position.y = val; + } + }); + + this.elZ.on("change", (e) => { + let val = this.elZ.val(); + if($.isNumeric(val)){ + val = parseFloat(val); + + this.measurement.position.z = val; + } + }); + + this.elLength.on("change", (e) => { + let val = this.elLength.val(); + if($.isNumeric(val)){ + val = parseFloat(val); + + this.measurement.scale.x = val; + } + }); + + this.elWidth.on("change", (e) => { + let val = this.elWidth.val(); + if($.isNumeric(val)){ + val = parseFloat(val); + + this.measurement.scale.y = val; + } + }); + + this.elHeight.on("change", (e) => { + let val = this.elHeight.val(); + if($.isNumeric(val)){ + val = parseFloat(val); + + this.measurement.scale.z = val; + } + }); + + let toRadians = (d) => Math.PI * d / 180; + + this.elAlpha.on("change", (e) => { + let val = this.elAlpha.val(); + if($.isNumeric(val)){ + val = parseFloat(val); + + this.measurement.rotation.x = toRadians(val); + } + }); + + this.elBeta.on("change", (e) => { + let val = this.elBeta.val(); + if($.isNumeric(val)){ + val = parseFloat(val); + + this.measurement.rotation.y = toRadians(val); + } + }); + + this.elGamma.on("change", (e) => { + let val = this.elGamma.val(); + if($.isNumeric(val)){ + val = parseFloat(val); + + this.measurement.rotation.z = toRadians(val); + } + }); + + + this.elDownloadButton = this.elContent.find(`#download_volume_${this.id}`); if(viewer.server){ @@ -1239,6 +1379,62 @@ function initMeasurementDetails(){ } update(){ + if(!this.destroyed){ + requestAnimationFrame(this._update); + } + + if(!this.elContent.is(":visible")){ + return; + } + + if(this.measurement.position.x !== this.values.x){ + this.elX.val(this.measurement.position.x.toFixed(3)); + this.values.x = this.measurement.position.x; + } + + if(this.measurement.position.y !== this.values.y){ + let elY = this.elContent.find(`#volume_input_y_${this.measurement.id}`); + elY.val(this.measurement.position.y.toFixed(3)); + this.values.y = this.measurement.position.y; + } + + if(this.measurement.position.z !== this.values.z){ + let elZ = this.elContent.find(`#volume_input_z_${this.measurement.id}`); + elZ.val(this.measurement.position.z.toFixed(3)); + this.values.z = this.measurement.position.z; + } + + if(this.measurement.scale.x !== this.values.length){ + this.elLength.val(this.measurement.scale.x.toFixed(3)); + this.values.length = this.measurement.scale.x; + } + + if(this.measurement.scale.y !== this.values.width){ + this.elWidth.val(this.measurement.scale.y.toFixed(3)); + this.values.width = this.measurement.scale.y; + } + + if(this.measurement.scale.z !== this.values.height){ + this.elHeight.val(this.measurement.scale.z.toFixed(3)); + this.values.height = this.measurement.scale.z; + } + + let toDegrees = (r) => 180 * r / Math.PI; + + if(this.measurement.rotation.x !== this.values.alpha){ + this.elAlpha.val(toDegrees(this.measurement.rotation.x).toFixed(1)); + this.values.alpha = this.measurement.rotation.x; + } + + if(this.measurement.rotation.y !== this.values.beta){ + this.elBeta.val(toDegrees(this.measurement.rotation.y).toFixed(1)); + this.values.beta = this.measurement.rotation.y; + } + + if(this.measurement.rotation.z !== this.values.gamma){ + this.elGamma.val(toDegrees(this.measurement.rotation.z).toFixed(1)); + this.values.gamma = this.measurement.rotation.z; + } } @@ -1248,6 +1444,8 @@ function initMeasurementDetails(){ this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); + + this.destroyed = true; } };