@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 1.72 kB
JavaScript
import{unwrap as t}from"../../../../../core/maybe.js";import{Manipulation as i,ManipulatorType as r}from"./Manipulation.js";import{createManipulatorDragEventPipeline as o,screenToMap as a}from"../../../../interactive/dragEventPipeline.js";import{GraphicManipulator as e}from"../../../../interactive/GraphicManipulator.js";import{AccumulationBehaviour as s}from"../../../../interactive/editGeometry/interfaces.js";import{getSymbolInfo as n}from"../../../../interactive/support/utils.js";class c extends i{constructor(t){super(),this._view=t.view,this._tool=t.tool,this._graphic=t.graphic,this._manipulator=this._createManipulator(),this.forEachManipulator((t=>this._tool.manipulators.add(t)))}destroy(){this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()})),this._tool=null,this._view=null,this._manipulator=null,this._graphic=null}forEachManipulator(t){t(this._manipulator,r.TRANSLATE_XY)}createDragPipeline(i,r){let e=null,c=null,p=0,l=0,m=0;const{offsetX:h,offsetY:u,size:_}=n(t(this._graphic.symbol));return o(this._manipulator,((t,o)=>{o.next((t=>{if("start"===t.action){const t=i();e=t.editGeometryOperations,c=t.constraints}return t})).next(a(this._view)).next((t=>{const{x:i,y:o,z:a}=t.mapEnd;if(c&&(i+h<c.xmin||o+u-_<c.ymin||i+h>c.xmax||o+u-_>c.ymax))return t;"start"===t.action&&(p=t.mapStart.x,l=t.mapStart.y,m=t.mapStart.z);const n=i-p,f=o-l,v=a-m;p=i,l=o,m=a;const x=[];for(const r of e.data.components)x.push(...r.vertices);const d="start"===t.action?s.NEW_STEP:s.ACCUMULATE_STEPS,y=e.moveVertices(x,n,f,v,d);return r(t,y),t}))}))}_createManipulator(){const t=this._view,i=this._graphic;return new e({view:t,graphic:i,selectable:!0,cursor:"move"})}}export{c as DragManipulation};