UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 4.71 kB
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Evented.js";import o from"../../../../../core/Handles.js";import{destroyMaybe as r,isSome as i,isNone as n}from"../../../../../core/maybe.js";import{watch as a,syncAndInitial as p,sync as s}from"../../../../../core/reactiveUtils.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{SupportedGraphicResult as c}from"../isSupportedGraphicUtils.js";import{geometryOfSupportedGraphic as d,isSupportedGraphic as m}from"./isSupportedGraphic.js";import{ReshapeOperation as y}from"./ReshapeOperation.js";import{InteractiveToolBase as u}from"../../../../interactive/InteractiveToolBase.js";import g from"../../../../interactive/sketch/SketchLabelOptions.js";import _ from"../../../../interactive/sketch/SketchTooltipOptions.js";let v=class extends(t.EventedMixin(u)){constructor(e){super(e),this._handles=new o,this._internalGeometryUpdate=!1,this.enableZShape=!0,this.enableZVertex=!0,this.enableMoveGraphic=!0,this.enableMidpoints=!0,this.enableEdgeOffset=!1,this.type="reshape-3d",this.labelOptions=new g,this.tooltipOptions=new _,this.snappingManager=null,this.automaticManipulatorSelection=!1}initialize(){const e=this._reshapeOperation=new y({tool:this});this.addHandles([e.on("reshape",(e=>{"reshape"===e.type&&this._onReshapeGeometryChanged(),this.emit("reshape",e)})),e.on("move",(e=>{"move"===e.type&&this._onReshapeGeometryChanged(),this.emit("move",e)})),e.on("vertex-add",(e=>{this._onReshapeGeometryChanged(),this.emit("vertex-add",e)})),e.on("vertex-remove",(e=>{this._onReshapeGeometryChanged(),this.emit("vertex-remove",e)})),e.on("immediate-click",(e=>this.emit("immediate-click",e))),this.view.on("pointer-down",["Shift"],(e=>e.stopPropagation())),a((()=>this.graphic),(()=>this._updateGraphic()),p)]),this.finishToolCreation()}destroy(){this._handles=r(this._handles),this._reshapeOperation=r(this._reshapeOperation)}get updating(){return this._reshapeOperation?.updating??!1}_updateGeometry(){const e=d(this.graphic);this._reshapeOperation.inputGeometry=i(e)?e.clone():null}_updateGraphic(){if(this._handles.remove("onGraphicGeometryChange"),this._updateGeometry(),m(this.graphic)!==c.SUPPORTED)return;const e=a((()=>this.graphic?.geometry),(()=>{!1===this._internalGeometryUpdate&&this._updateGeometry()}),s);this._handles.add(e,"onGraphicGeometryChange")}onManipulatorSelectionChanged(){this._reshapeOperation&&this._reshapeOperation.onManipulatorSelectionChanged()}_updateGeometryInternally(e){this._internalGeometryUpdate=!0,this.graphic.geometry=e,this._internalGeometryUpdate=!1}_onReshapeGeometryChanged(){const{outputGeometry:e}=this._reshapeOperation;!n(this.graphic)&&e&&this._updateGeometryInternally(e.clone())}get canUndo(){return this._reshapeOperation.canUndo??!1}undo(){i(this.snappingManager)&&this.snappingManager.doneSnapping();const e=this._reshapeOperation.undo(),{outputGeometry:t}=this._reshapeOperation;e&&t&&this._updateGeometryInternally(t.clone())}get canRedo(){return this._reshapeOperation.canRedo??!1}redo(){i(this.snappingManager)&&this.snappingManager.doneSnapping();const e=this._reshapeOperation.redo(),{outputGeometry:t}=this._reshapeOperation;e&&t&&this._updateGeometryInternally(t.clone())}onInputEvent(e){"key-down"!==e.type||"Delete"!==e.key&&"Backspace"!==e.key||this._reshapeOperation.removeSelectedVertices()}reset(){}get test(){return{snappingManager:this.snappingManager,reshapeOperation:this._reshapeOperation}}};e([h()],v.prototype,"_reshapeOperation",void 0),e([h({constructOnly:!0,nonNullable:!0})],v.prototype,"view",void 0),e([h({constructOnly:!0})],v.prototype,"graphic",void 0),e([h({constructOnly:!0,nonNullable:!0})],v.prototype,"enableZShape",void 0),e([h({constructOnly:!0,nonNullable:!0})],v.prototype,"enableZVertex",void 0),e([h({constructOnly:!0,nonNullable:!0})],v.prototype,"enableMoveGraphic",void 0),e([h({constructOnly:!0,nonNullable:!0})],v.prototype,"enableMidpoints",void 0),e([h({constructOnly:!0,nonNullable:!0})],v.prototype,"enableEdgeOffset",void 0),e([h()],v.prototype,"type",void 0),e([h({constructOnly:!0,type:g})],v.prototype,"labelOptions",void 0),e([h({constructOnly:!0,type:_})],v.prototype,"tooltipOptions",void 0),e([h({constructOnly:!0})],v.prototype,"snappingManager",void 0),e([h()],v.prototype,"updating",null),e([h()],v.prototype,"automaticManipulatorSelection",void 0),v=e([l("esri.views.3d.interactive.editingTools.graphicReshape3D.GraphicReshapeTool")],v);export{v as GraphicReshapeTool};