UNPKG

@itwin/frontend-devtools

Version:

Debug menu and supporting UI widgets

42 lines 1.87 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); exports.ChangeUnitsTool = void 0; /** @packageDocumentation * @module Tools */ const core_frontend_1 = require("@itwin/core-frontend"); const parseToggle_1 = require("./parseToggle"); // CSpell: ignore fmtr /** Controls whether quantities are formatted using imperial or metric units. * Such formatting is used in many places; one example is the output of the MeasureTool. * @beta */ class ChangeUnitsTool extends core_frontend_1.Tool { static toolId = "ChangeUnits"; static get minArgs() { return 0; } static get maxArgs() { return 1; } // support boolean for backwards compatibility async run(useMetric) { const fmtr = core_frontend_1.IModelApp.quantityFormatter; // if no arg then toggle to metric from any non-metric unit system const useImperial = undefined !== useMetric ? !useMetric : fmtr.activeUnitSystem === "metric"; const unitSystem = useImperial ? "imperial" : "metric"; if (unitSystem !== fmtr.activeUnitSystem) { await fmtr.setActiveUnitSystem(unitSystem); await core_frontend_1.IModelApp.toolAdmin.startDefaultTool(); } return true; } async parseAndRun(...args) { const enable = (0, parseToggle_1.parseToggle)(args[0]); if (typeof enable !== "string") await this.run(enable); return true; } } exports.ChangeUnitsTool = ChangeUnitsTool; //# sourceMappingURL=ChangeUnitsTool.js.map