UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 5.46 kB
import{_ as e}from"../../../../chunks/tslib.es6.js";import{clock as t}from"../../../../core/clock.js";import{destroyHandle as i,makeHandle as o}from"../../../../core/handleUtils.js";import{isSome as s,isNone as n,removeMaybe as r}from"../../../../core/maybe.js";import{watch as a,syncAndInitial as l,when as c}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{sv3d as u}from"../../../../geometry/support/vectorStacks.js";import{DidPointerMoveRecentlyFlag as h}from"./lengthDimensionManipulatorUtils.js";import{LengthDimensionSubTool as d}from"./LengthDimensionSubTool.js";import{settings as v}from"./settings.js";import{newIntersector as _}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as T}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{AnalysisToolBase as y}from"../../../interactive/AnalysisToolBase.js";import{SKETCH_KEYS as g}from"../../../interactive/keybindings.js";import{createScreenPointArrayFromEvent as S}from"../../../support/screenUtils.js";var b;!function(e){e.Ready="ready",e.Creating="creating",e.Created="created"}(b||(b={}));let M=class extends y{constructor(e){super(e),this.automaticManipulatorSelection=!1,this.removeIncompleteOnCancel=!1,this._pointerMoveTimerMs=v.pointerMoveTimeoutMs,this._prevPointerMoveTimeout=null}initialize(){this._intersector=_(this.view.state.viewingMode),this._intersector.options.store=T.MIN,this._lengthDimensionSubTool=new d({analysis:this.analysis,analysisViewData:this.analysisViewData,manipulators:this.manipulators,parentTool:this,view:this.view}),this.addHandles([i(this._lengthDimensionSubTool),o((()=>this._clearPointerMoveTimeout())),a((()=>this.state),(e=>{e===b.Created&&this.finishToolCreation()}),l),c((()=>this.firstGrabbedManipulator),(e=>{this.selectedDimension=e.metadata}),l),a((()=>this.selectedDimension),(()=>this._resetPointerMoveTimeout()),l)])}get state(){return this.analysis.dimensions.some((e=>"length"===e.type))?s(this._activeSubTool)?b.Creating:b.Created:b.Ready}get updating(){return this._lengthDimensionSubTool.updating}get cursor(){return this.active?"crosshair":null}get selectedDimension(){return this.analysisViewData.selectedDimension}set selectedDimension(e){this.analysisViewData.selectedDimension=e}onInputEvent(e){switch(e.type){case"immediate-click":this._clickHandler(e);break;case"immediate-double-click":this._doubleClickHandler(e);break;case"pointer-move":this._pointerMoveHandler(e);break;case"key-down":if(g.cancel===e.key){if(s(this._activeSubTool)&&this._activeSubTool.removeStaged())return void e.stopPropagation();this.active||(this.selectedDimension=null)}else g.delete.includes(e.key)&&this._deleteKeyHandler()}}onActivate(){this._activeSubTool=this._lengthDimensionSubTool}onDeactivate(){s(this._activeSubTool)&&(this._activeSubTool.onDeactivate(),this._activeSubTool=null)}onShow(){this._resetPointerMoveTimeout()}onManipulatorSelectionChanged(){this._lengthDimensionSubTool.onManipulatorSelectionChanged()}onHide(){this.selectedDimension=null}_clickHandler(e){if(this.hasFocusedManipulators)return void e.stopPropagation();if(n(this._activeSubTool))return;const t=this._intersectScreen(e);n(t)||(this.selectedDimension=this._activeSubTool.onClick({mapPoint:t,pointerType:e.pointerType}),e.stopPropagation())}_doubleClickHandler(e){this.active&&(this.view.activeTool=null,e.stopPropagation())}_pointerMoveHandler(e){if(this._resetPointerMoveTimeout(),n(this._activeSubTool))return;if(this.hasFocusedManipulators)return;const t=this._intersectScreen(e);n(t)||this._activeSubTool.onPointerMove({mapPoint:t,pointerType:e.pointerType})}_deleteKeyHandler(){s(this._activeSubTool)&&this._activeSubTool.removeStaged(),this._removeSelected()}_intersectScreen(e){const t=S(e);this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(t,this._intersector);const i=this._intersector.results.min,o=u.get();return i.getIntersectionPoint(o)?this.view.renderCoordsHelper.fromRenderCoords(o,this.view.spatialReference):null}_removeSelected(){s(this.selectedDimension)&&(this.analysis.dimensions.remove(this.selectedDimension),this.selectedDimension=null)}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=r(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.manipulators.forEach((e=>{e.manipulator.state|=h})),this._prevPointerMoveTimeout=t.setTimeout((()=>{this.manipulators.forEach((e=>{e.manipulator.state&=~h}))}),this._pointerMoveTimerMs)}get testInfo(){return{...this._lengthDimensionSubTool.testInfo,setManipulatorAutoHideDelay:e=>{this._pointerMoveTimerMs=e,this._resetPointerMoveTimeout()}}}};e([p({constructOnly:!0})],M.prototype,"view",void 0),e([p({constructOnly:!0})],M.prototype,"analysis",void 0),e([p({readOnly:!0})],M.prototype,"state",null),e([p({readOnly:!0})],M.prototype,"updating",null),e([p({readOnly:!0})],M.prototype,"cursor",null),e([p({constructOnly:!0})],M.prototype,"analysisViewData",void 0),e([p()],M.prototype,"selectedDimension",null),e([p()],M.prototype,"automaticManipulatorSelection",void 0),e([p()],M.prototype,"_activeSubTool",void 0),e([p()],M.prototype,"_lengthDimensionSubTool",void 0),M=e([m("esri.views.3d.analysis.Dimension.DimensionTool")],M);export{M as DimensionTool};