Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[measure-tools] add multi point option #1047

Merged
merged 12 commits into from
Oct 11, 2024
39 changes: 38 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@
"version": "0.2.0",
"compounds": [
{
"name": "measure-tools tests (chrome)",
"name": "test-viewer (chrome)",
"presentation": {
"hidden": false,
"group": "1_ChromeTests",
"order": 1
},
"configurations": [
"[SCRIPTS] test-viewer",
"[FRONTEND] test-viewer",
]
},
{
"name": "measure-tools tests (chrome)",
"presentation": {
"hidden": false,
"group": "1_ChromeTests",
"order": 2
},
"configurations": [
"[CERTA] measure-tools tests",
"[ATTACH] measure-tools tests",
Expand Down Expand Up @@ -57,6 +69,31 @@
"[CERTA] measure-tools tests"
]
},
{ /* Partial */
"name": "[FRONTEND] test-viewer",
"presentation": {
"hidden": true,
},
"cwd": "${workspaceFolder}/apps/test-viewer",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000/",
"sourceMaps": true,
"outputCapture": "std",
"webRoot": "${workspaceFolder}/apps/test-viewer",
"outFiles": [
"${workspaceFolder}/apps/test-viewer/lib/**/*.js",
"${workspaceFolder}/packages/itwin/*/lib/**/*.js",
],
},
{ /* Partial */
"name": "[SCRIPTS] test-viewer",
"presentation": {
"hidden": true
},
"type": "node",
"preLaunchTask": "[TASK] test-viewer start"
},
{
"name": "Tests: Tree-widget",
"cwd": "${workspaceFolder}/packages/itwin/tree-widget",
Expand Down
12 changes: 12 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "[TASK] test-viewer start",
"type": "npm",
"script": "start",
"path": "apps/test-viewer/",
"problemMatcher": []
},
]
}
2 changes: 1 addition & 1 deletion apps/test-viewer/src/components/Viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function ViewerWithOptions() {
defaultUiConfig={{
hideNavigationAid: true,
hideStatusBar: false,
hideToolSettings: true,
hideToolSettings: false,
}}
mapLayerOptions={{ BingMaps: { key: "key", value: ApiKeys.BingMapsKey } }}
tileAdmin={{ cesiumIonKey: ApiKeys.CesiumKey }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Add a tool settings to measuredistance tool allowing consecutive / multi point measurements",
"packageName": "@itwin/measure-tools-react",
"email": "3418768+a-gagnon@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"slope": "Slope:",
"run": "Run:",
"rise": "Rise:",
"useMultiPoint": "Multi-point",
"mainInstruction": "Enter point to measure from",
"mainInstruction2": "Enter point to measure to"
},
Expand Down Expand Up @@ -148,4 +149,4 @@
"label": "Measurement",
"tooltip": "Measurement Tools"
}
}
}
52 changes: 51 additions & 1 deletion packages/itwin/measure-tools/src/tools/MeasureDistanceTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ import { MeasureTools } from "../MeasureTools";
import { MeasureDistanceToolModel } from "../toolmodels/MeasureDistanceToolModel";
import { SheetMeasurementsHelper } from "../api/SheetMeasurementHelper";
import type { DrawingMetadata } from "../api/Measurement";
import { DrawingDataCache } from "../api/DrawingTypeDataCache";
import { type DialogItem, type DialogItemValue, type DialogPropertySyncItem, PropertyDescriptionHelper } from "@itwin/appui-abstract";
aruniverse marked this conversation as resolved.
Show resolved Hide resolved

export class MeasureDistanceTool extends MeasurementToolBase<
DistanceMeasurement,
MeasureDistanceToolModel
> {
public static override toolId = "MeasureTools.MeasureDistance";
public static override iconSpec = "icon-measure-distance";
private static readonly useMultiPointPropertyName = "useMultiPoint";

private _useMultiPointMeasurement: boolean = false;
private _enableSheetMeasurements: boolean;

public static override get flyover() {
Expand Down Expand Up @@ -98,6 +101,11 @@ MeasureDistanceToolModel
) {
this.toolModel.setEndPoint(viewType, ev.point, false);
await this.onReinitialize();

// Trigger another button event to use as the start point of the next measurement
if (this._useMultiPointMeasurement) {
return this.onDataButtonDown(ev);
}
}

ev.viewport.invalidateDecorations();
Expand Down Expand Up @@ -247,4 +255,46 @@ MeasureDistanceToolModel
);
IModelApp.notifications.setToolAssistance(instructions);
}

public override async onInstall(): Promise<boolean> {
if (!await super.onInstall()) {
return false;
}
const initialValue = IModelApp.toolAdmin.toolSettingsState.getInitialToolSettingValue(this.toolId, MeasureDistanceTool.useMultiPointPropertyName);
this._useMultiPointMeasurement = true === initialValue?.value;
return true;
}

public override async onCleanup(): Promise<void> {
const propertyName = MeasureDistanceTool.useMultiPointPropertyName;
const value: DialogItemValue = { value: this._useMultiPointMeasurement };
IModelApp.toolAdmin.toolSettingsState.saveToolSettingProperty(this.toolId, { propertyName, value });

return super.onCleanup();
}

public override supplyToolSettingsProperties(): DialogItem[] {
const propertyLabel = MeasureTools.localization.getLocalizedString(
"MeasureTools:tools.MeasureDistance.useMultiPoint"
);
const toolSettings: DialogItem[] = [{
value: { value: this._useMultiPointMeasurement },
property: PropertyDescriptionHelper.buildToggleDescription(MeasureDistanceTool.useMultiPointPropertyName, propertyLabel),
editorPosition: { rowPriority: 0, columnIndex: 0 },
isDisabled: false,
}];
return toolSettings;
}

public override async applyToolSettingPropertyChange(updatedValue: DialogPropertySyncItem): Promise<boolean> {
if (MeasureDistanceTool.useMultiPointPropertyName === updatedValue.propertyName) {
const value = updatedValue.value.value;
if (typeof value !== "boolean") {
return false;
}
this._useMultiPointMeasurement = value;
return true;
}
return super.applyToolSettingPropertyChange(updatedValue);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 2 additions & 20 deletions packages/itwin/tree-widget/src/e2e-tests/ModelsTree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,8 @@
import type { Locator } from "@playwright/test";
import { expect, test } from "@playwright/test";
import {
expandStagePanel,
initTreeWidgetTest,
locateInstanceFilter,
locateNode,
scrollTree,
selectOperatorInDialog,
selectPropertyInDialog,
selectTree,
selectValueInDialog,
takeScreenshot,
withDifferentDensities,
expandStagePanel, initTreeWidgetTest, locateInstanceFilter, locateNode, scrollTree, selectOperatorInDialog, selectPropertyInDialog, selectTree,
selectValueInDialog, takeScreenshot, withDifferentDensities,
} from "./utils";

test.describe("Models tree", () => {
Expand All @@ -39,9 +30,6 @@ test.describe("Models tree", () => {
const physicalModelNode = locateNode(treeWidget, "ProcessPhysicalModel");
await physicalModelNode.getByLabel("Expand").click();

// wait for node at the bottom to be visible/loaded
await locateNode(treeWidget, "Tag-Category").waitFor();

const pipeSupportNode = locateNode(treeWidget, "PipeSupport");
await pipeSupportNode.getByLabel("Expand").click();

Expand Down Expand Up @@ -115,9 +103,6 @@ test.describe("Models tree", () => {
const node = locateNode(treeWidget, "ProcessPhysicalModel");
await node.getByLabel("Expand").click();

// wait for node at the bottom to be visible/loaded
await locateNode(treeWidget, "Tag-Category").waitFor();

await treeWidget.getByRole("button", { name: "Open" }).click();
await treeWidget.getByPlaceholder("Search...").fill("Test");

Expand All @@ -130,9 +115,6 @@ test.describe("Models tree", () => {
const node = locateNode(treeWidget, "ProcessPhysicalModel");
await node.getByLabel("Expand").click();

// wait for node at the bottom to be visible/loaded
await locateNode(treeWidget, "Tag-Category").waitFor();

await treeWidget.getByRole("button", { name: "OPen" }).click();
await treeWidget.getByPlaceholder("Search...").fill("x");

Expand Down
Loading