From 305bb70b24952966fb3c4acf1528cd519194f30d Mon Sep 17 00:00:00 2001 From: Michel D'Astous Date: Wed, 3 Apr 2024 14:45:14 -0400 Subject: [PATCH] Added tool assistance instructions to `MapFeatureInfo` tool, also updated icon (#6559) (cherry picked from commit 1b4a21f59dcdd21925c30ef755f318c6e69520f7) --- common/api/map-layers-formats.api.md | 6 ++- ...pfeatureInfo_toolFix_2024-03-27-11-29.json | 10 +++++ .../src/Icons/MapInfoIcon.ts | 9 +++++ .../src/Tools/MapFeatureInfoTool.ts | 38 ++++++++++++++++++- .../public/locales/en/mapLayersFormats.json | 9 ++++- 5 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 common/changes/@itwin/map-layers-formats/geo-mapfeatureInfo_toolFix_2024-03-27-11-29.json create mode 100644 extensions/map-layers-formats/src/Icons/MapInfoIcon.ts diff --git a/common/api/map-layers-formats.api.md b/common/api/map-layers-formats.api.md index 78cb2b61730b..aba54749b721 100644 --- a/common/api/map-layers-formats.api.md +++ b/common/api/map-layers-formats.api.md @@ -65,7 +65,7 @@ export class MapFeatureInfoTool extends PrimitiveTool { // (undocumented) getToolTip(hit: HitDetail): Promise; // (undocumented) - static iconSpec: string; + static iconSpec: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiI+PHBhdGggZD0iTTUuODYyIDUuMTYyYTEuNDg4IDEuNDg4IDAgMSAxLTIuOTc1IDAgMS40ODggMS40ODggMCAwIDEgMi45NzUgMFpNMTIgN2MuNzEyIDAgMS4zODcuMTU0IDIgLjQyMlYwaC0xLjA1bC0yLjI3OCA3LjIwMUE0Ljk1IDQuOTUgMCAwIDEgMTIgN1ptLTQuNzkyIDYuMzQ5TDcgMTRIMFYwaDExLjQ2M0w4Ljg3MiA4LjEyOUM3LjczOSA5LjA0NSA3IDEwLjQyOSA3IDEyYzAgLjQ3LjA4Ni45MTcuMjA4IDEuMzQ5Wm0tLjAzMy04LjE4N1Y1LjA5YTIuNzY0IDIuNzY0IDAgMCAwLTIuODcyLTIuNzI4IDIuNzY0IDIuNzY0IDAgMCAwLTIuNzI4IDIuOEE2LjkwMyA2LjkwMyAwIDAgMCAyLjggOC4zMTJjLjQ3NC44NzcgMSAxLjcyNCAxLjU3NSAyLjUzOCAwIDAgLjk2My0xLjQ4OCAxLjU3NS0yLjUzN2E2LjkwMyA2LjkwMyAwIDAgMCAxLjIyNS0zLjE1Wk0xNiAxMmE0IDQgMCAxIDEtOCAwIDQgNCAwIDAgMSA4IDBabS00LjA1LTEuODVhLjQ2OS40NjkgMCAwIDAgLjUuNS42NTUuNjU1IDAgMCAwIC42NS0uNmwtLjAwMi0uMDMyQS40Ni40NiAwIDAgMCAxMi42IDkuNmEuNjE1LjYxNSAwIDAgMC0uNjUuNTVabTEuMTUgMy40NS0uMTUtLjJhMSAxIDAgMCAxLS41NS4zYy0uMSAwLS4xLS4wNS0uMDUtLjNsLjM1LTEuM2MuMTUtLjUuMS0uOC0uMTUtLjhhMy4yNSAzLjI1IDAgMCAwLTEuNjUuOGwuMS4yNWMuMTk4LS4xMjUuNDItLjIxLjY1LS4yNS4wNSAwIC4wNS4wNSAwIC4yNWwtLjMgMS4yYy0uMi43IDAgLjg1LjI1Ljg1YTIuODg1IDIuODg1IDAgMCAwIDEuNS0uOFoiLz48L3N2Zz4="; // (undocumented) onCleanup(): Promise; // (undocumented) @@ -82,6 +82,10 @@ export class MapFeatureInfoTool extends PrimitiveTool { onRestartTool(): Promise; // (undocumented) requireWriteableTarget(): boolean; + // @internal (undocumented) + protected setupAndPromptForNextAction(): void; + // @internal (undocumented) + protected showPrompt(): void; // (undocumented) static toolId: string; } diff --git a/common/changes/@itwin/map-layers-formats/geo-mapfeatureInfo_toolFix_2024-03-27-11-29.json b/common/changes/@itwin/map-layers-formats/geo-mapfeatureInfo_toolFix_2024-03-27-11-29.json new file mode 100644 index 000000000000..83d9774604db --- /dev/null +++ b/common/changes/@itwin/map-layers-formats/geo-mapfeatureInfo_toolFix_2024-03-27-11-29.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@itwin/map-layers-formats", + "comment": "Added tool assistance instructions to `MapFeatureInfo` tool, also updated icons ", + "type": "none" + } + ], + "packageName": "@itwin/map-layers-formats" +} \ No newline at end of file diff --git a/extensions/map-layers-formats/src/Icons/MapInfoIcon.ts b/extensions/map-layers-formats/src/Icons/MapInfoIcon.ts new file mode 100644 index 000000000000..c8355ec715fa --- /dev/null +++ b/extensions/map-layers-formats/src/Icons/MapInfoIcon.ts @@ -0,0 +1,9 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Bentley Systems, Incorporated. All rights reserved. +* See LICENSE.md in the project root for license terms and full copyright notice. +*--------------------------------------------------------------------------------------------*/ + +/** @internal */ +export const mapInfoIcon = { + dataUri: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiI+PHBhdGggZD0iTTUuODYyIDUuMTYyYTEuNDg4IDEuNDg4IDAgMSAxLTIuOTc1IDAgMS40ODggMS40ODggMCAwIDEgMi45NzUgMFpNMTIgN2MuNzEyIDAgMS4zODcuMTU0IDIgLjQyMlYwaC0xLjA1bC0yLjI3OCA3LjIwMUE0Ljk1IDQuOTUgMCAwIDEgMTIgN1ptLTQuNzkyIDYuMzQ5TDcgMTRIMFYwaDExLjQ2M0w4Ljg3MiA4LjEyOUM3LjczOSA5LjA0NSA3IDEwLjQyOSA3IDEyYzAgLjQ3LjA4Ni45MTcuMjA4IDEuMzQ5Wm0tLjAzMy04LjE4N1Y1LjA5YTIuNzY0IDIuNzY0IDAgMCAwLTIuODcyLTIuNzI4IDIuNzY0IDIuNzY0IDAgMCAwLTIuNzI4IDIuOEE2LjkwMyA2LjkwMyAwIDAgMCAyLjggOC4zMTJjLjQ3NC44NzcgMSAxLjcyNCAxLjU3NSAyLjUzOCAwIDAgLjk2My0xLjQ4OCAxLjU3NS0yLjUzN2E2LjkwMyA2LjkwMyAwIDAgMCAxLjIyNS0zLjE1Wk0xNiAxMmE0IDQgMCAxIDEtOCAwIDQgNCAwIDAgMSA4IDBabS00LjA1LTEuODVhLjQ2OS40NjkgMCAwIDAgLjUuNS42NTUuNjU1IDAgMCAwIC42NS0uNmwtLjAwMi0uMDMyQS40Ni40NiAwIDAgMCAxMi42IDkuNmEuNjE1LjYxNSAwIDAgMC0uNjUuNTVabTEuMTUgMy40NS0uMTUtLjJhMSAxIDAgMCAxLS41NS4zYy0uMSAwLS4xLS4wNS0uMDUtLjNsLjM1LTEuM2MuMTUtLjUuMS0uOC0uMTUtLjhhMy4yNSAzLjI1IDAgMCAwLTEuNjUuOGwuMS4yNWMuMTk4LS4xMjUuNDItLjIxLjY1LS4yNS4wNSAwIC4wNS4wNSAwIC4yNWwtLjMgMS4yYy0uMi43IDAgLjg1LjI1Ljg1YTIuODg1IDIuODg1IDAgMCAwIDEuNS0uOFoiLz48L3N2Zz4=", +} as const; diff --git a/extensions/map-layers-formats/src/Tools/MapFeatureInfoTool.ts b/extensions/map-layers-formats/src/Tools/MapFeatureInfoTool.ts index 95e45c9265b5..632d19bbbf37 100644 --- a/extensions/map-layers-formats/src/Tools/MapFeatureInfoTool.ts +++ b/extensions/map-layers-formats/src/Tools/MapFeatureInfoTool.ts @@ -18,11 +18,17 @@ import { MapLayerScaleRangeVisibility, MapTileTreeScaleRangeVisibility, PrimitiveTool, + ToolAssistance, + ToolAssistanceImage, + ToolAssistanceInputMethod, + ToolAssistanceInstruction, + ToolAssistanceSection, Viewport, } from "@itwin/core-frontend"; import { BeEvent } from "@itwin/core-bentley"; import { ImageMapLayerSettings, MapImageryProps, MapImagerySettings, MapLayerProps } from "@itwin/core-common"; import { MapFeatureInfoDecorator } from "./MapFeatureInfoDecorator"; +import { mapInfoIcon } from "../Icons/MapInfoIcon"; /** * Data provided every time [[MapFeatureInfoTool]] retrieves feature information. @@ -112,7 +118,7 @@ export class MapFeatureInfoTool extends PrimitiveTool { public readonly onInfoCleared = new BeEvent(); public static override toolId = "MapFeatureInfoTool"; - public static override iconSpec = "icon-map"; + public static override iconSpec = mapInfoIcon.dataUri; private _decorator: MapFeatureInfoDecorator = new MapFeatureInfoDecorator(); private _layerSettingsCache = new Map(); @@ -125,6 +131,11 @@ export class MapFeatureInfoTool extends PrimitiveTool { return false; } + /** @internal */ + protected setupAndPromptForNextAction(): void { + this.showPrompt(); + } + private updateDecorator(vp: Viewport) { if (this._state.existsInDisplayStyle) { if (this._state.isInRange) { @@ -140,6 +151,9 @@ export class MapFeatureInfoTool extends PrimitiveTool { public override async onPostInstall() { await super.onPostInstall(); + + this.setupAndPromptForNextAction(); + this.initLocateElements(); IModelApp.locateManager.options.allowDecorations = true; @@ -192,6 +206,7 @@ export class MapFeatureInfoTool extends PrimitiveTool { } IModelApp.viewManager.addDecorator(this._decorator); + } public override async onCleanup() { @@ -285,4 +300,25 @@ export class MapFeatureInfoTool extends PrimitiveTool { if (!(await tool.run())) return this.exitTool(); } + + /** @internal */ + protected showPrompt(): void { + + const promptEnterPoint = IModelApp.localization.getLocalizedString("mapLayersFormats:tools.MapFeatureInfoTool.Prompts.EnterPoint"); + const promptClickIdentify= IModelApp.localization.getLocalizedString("mapLayersFormats:tools.MapFeatureInfoTool.Prompts.clickToIdentify"); + const promptClickClear = IModelApp.localization.getLocalizedString("mapLayersFormats:tools.MapFeatureInfoTool.Prompts.clickToClear"); + + // Mouse Instructions + const mouseInstructions: ToolAssistanceInstruction[] = []; + mouseInstructions.push(ToolAssistance.createInstruction(ToolAssistanceImage.LeftClick, promptClickIdentify, false, ToolAssistanceInputMethod.Mouse)); + mouseInstructions.push(ToolAssistance.createInstruction(ToolAssistanceImage.RightClick, promptClickClear, false, ToolAssistanceInputMethod.Mouse)); + const sections: ToolAssistanceSection[] = []; + sections.push(ToolAssistance.createSection(mouseInstructions, ToolAssistance.inputsLabel)); + + // Main Instruction + const mainInstruction = ToolAssistance.createInstruction(this.iconSpec, promptEnterPoint); + const instructions = ToolAssistance.createInstructions(mainInstruction, sections); + + IModelApp.notifications.setToolAssistance(instructions); + } } diff --git a/extensions/map-layers-formats/src/public/locales/en/mapLayersFormats.json b/extensions/map-layers-formats/src/public/locales/en/mapLayersFormats.json index ddeaf76a350a..0ed0866108d3 100644 --- a/extensions/map-layers-formats/src/public/locales/en/mapLayersFormats.json +++ b/extensions/map-layers-formats/src/public/locales/en/mapLayersFormats.json @@ -1,7 +1,14 @@ { "tools": { "MapFeatureInfoTool": { - "keyin": "mlt map feature info" + "keyin": "mlt map feature info", + "description": "Identify map layer features", + "flyover": "Map Layer Info", + "Prompts": { + "EnterPoint": "Identify map layer features", + "clickToIdentify": "Click to identify features", + "clickToClear": "Click to clear highlighted features" + } } }, "Messages": {