From a8e332cdcb8be88238caac6acb7c81d9575246b3 Mon Sep 17 00:00:00 2001 From: m-schuetz Date: Sat, 23 Dec 2017 16:13:03 +0100 Subject: [PATCH] Save some intermediate stuff before trying a new tree view lib --- src/viewer/sidebar.html | 39 ++- src/viewer/sidebar.js | 578 +++------------------------------------- src/viewer/viewer.js | 4 + 3 files changed, 70 insertions(+), 551 deletions(-) diff --git a/src/viewer/sidebar.html b/src/viewer/sidebar.html index 480fb97a..f9aa820e 100644 --- a/src/viewer/sidebar.html +++ b/src/viewer/sidebar.html @@ -53,7 +53,30 @@
+ +
+ Measurement +
  • + +
    + Clipping +
    +
  • + + + +
  • +
  • + + + +
  • Navigation @@ -74,17 +97,17 @@
    - + diff --git a/src/viewer/sidebar.js b/src/viewer/sidebar.js index 736d6bf6..77dfade7 100644 --- a/src/viewer/sidebar.js +++ b/src/viewer/sidebar.js @@ -108,13 +108,6 @@ initSidebar = (viewer) => { } )); - // CLIP VOLUME - elToolbar.append(createToolIcon( - Potree.resourcePath + '/icons/clip_volume.svg', - '[title]tt.clip_volume', - function () { viewer.volumeTool.startInsertion({clip: true}); } - )); - // REMOVE ALL elToolbar.append(createToolIcon( Potree.resourcePath + '/icons/reset_tools.svg', @@ -125,6 +118,41 @@ initSidebar = (viewer) => { )); } + function initClippingTool() { + + $("#optClipMode").selectmenu(); + $("#optClipMode").val(1).selectmenu("refresh"); + $("#optClipMode").selectmenu({ + change: function(event, ui){ + viewer.clippingTool.setClipMode(parseInt(ui.item.value)); + } + }); + + //viewer.addEventListener("clipper.clipMode_changed", function(event){ + // $("#optClipMode").val(viewer.clippingTool.clipMode).selectmenu("refresh"); + //}); + + + let clippingToolBar = $("#clipping_tools"); + + // CLIP VOLUME + clippingToolBar.append(createToolIcon( + Potree.resourcePath + '/icons/clip_volume.svg', + '[title]tt.clip_volume', + function () { viewer.volumeTool.startInsertion({clip: true}); } + )); + + // CLIP POLYGON + clippingToolBar.append(createToolIcon( + Potree.resourcePath + "/icons/clip-polygon.svg", + "[title]tt.clip_polygon", + function(){ + viewer.clippingTool.startInsertion({type: "polygon"}); + } + )); + + } + function initClassificationList () { let elClassificationList = $('#classificationList'); @@ -391,542 +419,6 @@ initSidebar = (viewer) => { lblMoveSpeed.html(viewer.getMoveSpeed().toFixed(1)); } - - function initClippingTool() { - $("#clipping_volumes_container").hide(); - - $("#optClipMode").selectmenu(); - $("#optClipMode").val(1).selectmenu("refresh"); - $("#optClipMode").selectmenu({ - change: function(event, ui){ - viewer.clippingTool.setClipMode(parseInt(ui.item.value)); - } - }); - - viewer.addEventListener("clipper.clipMode_changed", function(event){ - $("#optClipMode").val(viewer.clippingTool.clipMode).selectmenu("refresh"); - }); - - - let clippingToolBar = $("#clipping_tools"); - - clippingToolBar.append(createToolIcon( - Potree.resourcePath + "/icons/clip-polygon.svg", - "[title]tt.clip_polygon", - function(){ - viewer.clippingTool.startInsertion({type: "polygon"}); - } - )); - - clippingToolBar.append(createToolIcon( - Potree.resourcePath + "/icons/clip-plane-x.svg", - "[title]tt.clip_plane_x", - function(){ - viewer.clippingTool.startInsertion({type: "plane", alpha: 0, beta: Math.PI/2, gamma: 0}); - } - )); - - clippingToolBar.append(createToolIcon( - Potree.resourcePath + "/icons/clip-plane-y.svg", - "[title]tt.clip_plane_y", - function(){ - viewer.clippingTool.startInsertion({type: "plane", alpha: Math.PI/2, beta: 0, gamma: 0}); - } - )); - - clippingToolBar.append(createToolIcon( - Potree.resourcePath + "/icons/clip-plane-z.svg", - "[title]tt.clip_plane_z", - function(){ - viewer.clippingTool.startInsertion({type: "plane", alpha: 0, beta: 0, gamma: 0}); - } - )); - - clippingToolBar.append(createToolIcon( - Potree.resourcePath + "/icons/reset_tools.svg", - "[title]tt.remove_all_clipping_volumes", - function(){ - viewer.scene.removeAllClipVolumes(); - } - )); - - viewer.scene.addEventListener("polygon_clip_volume_added", function(event) { - let pcv = event.volume; - $("#clipping_volumes_container").show(); - - let cvList = $("#clipping_volumes_list"); - - let createPCVitem = (volume) => { - let removeIconPath = Potree.resourcePath + "/icons/remove.svg"; - - let pcvItem = $(` -
    -
    - - - -
    -
    - `); - - // remove button - let pcvRemove = pcvItem.find(".clipping_volume_action_remove"); - pcvRemove.click(() => { - viewer.scene.removePolygonClipVolume(volume) - }); - - return pcvItem; - }; - - // wrapper which doesnt change - let icon = "/icons/area.svg"; - let pcvWrapper = $(` - - -
    - - ${pcv.name} -
    - - - -
    - `); - - pcvWrapper.find(".measurement_content").append(createPCVitem(pcv)); - - pcvWrapper.find(".scene_header").click(function(event) { - if($(this).next().is(":visible")) { - pcv.dispatchEvent({"type": "ui_deselect"}); - } else { - pcv.dispatchEvent({"type": "ui_select"}); - } - $(this).next().slideToggle(200); - }); - - cvList.append(pcvWrapper); - }); - - viewer.scene.addEventListener("polygon_clip_volume_removed", function(event) { - $("#" + event.volume.name).remove(); - - if(viewer.scene.clipVolumes.length == 0 && viewer.scene.polygonClipVolumes.length == 0) { - $("#clipping_volumes_container").hide(); - } - }); - - viewer.scene.addEventListener("clip_volume_added", function(event) { - let cv = event.volume; - $("#clipping_volumes_container").show(); - - let cvList = $("#clipping_volumes_list"); - - let createCVitem = (volume) => { - let x = Potree.utils.addCommas(volume.position.x.toFixed(3)); - let y = Potree.utils.addCommas(volume.position.y.toFixed(3)); - let z = Potree.utils.addCommas(volume.position.z.toFixed(3)); - let rot_alpha = (volume.rotation.x * 180/Math.PI).toFixed(0); - let rot_beta = (volume.rotation.y * 180/Math.PI).toFixed(0); - let rot_gamma = (volume.rotation.z * 180/Math.PI).toFixed(0); - let sc_width = Potree.utils.addCommas(volume.children[0].scale.x.toFixed(3)); - let sc_length = Potree.utils.addCommas(volume.children[0].scale.y.toFixed(3)); - let sc_thickness = Potree.utils.addCommas(volume.children[0].scale.z.toFixed(3)); - let removeIconPath = Potree.resourcePath + "/icons/remove.svg"; - - let cvItem = $(` -
    -
    - Size -
    -
    - - - - - - - - - - - - -
    widthlengththickness
    -
    -
    - -
    - Position -
    -
    - - - - - - - - - - - - -
    xyz
    ${x}${y}${z}
    -
    -
    -
    -
    - Offset: - -
    -
    - Global: -
    - - x - - - y - - - z - -
    -
    -
    - Local: -
    - - x - - - y - - - z - -
    -
    -
    - -
    - Rotation -
    -
    - - - - - - - - - - - - -
    αβγ
    ${rot_alpha}°${rot_beta}°${rot_gamma}°
    -
    -
    -
    -
    - Angle: - -
    -
    - Global: -
    - - α - - - β - - - γ - -
    -
    -
    - Local: -
    - - α - - - β - - - γ - -
    -
    -
    - -
    - - - -
    -
    - `); - - // spinner style - cvItem.find(".clip_volume_spinner").spinner(); - - // button style - let cv_btn_offset = cvItem.find(".cv_btn_offset"); - cv_btn_offset.button(); - cv_btn_offset.css("padding", "2px"); - cv_btn_offset.css("margin", "0px 3px"); - - // scale spinner - let cv_sp_width = cvItem.find("#cv_sp_width_" + volume.id); - let cv_sp_length = cvItem.find("#cv_sp_length_" + volume.id); - let cv_sp_thickness = cvItem.find("#cv_sp_thickness_" + volume.id); - - cv_sp_width.spinner({ - min: 0.001, - max: 100, - step: 0.1, - numberFormat: "n", - spin: (event, ui) => { - let value = cv_sp_width.spinner("value"); - volume.setScaleX(value); - }, - stop: (event, ui) => { - let value = cv_sp_width.spinner("value"); - volume.setScaleX(value); - } - }); - - cv_sp_length.spinner({ - min: 0.001, - max: 100, - step: 0.1, - numberFormat: "n", - spin: (event, ui) => { - let value = cv_sp_length.spinner("value"); - volume.setScaleY(value); - }, - stop: (event, ui) => { - let value = cv_sp_length.spinner("value"); - volume.setScaleY(value); - } - }); - - cv_sp_thickness.spinner({ - min: 0.001, - max: 100, - step: 0.1, - numberFormat: "n", - spin: (event, ui) => { - let value = cv_sp_thickness.spinner("value"); - volume.setScaleZ(value); - }, - stop: (event, ui) => { - let value = cv_sp_thickness.spinner("value"); - volume.setScaleZ(value); - } - }); - - // offset spinner - let cv_sp_offset = cvItem.find("#cv_sp_offset_" + volume.id); - cv_sp_offset.spinner({ - min: 0.001, - max: 1000, - step: 1.0, - numberFormat: "n", - spin: (event, ui) => { - let value = cv_sp_offset.spinner("value"); - volume.setClipOffset(value); - }, - stop: (event, ui) => { - let value = cv_sp_offset.spinner("value"); - volume.setClipOffset(value); - } - }); - - // angle offset spinner - let cv_sp_rot_offset = cvItem.find("#cv_sp_rot_offset_" + volume.id); - cv_sp_rot_offset.spinner({ - min: 1, - max: 360, - step: 1, - numberFormat: "n", - spin: (event, ui) => { - let value = cv_sp_rot_offset.spinner("value"); - volume.setClipRotOffset(value); - }, - stop: (event, ui) => { - let value = cv_sp_rot_offset.spinner("value"); - volume.setClipRotOffset(value); - } - }); - - // global offset buttons - let cv_btn_global_x_decr = cvItem.find("#cv_btn_global_x_decr_" + volume.id); - let cv_btn_global_x_incr = cvItem.find("#cv_btn_global_x_incr_" + volume.id); - let cv_btn_global_y_decr = cvItem.find("#cv_btn_global_y_decr_" + volume.id); - let cv_btn_global_y_incr = cvItem.find("#cv_btn_global_y_incr_" + volume.id); - let cv_btn_global_z_decr = cvItem.find("#cv_btn_global_z_decr_" + volume.id); - let cv_btn_global_z_incr = cvItem.find("#cv_btn_global_z_incr_" + volume.id); - - cv_btn_global_x_decr.click(function(event) { - volume.offset({cs: "global", axis: "x", dir: -1}); - }); - cv_btn_global_x_incr.click(function(event) { - volume.offset({cs: "global", axis: "x", dir: 1}); - }); - cv_btn_global_y_decr.click(function(event) { - volume.offset({cs: "global", axis: "y", dir: -1}); - }); - cv_btn_global_y_incr.click(function(event) { - volume.offset({cs: "global", axis: "y", dir: 1}); - }); - cv_btn_global_z_decr.click(function(event) { - volume.offset({cs: "global", axis: "z", dir: -1}); - }); - cv_btn_global_z_incr.click(function(event) { - volume.offset({cs: "global", axis: "z", dir: 1}); - }); - - // local offset buttons - let cv_btn_local_x_decr = cvItem.find("#cv_btn_local_x_decr_" + volume.id); - let cv_btn_local_x_incr = cvItem.find("#cv_btn_local_x_incr_" + volume.id); - let cv_btn_local_y_decr = cvItem.find("#cv_btn_local_y_decr_" + volume.id); - let cv_btn_local_y_incr = cvItem.find("#cv_btn_local_y_incr_" + volume.id); - let cv_btn_local_z_decr = cvItem.find("#cv_btn_local_z_decr_" + volume.id); - let cv_btn_local_z_incr = cvItem.find("#cv_btn_local_z_incr_" + volume.id); - - cv_btn_local_x_decr.click(function(event) { - volume.offset({cs: "local", axis: "x", dir: -1}); - }); - cv_btn_local_x_incr.click(function(event) { - volume.offset({cs: "local", axis: "x", dir: 1}); - }); - cv_btn_local_y_decr.click(function(event) { - volume.offset({cs: "local", axis: "y", dir: -1}); - }); - cv_btn_local_y_incr.click(function(event) { - volume.offset({cs: "local", axis: "y", dir: 1}); - }); - cv_btn_local_z_decr.click(function(event) { - volume.offset({cs: "local", axis: "z", dir: -1}); - }); - cv_btn_local_z_incr.click(function(event) { - volume.offset({cs: "local", axis: "z", dir: 1}); - }); - - // global angle offset - let cv_btn_global_alpha_decr = cvItem.find("#cv_btn_global_alpha_decr_" + volume.id); - let cv_btn_global_alpha_incr = cvItem.find("#cv_btn_global_alpha_incr_" + volume.id); - let cv_btn_global_beta_decr = cvItem.find("#cv_btn_global_beta_decr_" + volume.id); - let cv_btn_global_beta_incr = cvItem.find("#cv_btn_global_beta_incr_" + volume.id); - let cv_btn_global_gamma_decr = cvItem.find("#cv_btn_global_gamma_decr_" + volume.id); - let cv_btn_global_gamma_incr = cvItem.find("#cv_btn_global_gamma_incr_" + volume.id); - - cv_btn_global_alpha_decr.click(function(event) { - volume.rotate({cs: "global", axis: "x", dir: -1}); - }); - cv_btn_global_alpha_incr.click(function(event) { - volume.rotate({cs: "global", axis: "x", dir: 1}); - }); - cv_btn_global_beta_decr.click(function(event) { - volume.rotate({cs: "global", axis: "y", dir: -1}); - }); - cv_btn_global_beta_incr.click(function(event) { - volume.rotate({cs: "global", axis: "y", dir: 1}); - }); - cv_btn_global_gamma_decr.click(function(event) { - volume.rotate({cs: "global", axis: "z", dir: -1}); - }); - cv_btn_global_gamma_incr.click(function(event) { - volume.rotate({cs: "global", axis: "z", dir: 1}); - }); - - // local angle offset - let cv_btn_local_alpha_decr = cvItem.find("#cv_btn_local_alpha_decr_" + volume.id); - let cv_btn_local_alpha_incr = cvItem.find("#cv_btn_local_alpha_incr_" + volume.id); - let cv_btn_local_beta_decr = cvItem.find("#cv_btn_local_beta_decr_" + volume.id); - let cv_btn_local_beta_incr = cvItem.find("#cv_btn_local_beta_incr_" + volume.id); - let cv_btn_local_gamma_decr = cvItem.find("#cv_btn_local_gamma_decr_" + volume.id); - let cv_btn_local_gamma_incr = cvItem.find("#cv_btn_local_gamma_incr_" + volume.id); - - cv_btn_local_alpha_decr.click(function(event) { - volume.rotate({cs: "local", axis: "x", dir: -1}); - }); - cv_btn_local_alpha_incr.click(function(event) { - volume.rotate({cs: "local", axis: "x", dir: 1}); - }); - cv_btn_local_beta_decr.click(function(event) { - volume.rotate({cs: "local", axis: "y", dir: -1}); - }); - cv_btn_local_beta_incr.click(function(event) { - volume.rotate({cs: "local", axis: "y", dir: 1}); - }); - cv_btn_local_gamma_decr.click(function(event) { - volume.rotate({cs: "local", axis: "z", dir: -1}); - }); - cv_btn_local_gamma_incr.click(function(event) { - volume.rotate({cs: "local", axis: "z", dir: 1}); - }); - - // remove button - let cvRemove = cvItem.find(".clipping_volume_action_remove"); - cvRemove.click(() => {viewer.scene.removeClipVolume(volume)}); - - return cvItem; - }; - - // update body when clip volume changes - cv.addEventListener("clip_volume_changed", function(event) { - let cv = event.volume; - let prevCVItem = $("span#" + cv.name + " .clip_volume_body"); - let cvItem = createCVitem(cv); - prevCVItem.after(cvItem); - prevCVItem.remove(); - }); - - // wrapper which doesnt change - let icon = "/icons/clip_volume.svg"; - let cvWrapper = $(` - - -
    - - ${cv.name} -
    - - - -
    - `); - - cvWrapper.find(".measurement_content").append(createCVitem(cv)); - - cvWrapper.find(".scene_header").click(function(event) { - if($(this).next().is(":visible")) { - cv.dispatchEvent({"type": "ui_deselect"}); - } else { - cv.dispatchEvent({"type": "ui_select"}); - } - $(this).next().slideToggle(200); - }); - - cvList.append(cvWrapper); - }); - - viewer.scene.addEventListener("clip_volume_removed", function(event) { - $("#" + event.volume.name).remove(); - - if(viewer.scene.clipVolumes.length == 0 && viewer.scene.polygonClipVolumes.length == 0) { - $("#clipping_volumes_container").hide(); - } - }); - } function initAnnotationDetails () { // annotation_details diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index 7a5fdcbe..1b0d9c7d 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -795,6 +795,10 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ $('#potree_description')[0].innerHTML = value; }; + setClipMode(clipMode){ + this.clippingTool.setClipMode(clipMode); + } + setNavigationMode (value) { this.scene.view.navigationMode = value; };