UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 2.42 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import t from"../../../../../core/Handles.js";import{c as i}from"../../../../../chunks/vec32.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Manipulation as e,ManipulatorType as a}from"./Manipulation.js";import{onGrabChangedHandle as o}from"./utils.js";import{getRotationAngle as n}from"../../../../draw/support/drawUtils.js";import{createManipulatorDragEventPipeline as s,screenToMap as l}from"../../../../interactive/dragEventPipeline.js";import{GraphicManipulator as p}from"../../../../interactive/GraphicManipulator.js";import{AccumulationBehavior as h}from"../../../../interactive/editGeometry/interfaces.js";import{AccumulationType as c}from"../../../../interactive/editGeometry/operations/UpdateVertices.js";import{apply as m}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";class u extends e{constructor(i){super(),this._handles=new t,this._originCache=r(),this._view=i.view,this._tool=i.tool,this._graphic=i.graphic,this._snapRotation=i.snapRotation,this._manipulator=this._createManipulator(),this._handles.add([this._manipulator.events.on("grab-changed",(t=>o(t,this._manipulator)))]),this.forEachManipulator((t=>this._tool.manipulators.add(t)))}destroy(){this._handles.destroy(),this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()})),this._tool=null,this._view=null,this._manipulator=null,this._snapRotation=null,this._graphic=null,this._handles=null,this._originCache=null}forEachManipulator(t){t(this._manipulator,a.ROTATE)}createDragPipeline(t,r){let e=null,a=null;return s(this._manipulator,((o,s)=>{s.next((i=>{if("start"===i.action){o.cursor="grabbing";const i=t();e=i.plane,a=i.editGeometryOperations}return i})).next(l(this._view)).next((t=>({...t,rotateAngle:n(t.mapStart,t.mapEnd,{x:e.origin[0],y:e.origin[1]},!0)}))).next(this._snapRotation.createDragEventPipelineStep(),this._snapRotation.next).next((t=>{const o=i(this._originCache,e.origin),n="start"===t.action?h.NEW_STEP:h.ACCUMULATE_STEPS,s=a.rotate(o,t.rotateAngle,n,c.REPLACE);return m(s,e),r(t,s),t})).next((t=>("end"===t.action&&(o.cursor="grab"),t)))}))}_createManipulator(){const t=this._view,i=this._graphic;return new p({view:t,graphic:i,selectable:!0,cursor:"grab"})}}export{u as RotateManipulation};