UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 4.5 kB
import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import t from"../../../../../Graphic.js";import{makeHandle as i}from"../../../../../core/handleUtils.js";import{unwrapOr as r,unwrap as s,isSome as a,destroyMaybe as l}from"../../../../../core/maybe.js";import{property as n}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{SnappingVisualizer2D as c}from"../../SnappingVisualizer2D.js";import{outline as p,regularVertices as h,activeVertex as m}from"./symbols.js";import{DrawGraphicTool as u,geometryTypeToDrawOperationGeometryType as y}from"../../../../draw/DrawGraphicTool.js";import{DrawOperation as v}from"../../../../draw/DrawOperation.js";import{MapDrawSurface as d}from"../../../../draw/drawSurfaces.js";import g from"../../../../../geometry/Point.js";import G from"../../../../../geometry/Multipoint.js";let E=class extends u{constructor(e){super(e),this._visualElementGraphics={outline:null,regularVertices:null,activeVertex:null},this.activeFillSymbol=null,this.type="draw-2d",this._visualElementSymbols={outline:r(e.activeLineSymbol,p),regularVertices:r(e.regularVerticesSymbol,h),activeVertex:r(e.activeVertexSymbol,m),fill:s(e.activeFillSymbol)}}normalizeCtorArgs(e){const t={...e};return delete t.activeFillSymbol,delete t.activeVertexSymbol,delete t.regularVerticesSymbol,delete t.activeLineSymbol,t}initializeGraphic(e){return a(this._visualElementSymbols.fill)&&(e.symbol=this._visualElementSymbols.fill),null}makeDrawOperation(){const{defaultZ:e,hasZ:t,view:i}=this;return new v({view:i,manipulators:this.manipulators,geometryType:y(this.geometryType),drawingMode:this.mode,hasZ:t,defaultZ:e,snapToSceneEnabled:this.snapToScene,drawSurface:new d(i,t,e),hasM:!1,snappingManager:this.snappingManager,snappingVisualizer:new c(this.internalGraphicsLayer),tooltipOptions:this.tooltipOptions})}onActiveVertexChanged(e){if("point"===this.geometryType)return null;const[r,s]=e,n=new g({x:r,y:s,spatialReference:this.view.spatialReference});return a(this._visualElementGraphics.activeVertex)?(this._visualElementGraphics.activeVertex.geometry=n,null):(this._visualElementGraphics.activeVertex=new t({geometry:n,symbol:this._visualElementSymbols.activeVertex,attributes:{displayOrder:2}}),this.internalGraphicsLayer.add(this._visualElementGraphics.activeVertex),this.internalGraphicsLayer.graphics.sort(_),i((()=>{a(this._visualElementGraphics.activeVertex)&&(this.internalGraphicsLayer.remove(this._visualElementGraphics.activeVertex),this._visualElementGraphics.activeVertex=l(this._visualElementGraphics.activeVertex))})))}onOutlineChanged(e){const r=e.clone();if("polyline"===r.type){const e=r.paths[r.paths.length-1];e.splice(0,e.length-2)}return a(this._visualElementGraphics.outline)?(this._visualElementGraphics.outline.geometry=r,null):(this._visualElementGraphics.outline=new t({geometry:r,symbol:this._visualElementSymbols.outline,attributes:{displayOrder:0}}),this.internalGraphicsLayer.add(this._visualElementGraphics.outline),this.internalGraphicsLayer.graphics.sort(_),i((()=>{a(this._visualElementGraphics.outline)&&(this.internalGraphicsLayer.remove(this._visualElementGraphics.outline),this._visualElementGraphics.outline=l(this._visualElementGraphics.outline))})))}onRegularVerticesChanged(e){const r=new G({points:e,spatialReference:this.view.spatialReference});return a(this._visualElementGraphics.regularVertices)?(this._visualElementGraphics.regularVertices.geometry=r,null):(this._visualElementGraphics.regularVertices=new t({geometry:r,symbol:this._visualElementSymbols.regularVertices,attributes:{displayOrder:1}}),this.internalGraphicsLayer.add(this._visualElementGraphics.regularVertices),this.internalGraphicsLayer.graphics.sort(_),i((()=>{a(this._visualElementGraphics.regularVertices)&&(this.internalGraphicsLayer.remove(this._visualElementGraphics.regularVertices),this._visualElementGraphics.regularVertices=l(this._visualElementGraphics.regularVertices))})))}};function _(e,t){return(e.attributes?.displayOrder??-1/0)-(t.attributes?.displayOrder??-1/0)}e([n()],E.prototype,"activeFillSymbol",void 0),e([n({readOnly:!0})],E.prototype,"type",void 0),e([n({constructOnly:!0,nonNullable:!0})],E.prototype,"view",void 0),E=e([o("esri.views.2d.interactive.draw.DrawGraphicTool2D")],E);export{E as DrawGraphicTool2D};