Skip to content

Commit

Permalink
Added tool assistance instructions to MapFeatureInfo tool, also upd…
Browse files Browse the repository at this point in the history
…ated icon (#6559)
  • Loading branch information
mdastous-bentley committed Apr 3, 2024
1 parent 7fbf894 commit 1b4a21f
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 3 deletions.
6 changes: 5 additions & 1 deletion common/api/map-layers-formats.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class MapFeatureInfoTool extends PrimitiveTool {
// (undocumented)
getToolTip(hit: HitDetail): Promise<HTMLElement | string>;
// (undocumented)
static iconSpec: string;
static iconSpec: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiI+PHBhdGggZD0iTTUuODYyIDUuMTYyYTEuNDg4IDEuNDg4IDAgMSAxLTIuOTc1IDAgMS40ODggMS40ODggMCAwIDEgMi45NzUgMFpNMTIgN2MuNzEyIDAgMS4zODcuMTU0IDIgLjQyMlYwaC0xLjA1bC0yLjI3OCA3LjIwMUE0Ljk1IDQuOTUgMCAwIDEgMTIgN1ptLTQuNzkyIDYuMzQ5TDcgMTRIMFYwaDExLjQ2M0w4Ljg3MiA4LjEyOUM3LjczOSA5LjA0NSA3IDEwLjQyOSA3IDEyYzAgLjQ3LjA4Ni45MTcuMjA4IDEuMzQ5Wm0tLjAzMy04LjE4N1Y1LjA5YTIuNzY0IDIuNzY0IDAgMCAwLTIuODcyLTIuNzI4IDIuNzY0IDIuNzY0IDAgMCAwLTIuNzI4IDIuOEE2LjkwMyA2LjkwMyAwIDAgMCAyLjggOC4zMTJjLjQ3NC44NzcgMSAxLjcyNCAxLjU3NSAyLjUzOCAwIDAgLjk2My0xLjQ4OCAxLjU3NS0yLjUzN2E2LjkwMyA2LjkwMyAwIDAgMCAxLjIyNS0zLjE1Wk0xNiAxMmE0IDQgMCAxIDEtOCAwIDQgNCAwIDAgMSA4IDBabS00LjA1LTEuODVhLjQ2OS40NjkgMCAwIDAgLjUuNS42NTUuNjU1IDAgMCAwIC42NS0uNmwtLjAwMi0uMDMyQS40Ni40NiAwIDAgMCAxMi42IDkuNmEuNjE1LjYxNSAwIDAgMC0uNjUuNTVabTEuMTUgMy40NS0uMTUtLjJhMSAxIDAgMCAxLS41NS4zYy0uMSAwLS4xLS4wNS0uMDUtLjNsLjM1LTEuM2MuMTUtLjUuMS0uOC0uMTUtLjhhMy4yNSAzLjI1IDAgMCAwLTEuNjUuOGwuMS4yNWMuMTk4LS4xMjUuNDItLjIxLjY1LS4yNS4wNSAwIC4wNS4wNSAwIC4yNWwtLjMgMS4yYy0uMi43IDAgLjg1LjI1Ljg1YTIuODg1IDIuODg1IDAgMCAwIDEuNS0uOFoiLz48L3N2Zz4=";
// (undocumented)
onCleanup(): Promise<void>;
// (undocumented)
Expand All @@ -82,6 +82,10 @@ export class MapFeatureInfoTool extends PrimitiveTool {
onRestartTool(): Promise<void>;
// (undocumented)
requireWriteableTarget(): boolean;
// @internal (undocumented)
protected setupAndPromptForNextAction(): void;
// @internal (undocumented)
protected showPrompt(): void;
// (undocumented)
static toolId: string;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
9 changes: 9 additions & 0 deletions extensions/map-layers-formats/src/Icons/MapInfoIcon.ts
Original file line number Diff line number Diff line change
@@ -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,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNi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Zz4=",
} as const;
38 changes: 37 additions & 1 deletion extensions/map-layers-formats/src/Tools/MapFeatureInfoTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<string, MapLayerInfoFromTileTree[]>();
Expand All @@ -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) {
Expand All @@ -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;

Expand Down Expand Up @@ -192,6 +206,7 @@ export class MapFeatureInfoTool extends PrimitiveTool {
}

IModelApp.viewManager.addDecorator(this._decorator);

}

public override async onCleanup() {
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 1b4a21f

Please sign in to comment.