@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.09 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as t}from"tslib";import{destroyMaybe as e}from"../../core/maybe.js";import{property as o,subclass as r}from"../../core/accessorSupport/decorators.js";import{getEffectiveElevationInfo as i}from"../../support/elevationInfoUtils.js";import{DrawOperation as n}from"./DrawOperation.js";import{ElevationDrawSurface as a,SceneDrawSurface as s}from"./drawSurfaces.js";import{InteractiveToolBase as p}from"../interactive/InteractiveToolBase.js";let d=class extends p{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=i(this.hasZ,this.elevationInfo);this.drawOperation=new n({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 s(t,e):null,elevationDrawSurface:"3d"===t.type?new a(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=e(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([o({constructOnly:!0,nonNullable:!0})],d.prototype,"defaultZ",void 0),t([o()],d.prototype,"drawOperation",void 0),t([o({constructOnly:!0})],d.prototype,"elevationInfo",void 0),t([o({value:!0})],d.prototype,"enabled",null),t([o({constructOnly:!0})],d.prototype,"geometryType",void 0),t([o({constructOnly:!0})],d.prototype,"automaticLengthMeasurementUtils",void 0),t([o({constructOnly:!0})],d.prototype,"hasZ",void 0),t([o({constructOnly:!0})],d.prototype,"mode",void 0),t([o()],d.prototype,"snapToScene",void 0),t([o({readOnly:!0})],d.prototype,"type",void 0),t([o({readOnly:!0})],d.prototype,"updating",null),t([o({constructOnly:!0,nonNullable:!0})],d.prototype,"view",void 0),d=t([r("esri.views.draw.LegacyDrawTool")],d);export{d as LegacyDrawTool};