UNPKG

@itwin/measure-tools-react

Version:
42 lines 1.89 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { FeatureTracking, MeasureToolsFeatures } from "../api/FeatureTracking.js"; import { MeasurementPreferences } from "../api/MeasurementPreferences.js"; import { PrimitiveToolBase } from "../api/MeasurementTool.js"; export class ToggleDisplayMeasurementAxesTool extends PrimitiveToolBase { static get iconSpec() { if (MeasurementPreferences.current.displayMeasurementAxes) return "icon-measure-2d-hide"; return "icon-measure-2d-show"; } // Ignore built-in feature tracking on the tool, since we want to add a toggle state to the tracking so we will call it ourselves get feature() { return undefined; } constructor() { super(); } requireWriteableTarget() { return false; } isCompatibleViewport(_vp, _isSelectedViewChange) { return true; } async onPostInstall() { await super.onPostInstall(); const isEnabled = !MeasurementPreferences.current.displayMeasurementAxes; MeasurementPreferences.current.displayMeasurementAxes = isEnabled; FeatureTracking.notifyToggledFeature(MeasureToolsFeatures.Tools_ToggleDisplayMeasurementAxes, isEnabled); await this.exitTool(); } async onRestartTool() { const tool = new ToggleDisplayMeasurementAxesTool(); if (await tool.run()) return; return this.exitTool(); } } ToggleDisplayMeasurementAxesTool.toolId = "MeasureTools.ToggleDisplayMeasurementAxes"; //# sourceMappingURL=ToggleDisplayMeasurementAxesTool.js.map