@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.39 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Evented.js";import{destroyMaybe as o}from"../../core/maybe.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveElevationInfo as n}from"../../support/elevationInfoUtils.js";import{DrawOperation as a}from"./DrawOperation.js";import{ElevationDrawSurface as s,SceneDrawSurface as p}from"./drawSurfaces.js";import{InteractiveToolBase as d}from"../interactive/InteractiveToolBase.js";let l=class extends(e.EventedMixin(d)){constructor(t){super(t),this.defaultZ=0,this.elevationInfo=null,this.hasZ=!0,this.mode=null,this.snapToScene=null,this.type="draw-3d"}initialize(){const t=this.view,e=n(this.hasZ,this.elevationInfo);this.drawOperation=new a({view:t,manipulators:this.manipulators,geometryType:this.geometryType,drawingMode:this.mode,hasZ:this.hasZ,defaultZ:this.defaultZ,snapToSceneEnabled:this.snapToScene,drawSurface:"3d"===t.type?new p(t,e):null,elevationDrawSurface:"3d"===t.type?new s(e,this.defaultZ,t):null,hasM:!1,elevationInfo:e,automaticLengthMeasurementUtils:this.automaticLengthMeasurementUtils}),this.addHandles([this.drawOperation.on("vertex-add",(t=>this.onVertexAdd(t))),this.drawOperation.on("vertex-remove",(t=>this.onVertexRemove(t))),this.drawOperation.on("vertex-update",(t=>this.onVertexUpdate(t))),this.drawOperation.on("cursor-update",(t=>this.onCursorUpdate(t))),this.drawOperation.on("complete",(t=>this.onComplete(t)))]),this.finishToolCreation()}destroy(){this.drawOperation=o(this.drawOperation),this._set("view",null)}set enabled(t){this.drawOperation.interactive=t,this._set("enabled",t)}get updating(){return this.drawOperation?.updating??!1}completeCreateOperation(){this.drawOperation.complete()}onDeactivate(){this.drawOperation.isCompleted||this.drawOperation.cancel()}getVertexCoords(){return this.drawOperation.geometryIncludingUncommittedVertices}onInputEvent(t){this.drawOperation.onInputEvent(t)}canRedo(){return this.drawOperation.canRedo}canUndo(){return this.drawOperation.canUndo}redo(){this.drawOperation.redo()}reset(){}undo(){this.drawOperation.undo()}onComplete(t){this.emit("complete",t)}onCursorUpdate(t){this.emit("cursor-update",t)}onVertexAdd(t){this.emit("vertex-add",t)}onVertexRemove(t){this.emit("vertex-remove",t)}onVertexUpdate(t){this.emit("vertex-update",t)}};t([r({constructOnly:!0,nonNullable:!0})],l.prototype,"defaultZ",void 0),t([r()],l.prototype,"drawOperation",void 0),t([r({constructOnly:!0})],l.prototype,"elevationInfo",void 0),t([r({value:!0})],l.prototype,"enabled",null),t([r({constructOnly:!0})],l.prototype,"geometryType",void 0),t([r({constructOnly:!0})],l.prototype,"automaticLengthMeasurementUtils",void 0),t([r({constructOnly:!0})],l.prototype,"hasZ",void 0),t([r({constructOnly:!0})],l.prototype,"mode",void 0),t([r()],l.prototype,"snapToScene",void 0),t([r({readOnly:!0})],l.prototype,"type",void 0),t([r({readOnly:!0})],l.prototype,"updating",null),t([r({constructOnly:!0,nonNullable:!0})],l.prototype,"view",void 0),l=t([i("esri.views.draw.DrawTool")],l);export{l as DrawTool};