12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.24/esri/copyright.txt for details.
- */
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import{unwrapOr as r,destroyMaybe as i}from"../../core/maybe.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{DrawOperation as s}from"./DrawOperation.js";import{SceneDrawSurface as p,ElevationDrawSurface as d}from"./drawSurfaces.js";import{InteractiveToolBase as l}from"../interactive/InteractiveToolBase.js";let h=class extends(o(t.EventedMixin(l))){constructor(e){super(e),this.defaultZ=0,this.elevationInfo=null,this.hasZ=!0,this.mode=null,this.snapToScene=null,this.type="draw-3d"}initialize(){const e=r(this.elevationInfo,{mode:this.hasZ?"absolute-height":"on-the-ground",offset:0}),t=this.view;this.drawOperation=new s({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 d(e,this.defaultZ,t):null,hasM:!1,elevationInfo:e}),this.handles.add([this.drawOperation.on("vertex-add",(e=>this.onVertexAdd(e))),this.drawOperation.on("vertex-remove",(e=>this.onVertexRemove(e))),this.drawOperation.on("vertex-update",(e=>this.onVertexUpdate(e))),this.drawOperation.on("cursor-update",(e=>this.onCursorUpdate(e))),this.drawOperation.on("complete",(e=>this.onComplete(e)))]),this.finishToolCreation()}destroy(){this.drawOperation=i(this.drawOperation),this._set("view",null)}get canRedo(){return this.drawOperation.canRedo}get canUndo(){return this.drawOperation.canUndo}set enabled(e){this.drawOperation.interactive=e,this._set("enabled",e)}get updating(){return this.drawOperation?.updating??!1}completeCreateOperation(){this.drawOperation.complete()}onDeactivate(){this.drawOperation.isCompleted||this.drawOperation.cancel()}getVertexCoords(){return this.drawOperation.vertices}onInputEvent(e){this.drawOperation.onInputEvent(e)}redo(){this.drawOperation.redo()}reset(){}undo(){this.drawOperation.undo()}onComplete(e){this.emit("complete",e)}onCursorUpdate(e){this.emit("cursor-update",e)}onVertexAdd(e){this.emit("vertex-add",e)}onVertexRemove(e){this.emit("vertex-remove",e)}onVertexUpdate(e){this.emit("vertex-update",e)}};e([n({constructOnly:!0,nonNullable:!0})],h.prototype,"defaultZ",void 0),e([n()],h.prototype,"drawOperation",void 0),e([n({constructOnly:!0})],h.prototype,"elevationInfo",void 0),e([n({value:!0})],h.prototype,"enabled",null),e([n({constructOnly:!0})],h.prototype,"geometryType",void 0),e([n({constructOnly:!0})],h.prototype,"hasZ",void 0),e([n({constructOnly:!0})],h.prototype,"mode",void 0),e([n()],h.prototype,"snapToScene",void 0),e([n({readOnly:!0})],h.prototype,"type",void 0),e([n({readOnly:!0})],h.prototype,"updating",null),e([n({constructOnly:!0,nonNullable:!0})],h.prototype,"view",void 0),h=e([a("esri.views.draw.DrawTool")],h);export{h as DrawTool};
|