@itwin/measure-tools-react
Version:
Frontend framework and tools for measurements
57 lines • 2.53 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { MeasurementManager } from "../api/MeasurementManager.js";
import { MeasurementUIEvents } from "../api/MeasurementUIEvents.js";
import { PrimitiveToolBase } from "../api/MeasurementTool.js";
import { MeasureToolsFeatures } from "../api/FeatureTracking.js";
import { MeasureTools } from "../MeasureTools.js";
export class ClearMeasurementsTool extends PrimitiveToolBase {
static get flyover() {
return MeasureTools.localization.getLocalizedString("MeasureTools:tools.ClearMeasurements.flyover");
}
static get description() {
return MeasureTools.localization.getLocalizedString("MeasureTools:tools.ClearMeasurements.description");
}
static get keyin() {
return MeasureTools.localization.getLocalizedString("MeasureTools:tools.ClearMeasurements.keyin");
}
get feature() {
return MeasureToolsFeatures.Tools_ClearMeasurements;
}
constructor() {
super();
}
requireWriteableTarget() {
return false;
}
isCompatibleViewport(_vp, _isSelectedViewChange) {
return true;
}
async onPostInstall() {
await super.onPostInstall();
// NOTE: If we were laying out measurements in a tool, by virtue of how tools run, those measurements will have persisted by the time
// we install this clear tool
// Default behavior is to clear non-locked measurements. The user can override this with setting a handler
const overrideClearHandler = MeasurementUIEvents.shouldClearMeasurementHandler;
if (overrideClearHandler) {
MeasurementManager.instance.dropMeasurementsForPredicate((measurement) => {
return overrideClearHandler(measurement);
});
}
else {
MeasurementManager.instance.clear(false);
}
await this.exitTool();
}
async onRestartTool() {
const tool = new ClearMeasurementsTool();
if (await tool.run())
return;
return this.exitTool();
}
}
ClearMeasurementsTool.toolId = "MeasureTools.ClearMeasurements";
ClearMeasurementsTool.iconSpec = "icon-measure-clear";
//# sourceMappingURL=ClearMeasurementsTool.js.map