From 859ed0633044e550121010417194f1c3906f664e Mon Sep 17 00:00:00 2001 From: Joe Roberts Date: Mon, 13 Nov 2023 11:41:59 -0800 Subject: [PATCH 1/3] #452 Updated Identifier tool to be a separated floating tool - Need to test different UI combinations with other separated tools - We may possibly want an option to make the tool not be separated to maintain compatibility --- .../Tools/Identifier/IdentifierTool.js | 64 ++++++++++++++++++- src/essence/Tools/Identifier/config.json | 2 + 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/essence/Tools/Identifier/IdentifierTool.js b/src/essence/Tools/Identifier/IdentifierTool.js index 69fd7c5d..fabc7f38 100644 --- a/src/essence/Tools/Identifier/IdentifierTool.js +++ b/src/essence/Tools/Identifier/IdentifierTool.js @@ -26,9 +26,32 @@ var IdentifierTool = { MMWebGISInterface: null, mousemoveTimeout: null, mousemoveTimeoutMap: null, + targetId: null, + made: false, + justification: 'left', vars: {}, - make: function () { + initialize: function () { + //Get tool variables and UI adjustments + this.justification = L_.getToolVars('identifier')['justification'] + var toolContent = d3.select('#toolSeparated_Identifier') + toolContent.style('bottom', '2px') + }, + make: function (targetId) { this.MMWebGISInterface = new interfaceWithMMWebGIS() + this.targetId = targetId + this.activeLayerNames = [] + + L_.subscribeOnLayerToggle('IdentifierTool', () => { + this.MMWebGISInterface = new interfaceWithMMWebGIS() + }) + + this.made = true + + L_.subscribeOnLayerToggle('IdentifierTool', () => { + this.MMWebGISInterface = new interfaceWithMMWebGIS() + }) + + this.made = true //Get tool variables this.varsRaw = L_.getToolVars('identifier', true) @@ -69,6 +92,9 @@ var IdentifierTool = { }, destroy: function () { this.MMWebGISInterface.separateFromMMWebGIS() + this.targetId = null + L_.unsubscribeOnLayerToggle('IdentifierTool') + this.made = false }, fillURLParameters: function (url, layerUUID) { if (IdentifierTool.vars.data?.[layerUUID]?.data?.[0]) { @@ -441,7 +467,6 @@ function interfaceWithMMWebGIS() { //tools.html( markup ); //Add event functions and whatnot - var previousCursor = d3.select('#map').style('cursor') d3.select('#map').style('cursor', 'crosshair') Map_.map.on('mousemove', IdentifierTool.idPixelMap) @@ -456,10 +481,23 @@ function interfaceWithMMWebGIS() { //Share everything. Don't take things that aren't yours. // Put things back where you found them. + + var newActive = $( + '#toolcontroller_sepdiv #' + + 'Identifier' + + 'Tool' + ) + newActive.addClass('active').css({ + color: ToolController_.activeColor, + }) + newActive.parent().css({ + background: ToolController_.activeBG, + }) + function separateFromMMWebGIS() { CursorInfo.hide() - d3.select('#map').style('cursor', previousCursor) + d3.select('#map').style('cursor', 'grab') Map_.map.off('mousemove', IdentifierTool.idPixelMap) //Globe_.shouldRaycastSprites = true @@ -469,6 +507,26 @@ function interfaceWithMMWebGIS() { .getContainer() .removeEventListener('mousemove', IdentifierTool.idPixelGlobe) } + + let tools = d3.select( + IdentifierTool.targetId ? `#${IdentifierTool.targetId}` : '#toolPanel' + ) + tools.style('background', 'var(--color-k)') + //Clear it + tools.selectAll('*').remove() + + var prevActive = $( + '#toolcontroller_sepdiv #' + + 'Identifier' + + 'Tool' + ) + prevActive.removeClass('active').css({ + color: ToolController_.defaultColor, + background: 'none', + }) + prevActive.parent().css({ + background: 'none', + }) } } diff --git a/src/essence/Tools/Identifier/config.json b/src/essence/Tools/Identifier/config.json index b9f43b75..65b232be 100644 --- a/src/essence/Tools/Identifier/config.json +++ b/src/essence/Tools/Identifier/config.json @@ -16,6 +16,8 @@ }, "hasVars": true, "name": "Identifier", + "toolbarPriority": 1, + "separatedTool": true, "paths": { "IdentifierTool": "essence/Tools/Identifier/IdentifierTool" } From e6bcfe65f05a3b18434de5d9255d18234b2e5061 Mon Sep 17 00:00:00 2001 From: Joe Roberts Date: Mon, 22 Apr 2024 19:18:01 -0700 Subject: [PATCH 2/3] Fixed Identifier tool bug when using old config with non-separated tool Bug was causing other tools to not open. This makes it backwards compatible. --- .../Tools/Identifier/IdentifierTool.js | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/essence/Tools/Identifier/IdentifierTool.js b/src/essence/Tools/Identifier/IdentifierTool.js index fabc7f38..bc4f3025 100644 --- a/src/essence/Tools/Identifier/IdentifierTool.js +++ b/src/essence/Tools/Identifier/IdentifierTool.js @@ -467,6 +467,7 @@ function interfaceWithMMWebGIS() { //tools.html( markup ); //Add event functions and whatnot + var previousCursor = d3.select('#map').style('cursor') d3.select('#map').style('cursor', 'crosshair') Map_.map.on('mousemove', IdentifierTool.idPixelMap) @@ -496,9 +497,6 @@ function interfaceWithMMWebGIS() { function separateFromMMWebGIS() { CursorInfo.hide() - - d3.select('#map').style('cursor', 'grab') - Map_.map.off('mousemove', IdentifierTool.idPixelMap) //Globe_.shouldRaycastSprites = true if (L_.hasGlobe) { @@ -508,25 +506,29 @@ function interfaceWithMMWebGIS() { .removeEventListener('mousemove', IdentifierTool.idPixelGlobe) } - let tools = d3.select( - IdentifierTool.targetId ? `#${IdentifierTool.targetId}` : '#toolPanel' - ) - tools.style('background', 'var(--color-k)') - //Clear it - tools.selectAll('*').remove() - - var prevActive = $( - '#toolcontroller_sepdiv #' + - 'Identifier' + - 'Tool' - ) - prevActive.removeClass('active').css({ - color: ToolController_.defaultColor, - background: 'none', - }) - prevActive.parent().css({ - background: 'none', - }) + if (IdentifierTool.targetId === 'toolContentSeparated_Identifier') { + d3.select('#map').style('cursor', 'grab') + let tools = d3.select( + IdentifierTool.targetId ? `#${IdentifierTool.targetId}` : '#toolPanel' + ) + tools.style('background', 'var(--color-k)') + //Clear it + tools.selectAll('*').remove() + var prevActive = $( + '#toolcontroller_sepdiv #' + + 'Identifier' + + 'Tool' + ) + prevActive.removeClass('active').css({ + color: ToolController_.defaultColor, + background: 'none', + }) + prevActive.parent().css({ + background: 'none', + }) + } else { + d3.select('#map').style('cursor', previousCursor) + } } } From 96622d79dfd2bd8d8cd74101f6035d380fd3ee29 Mon Sep 17 00:00:00 2001 From: Joe Roberts Date: Thu, 25 Apr 2024 12:16:54 -0700 Subject: [PATCH 3/3] Allow Identifier and Legend tools to be on different sides if specified --- src/essence/Tools/Identifier/IdentifierTool.js | 16 +++++++++++++++- src/essence/Tools/Legend/LegendTool.js | 8 +++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/essence/Tools/Identifier/IdentifierTool.js b/src/essence/Tools/Identifier/IdentifierTool.js index bc4f3025..d1e3a732 100644 --- a/src/essence/Tools/Identifier/IdentifierTool.js +++ b/src/essence/Tools/Identifier/IdentifierTool.js @@ -34,7 +34,21 @@ var IdentifierTool = { //Get tool variables and UI adjustments this.justification = L_.getToolVars('identifier')['justification'] var toolContent = d3.select('#toolSeparated_Identifier') - toolContent.style('bottom', '2px') + toolContent.style('bottom', '2px') + if (this.justification == 'right') { + var toolController = d3.select('#toolcontroller_sepdiv') + toolController.style('top', '110px') + toolController.style('left', null) + toolController.style('right', '5px') + toolContent.style('left', null) + toolContent.style('right', '0px') + } else if (this.justification != L_.getToolVars('legend')['justification']) { + var toolController = d3.select('#toolcontroller_sepdiv').clone(false).attr('id', 'toolcontroller_sepdiv_left') + $('#toolSeparated_Identifier').appendTo('#toolcontroller_sepdiv_left') + toolController.style('top', '40px') + toolController.style('left', '5px') + toolController.style('right', null) + } }, make: function (targetId) { this.MMWebGISInterface = new interfaceWithMMWebGIS() diff --git a/src/essence/Tools/Legend/LegendTool.js b/src/essence/Tools/Legend/LegendTool.js index 16fd0afa..9f8a0951 100644 --- a/src/essence/Tools/Legend/LegendTool.js +++ b/src/essence/Tools/Legend/LegendTool.js @@ -27,7 +27,13 @@ var LegendTool = { toolController.style('right', '5px') toolContent.style('left', null) toolContent.style('right', '0px') - } + } else if (this.justification != L_.getToolVars('identifier')['justification']) { + var toolController = d3.select('#toolcontroller_sepdiv').clone(false).attr('id', 'toolcontroller_sepdiv_left') + $('#toolSeparated_Legend').appendTo('#toolcontroller_sepdiv_left') + toolController.style('top', '40px') + toolController.style('left', '5px') + toolController.style('right', null) + } }, make: function (targetId) { this.targetId = targetId