@arcgis/core 5.0.0-next.124 → 5.0.0-next.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/applications/Components/applySetUtils.d.ts +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{a327f36561f093dc0fab.js → 19fcc74d34cbbaa56a41.js} +1 -1
- package/assets/esri/core/workers/chunks/1ce46085095679386580.js +1 -0
- package/assets/esri/core/workers/chunks/{a2f38e86acf45272dbc2.js → 214323c62d6d3b603a00.js} +1 -1
- package/assets/esri/core/workers/chunks/215c54520d0da638fe57.js +1 -0
- package/assets/esri/core/workers/chunks/249630af2fb01257eb75.js +1 -0
- package/assets/esri/core/workers/chunks/3214763f268622f09986.js +1 -0
- package/assets/esri/core/workers/chunks/{18c05353d6d8950d1491.js → 36215b2c0b1020743458.js} +1 -1
- package/assets/esri/core/workers/chunks/{2badadf8032e166b34ec.js → 3f3c63420644f9522ab1.js} +1 -1
- package/assets/esri/core/workers/chunks/{7f70a41258b2a0157aa5.js → 3fa59195286af30932d9.js} +1 -1
- package/assets/esri/core/workers/chunks/41108f58f0f439ebba3f.js +1 -0
- package/assets/esri/core/workers/chunks/4fe210314813ea1f7a26.js +1 -0
- package/assets/esri/core/workers/chunks/52705ccbb452a3edb064.js +1 -0
- package/assets/esri/core/workers/chunks/54c545f44b7ce21fb604.js +1 -0
- package/assets/esri/core/workers/chunks/{cfdb17522112c52f81ad.js → 558e9fed2e58cbbf9947.js} +1 -1
- package/assets/esri/core/workers/chunks/56e3c34ebdee61ff4b33.js +1 -0
- package/assets/esri/core/workers/chunks/{b50d2d3379654de1f2f3.js → 58134617fb7530836b81.js} +1 -1
- package/assets/esri/core/workers/chunks/58c4be467a922fe37f01.js +1 -0
- package/assets/esri/core/workers/chunks/{f0582d8111ec825e1f9a.js → 651b46aeabf22ff53a38.js} +1 -1
- package/assets/esri/core/workers/chunks/{90316fb569389d48920f.js → 666f201d222c50ab8428.js} +1 -1
- package/assets/esri/core/workers/chunks/6988517cb09928fed0f8.js +1 -0
- package/assets/esri/core/workers/chunks/6bf7d8de86b9eb76f920.js +1 -0
- package/assets/esri/core/workers/chunks/6c0b7890c8eec7febe28.js +1 -0
- package/assets/esri/core/workers/chunks/{25267253ba578eba38cf.js → 754e4d0b8c1ad392bd83.js} +1 -1
- package/assets/esri/core/workers/chunks/7ec83fc059325e207825.js +1 -0
- package/assets/esri/core/workers/chunks/7f385e9c88df3395e678.js +1 -0
- package/assets/esri/core/workers/chunks/{66ed527cd8ad11d008be.js → 80d51d58db09b9f96cb5.js} +1 -1
- package/assets/esri/core/workers/chunks/81c758bdc07ed9d9a132.js +1 -0
- package/assets/esri/core/workers/chunks/{8670d9d11950f3c61b79.js → 83711695e16912e9b9c5.js} +1 -1
- package/assets/esri/core/workers/chunks/a143a6f8e2f21548b244.js +1 -0
- package/assets/esri/core/workers/chunks/a4947d5d2fa6b7bd399b.js +1 -0
- package/assets/esri/core/workers/chunks/{1f30558e3ad6ac68bdb8.js → b4203e488bb928ff8032.js} +1 -1
- package/assets/esri/core/workers/chunks/b4b16914950792c46bd3.js +1 -0
- package/assets/esri/core/workers/chunks/{360b3499e2a671c309ce.js → b6969a42602517a6ef1c.js} +1 -1
- package/assets/esri/core/workers/chunks/{1aa2187597f7c4adb67f.js → bcb254cb7297fec88679.js} +1 -1
- package/assets/esri/core/workers/chunks/{2d1a772abd730b61854f.js → bd2125e0a68378533641.js} +1 -1
- package/assets/esri/core/workers/chunks/{d76dfac06299cbd4f00e.js → c0b6706f86665cec85f8.js} +1 -1
- package/assets/esri/core/workers/chunks/{f114da7ef2b891184e77.js → c3c6d337ff53e5d921e8.js} +1 -1
- package/assets/esri/core/workers/chunks/{b5f68e1fdbaca3cd9c8d.js → c941b716ea3c13cabc80.js} +1 -1
- package/assets/esri/core/workers/chunks/c99f36159b5ed6f9267e.js +1 -0
- package/assets/esri/core/workers/chunks/cf4202ad468501ef24cf.js +1 -0
- package/assets/esri/core/workers/chunks/{e2dc7e6b84e9b38ef9fe.js → d2017b0b27b9e4ada922.js} +1 -1
- package/assets/esri/core/workers/chunks/{4742a8c19b86a5f859f0.js → d47ca631e109144b6ba9.js} +1 -1
- package/assets/esri/core/workers/chunks/{38124ee5119e614645c9.js → d78b2f85ec9212a973e8.js} +1 -1
- package/assets/esri/core/workers/chunks/{7cd4280d24b24045bd7e.js → d8adab2d55b39241b232.js} +1 -1
- package/assets/esri/core/workers/chunks/e0519f24430fecead87b.js +1 -0
- package/assets/esri/core/workers/chunks/e33f5780fb45ac7ca889.js +1 -0
- package/assets/esri/core/workers/chunks/{eb9e913fe0dfcc71cf92.js → e4611ebd7dba7692a914.js} +1 -1
- package/assets/esri/core/workers/chunks/{86f2ec2692363abc97d1.js → e52793690dff1a199647.js} +1 -1
- package/assets/esri/core/workers/chunks/{c13efb74aa4602f6a1ee.js → e56a10a475ce128b5fce.js} +1 -1
- package/assets/esri/core/workers/chunks/ea633a6a3b9ea8ce965d.js +1 -0
- package/assets/esri/core/workers/chunks/eae1c098c16e2faaf90d.js +1 -0
- package/assets/esri/core/workers/chunks/{8650fbe1db55b7280c00.js → ef4237dc7b67c9039826.js} +1 -1
- package/assets/esri/core/workers/chunks/f5f513997cde0ce0f2a2.js +1 -0
- package/assets/esri/core/workers/chunks/fcc8d0b60f7c2397e550.js +1 -0
- package/assets/esri/themes/base/widgets/_BasemapGallery.scss +1 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/OperatorProximityGeodesic.js +1 -1
- package/chunks/OperatorShapePreservingLength.js +1 -1
- package/chunks/OperatorShapePreservingProject.js +1 -1
- package/chunks/SpatialReference.js +1 -1
- package/chunks/containsOperator.js +1 -1
- package/chunks/disjointOperator.js +1 -1
- package/config.js +1 -1
- package/core/has.js +1 -1
- package/editing/sharedTemplates/SharedTemplateMetadata.d.ts +0 -31
- package/{layers/graphics/editingSupport.d.ts → editing/types.d.ts} +8 -8
- package/editing/types.js +2 -0
- package/geometry/operators/gx/operatorIntersection.js +1 -1
- package/geometry/operators/json/containsOperator.js +1 -1
- package/geometry/operators/json/disjointOperator.js +1 -1
- package/geometry/support/zscale.js +1 -1
- package/graphic/KnowledgeGraphGraphicOrigin.d.ts +0 -1
- package/graphic/LinkChartGraphicOrigin.js +1 -1
- package/interfaces.d.ts +60 -60
- package/kernel.js +1 -1
- package/layers/CSVLayer.d.ts +317 -540
- package/layers/CSVLayer.js +1 -1
- package/layers/FeatureLayer.d.ts +13 -13
- package/layers/FeatureLayer.js +1 -1
- package/layers/GeoJSONLayer.d.ts +4 -4
- package/layers/OrientedImageryLayer.d.ts +6 -6
- package/layers/SceneLayer.d.ts +2 -2
- package/layers/SubtypeGroupLayer.d.ts +5 -5
- package/layers/graphics/applyEditsUtils.js +1 -1
- package/layers/graphics/data/QueryEngineCapabilities.js +1 -1
- package/layers/graphics/editingSupport.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/graphics/sources/OGCFeatureSource.js +1 -1
- package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/EditBusLayer.d.ts +1 -1
- package/layers/raster/functions/ExtractBandFunction.js +1 -1
- package/layers/support/SubtypeSublayer.d.ts +5 -5
- package/layers/support/capabilities.js +1 -1
- package/layers/support/serviceCapabilitiesUtils.js +1 -1
- package/networks/support/Circuit.d.ts +11 -2
- package/networks/support/CircuitSection.d.ts +3 -2
- package/package.json +1 -1
- package/rest/featureService/FeatureService.js +1 -1
- package/rest/featureService/types.d.ts +7 -1
- package/rest/query/operations/editsZScale.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMCursor.js +1 -1
- package/symbols/cim/CIMSymbolHelper.js +1 -1
- package/symbols/cim/placements/PlacementAlongLineSameSize.js +1 -1
- package/symbols/cim/placements/PlacementAtExtremities.js +1 -1
- package/symbols/cim/placements/PlacementAtMeasuredUnits.js +1 -1
- package/symbols/cim/placements/PlacementAtRatioPositions.js +1 -1
- package/symbols/cim/placements/PlacementOnLine.js +1 -1
- package/symbols/cim/placements/PlacementOnVertices.js +1 -1
- package/symbols/cim/types.d.ts +7 -0
- package/versionManagement/VersionManagementService.d.ts +3 -2
- package/views/2d/analysis/DistanceMeasurement/utils.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/3d/support/MemoryController.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/plugins/BezierSegmentPlugin.js +1 -1
- package/views/draw/plugins/CircularArcSegmentPlugin.js +1 -1
- package/views/draw/plugins/FreehandSegmentPlugin.js +1 -1
- package/views/draw/plugins/MultipointPlugin.js +1 -1
- package/views/draw/plugins/PointPlugin.js +1 -1
- package/views/draw/plugins/PolygonPlugin.js +1 -1
- package/views/draw/plugins/PolylinePlugin.js +1 -1
- package/views/draw/plugins/ShapePlugin.js +1 -1
- package/views/draw/support/managers/TooltipManager.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDynamic.js +1 -1
- package/views/interactive/tooltip/infos/DynamicTooltipInfo.js +1 -1
- package/webscene/Glow.d.ts +10 -2
- package/widgets/Directions.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
- package/widgets/Home/HomeViewModel.d.ts +2 -1
- package/widgets/Home/HomeViewModel.js +1 -1
- package/widgets/Home.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/constants.js +1 -1
- package/widgets/OrientedImageryViewer/types.js +1 -1
- package/widgets/OrientedImageryViewer/videoViewerUtils.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/support/PluginManager.js +1 -1
- package/assets/esri/core/workers/chunks/0184b4c0c92c76c60ab2.js +0 -1
- package/assets/esri/core/workers/chunks/0bf742d48f434c4c575f.js +0 -1
- package/assets/esri/core/workers/chunks/15ba0296403dd4152b88.js +0 -1
- package/assets/esri/core/workers/chunks/1701d9c50610f0b2dd38.js +0 -1
- package/assets/esri/core/workers/chunks/231602adad900fc024f0.js +0 -1
- package/assets/esri/core/workers/chunks/27aa21da934ecaca381a.js +0 -1
- package/assets/esri/core/workers/chunks/2907e9a7216b5a29729b.js +0 -1
- package/assets/esri/core/workers/chunks/2b0891ba57ba66b913ce.js +0 -1
- package/assets/esri/core/workers/chunks/2cd56b7ab70f908bbbd4.js +0 -1
- package/assets/esri/core/workers/chunks/2e1fe0dd357eb7a6f47f.js +0 -1
- package/assets/esri/core/workers/chunks/2e9d280f51ab43e6f102.js +0 -1
- package/assets/esri/core/workers/chunks/2eb7df99170b7bb2a914.js +0 -1
- package/assets/esri/core/workers/chunks/36b8dd092697ef544f40.js +0 -1
- package/assets/esri/core/workers/chunks/394aa478c29599b08bf5.js +0 -1
- package/assets/esri/core/workers/chunks/4ba4aa6c75e3f8950e65.js +0 -1
- package/assets/esri/core/workers/chunks/4d45c51ff32dd75299ac.js +0 -1
- package/assets/esri/core/workers/chunks/4fdc838f4c3efab6cd61.js +0 -1
- package/assets/esri/core/workers/chunks/6321680c8070dffa3b6c.js +0 -1
- package/assets/esri/core/workers/chunks/6b02919373bd4da7ff73.js +0 -1
- package/assets/esri/core/workers/chunks/a03196e6579d738251fc.js +0 -1
- package/assets/esri/core/workers/chunks/a0b715cf03895082b773.js +0 -1
- package/assets/esri/core/workers/chunks/aec827b50df6edc54808.js +0 -1
- package/assets/esri/core/workers/chunks/c80c82acec04ee0ade04.js +0 -1
- package/assets/esri/core/workers/chunks/d27a542a406ac3fe2ad9.js +0 -1
- package/assets/esri/core/workers/chunks/d9c1e1ec5c56f09fb82f.js +0 -1
- package/assets/esri/core/workers/chunks/ec2dfd89e4ce6fda4971.js +0 -1
- package/assets/esri/core/workers/chunks/ffb73b4e8f2f7ffd2db4.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import s from"../../../../core/Collection.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{watch as i,initial as o,when as a,sync as n}from"../../../../core/reactiveUtils.js";import{property as h,subclass as d}from"../../../../core/accessorSupport/decorators.js";import{translate as c,fromTranslation as p,scale as w,mul as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as f,distance as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as v,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Sphere as V}from"../../../../geometry/support/sphere.js";import{InternalRenderCategory as g}from"../../webgl.js";import M from"../../webgl/RenderNode.js";import{ViewshedShadowMap as b}from"./ViewshedShadowMap.js";import{V as y}from"../../../../chunks/Viewshed.glsl.js";import{ViewshedTechnique as S}from"../shaders/ViewshedTechnique.js";let j=class extends M{get shadowMap(){return this._shadowMap}get hasViewsheds(){return this._viewsheds.length>0}get _contentPixelRatio(){return this.view.state.contentPixelRatio}get _viewshedsInView(){return this._viewsheds.items.filter(e=>P(this.view,e))}constructor(e){super(e),this.isDecoration=!1,this._passParameters=new y,this._viewsheds=new s,this._shadowMap=null,this.consumes={required:[g.VIEWSHED,"normals"]},this.produces=g.VIEWSHED,this.requireGeometryDepth=!0}initialize(){this._shadowMap=new b(this.fboCache),this.addHandles([i(()=>this.view.resolutionScale,e=>{const s=this._shadowMap;s&&(s.settings.textureSizeQuality=e)},o),a(()=>!this.hasViewsheds,()=>this._shadowMap?.dispose()),i(()=>this._viewshedsInView.map(e=>[e.observerRenderSpace,e.heading,e.tilt,e.farDistance,e.horizontalFieldOfView,e.verticalFieldOfView]),()=>this.requestRender(1),n)])}destroy(){this._shadowMap=r(this._shadowMap)}precompile(){if(this.hasViewsheds){this.techniques.precompile(S);for(const e of this._viewshedsInView)if(this._shadowMap?.isActive(e))return void this.view.stage.renderer.precompileViewshedShadowMap()}}render(e){const s=this.bindParameters,t=this.renderingContext,r=e.find(({name:e})=>e===g.VIEWSHED);if(!this.hasViewsheds||!s.depth||this.isDecoration&&!s.decorations)return r;this._passParameters.shadowMap=this._shadowMap??this._passParameters.shadowMap,this._passParameters.normals=e.find(({name:e})=>"normals"===e)?.getTexture();const i=this.techniques.get(S);if(!i?.compiled)return this.requestRender(1),r;const o=this.view.stage.renderer.isFeatureEnabled(8);for(const a of this._viewshedsInView){if(!this._renderShadowCubeMap(s,a,o)||!this._shadowMap?.ready)continue;const e=this._setupViewshedParameters(a,s.camera);t.bindTechnique(i,s,e),t.
|
|
2
|
+
import{__decorate as e}from"tslib";import s from"../../../../core/Collection.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{watch as i,initial as o,when as a,sync as n}from"../../../../core/reactiveUtils.js";import{property as h,subclass as d}from"../../../../core/accessorSupport/decorators.js";import{translate as c,fromTranslation as p,scale as w,mul as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as f,distance as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as v,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Sphere as V}from"../../../../geometry/support/sphere.js";import{InternalRenderCategory as g}from"../../webgl.js";import M from"../../webgl/RenderNode.js";import{ViewshedShadowMap as b}from"./ViewshedShadowMap.js";import{V as y}from"../../../../chunks/Viewshed.glsl.js";import{ViewshedTechnique as S}from"../shaders/ViewshedTechnique.js";let j=class extends M{get shadowMap(){return this._shadowMap}get hasViewsheds(){return this._viewsheds.length>0}get _contentPixelRatio(){return this.view.state.contentPixelRatio}get _viewshedsInView(){return this._viewsheds.items.filter(e=>P(this.view,e))}constructor(e){super(e),this.isDecoration=!1,this._passParameters=new y,this._viewsheds=new s,this._shadowMap=null,this.consumes={required:[g.VIEWSHED,"normals"]},this.produces=g.VIEWSHED,this.requireGeometryDepth=!0}initialize(){this._shadowMap=new b(this.fboCache),this.addHandles([i(()=>this.view.resolutionScale,e=>{const s=this._shadowMap;s&&(s.settings.textureSizeQuality=e)},o),a(()=>!this.hasViewsheds,()=>this._shadowMap?.dispose()),i(()=>this._viewshedsInView.map(e=>[e.observerRenderSpace,e.heading,e.tilt,e.farDistance,e.horizontalFieldOfView,e.verticalFieldOfView]),()=>this.requestRender(1),n)])}destroy(){this._shadowMap=r(this._shadowMap)}precompile(){if(this.hasViewsheds){this.techniques.precompile(S);for(const e of this._viewshedsInView)if(this._shadowMap?.isActive(e))return void this.view.stage.renderer.precompileViewshedShadowMap()}}render(e){const s=this.bindParameters,t=this.renderingContext,r=e.find(({name:e})=>e===g.VIEWSHED);if(!this.hasViewsheds||!s.depth||this.isDecoration&&!s.decorations)return r;this._passParameters.shadowMap=this._shadowMap??this._passParameters.shadowMap,this._passParameters.normals=e.find(({name:e})=>"normals"===e)?.getTexture();const i=this.techniques.get(S);if(!i?.compiled)return this.requestRender(1),r;const o=this.view.stage.renderer.isFeatureEnabled(8);for(const a of this._viewshedsInView){if(!this._renderShadowCubeMap(s,a,o)||!this._shadowMap?.ready)continue;const e=this._setupViewshedParameters(a,s.camera);t.bindFramebuffer(r.fbo),t.bindTechnique(i,s,e),t.screen.draw()}return this.shadowMap?.dispose(),r}updateViewsheds(e){const s=this._viewsheds,{removes:t,adds:r}=e;if(t&&(Array.isArray(t)?s.removeMany(t):s.remove(t)),r)if(Array.isArray(r)){const e=r.filter(e=>!s.includes(e));s.addMany(e)}else s.includes(r)||s.add(r)}_renderShadowCubeMap(e,s,t){const r=this._shadowMap;if(!r)return!1;const i=this.view.basemapTerrain.hasStencilEnabledExtents,o=r.start(e.camera,s,t,this._contentPixelRatio,i);return o&&r.faces.forEach(e=>this.view.stage.renderer.renderViewshedShadowMap(e)),r.finish(),o}_setupViewshedParameters(e,s){const r=this._shadowMap;if(!r)return this._passParameters;const i=this._passParameters,o=e.effectiveObserverRenderSpace;i.localOrigin=o,i.observerOffset=f(E,e.observerRenderSpace,e.effectiveObserverRenderSpace),i.fovs=[t(e.horizontalFieldOfView),t(e.verticalFieldOfView)],i.headingAndTilt=[t(e.heading),t(e.tiltParallelToSurface)],i.upVector=e.tiltedUpVector;const a=R(e.targetRenderSpace,o);i.targetVector=a;const n=new Array,h=new Array;for(let t=0;t<r.numActiveFaces;t++)c(I,r.viewshedViewMatrices[t],o),n.push(...I),x(r.viewshedProjectionMatrices[t],I,D),h.push(...D);return i.viewMatrices=n,i.projectionMatrices=h,i.volumeOffset=this.selectedViewshed?.()===e.viewshed?A(e,this.view,s.eye):0,i}get test(){return{viewsheds:this._viewsheds,shadowMap:this._shadowMap,viewshedsInView:this._viewshedsInView}}};function R(e,s){const t=v();return f(t,e,s)}function x(e,s,t){const r=_(.5,.5,.5);return p(t,r),w(t,t,r),l(t,t,e),l(t,t,s),t}function P(e,s){const t=new V(s.observerRenderSpace,s.farDistanceRenderSpace);return!!e.ready&&e.frustum.intersectsSphere(t)}function A(e,s,t){if(null==e)return 0;const{observerRenderSpace:r,targetRenderSpace:i}=e,o=u(t,r)>u(t,i)?e.observer:e.target;return s.pixelSizeAt(o)}e([h()],j.prototype,"selectedViewshed",void 0),e([h()],j.prototype,"isDecoration",void 0),e([h()],j.prototype,"shadowMap",null),e([h()],j.prototype,"hasViewsheds",null),e([h()],j.prototype,"_contentPixelRatio",null),e([h()],j.prototype,"_viewshedsInView",null),e([h()],j.prototype,"consumes",void 0),e([h()],j.prototype,"produces",void 0),j=e([d("esri.views.3d.webgl-engine.lib.Viewshed")],j);const E=v(),I=m(),D=m();export{j as Viewshed,A as computeOffsetScale};
|
package/views/DOMContainer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{byId as e,reparent as i}from"../core/domUtils.js";import{on as s}from"../core/events.js";import{makeHandle as r}from"../core/handleUtils.js";import n from"../core/Logger.js";import{destroyMaybe as o,removeMaybe as a}from"../core/maybe.js";import{watch as h,initial as
|
|
2
|
+
import{__decorate as t}from"tslib";import{byId as e,reparent as i}from"../core/domUtils.js";import{on as s}from"../core/events.js";import{makeHandle as r}from"../core/handleUtils.js";import n from"../core/Logger.js";import{destroyMaybe as o,removeMaybe as a}from"../core/maybe.js";import{watch as h,initial as l,syncAndInitial as d}from"../core/reactiveUtils.js";import{addFrameTask as u}from"../core/scheduling.js";import{property as c,subclass as p}from"../core/accessorSupport/decorators.js";import{Attribution as m}from"./Attribution.js";import f from"./overlay/ViewOverlay.js";const _=[0,0];function y(t){const e=(t.ownerDocument||window.document).defaultView,i=t.getBoundingClientRect();return _[0]=i.left+(e?.pageXOffset??0),_[1]=i.top+(e?.pageYOffset??0),_}function g(t){t&&(t.textContent="",t.parentNode&&t.parentNode.removeChild(t))}const v="test"===process.env.NODE_ENV,b=v?0:16,w=v?0:750,C=v?0:512,H=2,O=_=>{const v=_;let O=class extends v{constructor(...t){super(...t),this._freqInfo={freq:b,time:w},this._overlayRenderTaskHandle=null,this.aria={},this.attributionMode=null,this.height=0,this.messagesCommon=null,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([h(()=>this.cursor,t=>{const{surface:e}=this;e&&e.setAttribute("data-cursor",t)}),h(()=>this.navigating,t=>{const{surface:e}=this;e&&e.setAttribute("data-navigating",t.toString())}),h(()=>[this.aria,this.surface],()=>this._updateAria(),{initial:!0})])}initialize(){const t=this;this.addHandles([h(()=>this.ui,(t,e)=>this._handleUIChange(t,e),l),t.on("focus",()=>this.notifyChange("focused")),t.on("blur",()=>this.notifyChange("focused"))])}destroy(){this.destroyed||(this.ui?.destroy(),this.container=null)}get attributionHeight(){return this._attribution?.height??0}get container(){return this._get("container")??null}set container(t){const s=this._get("container"),r=e(t);if(r||"string"!=typeof t||n.getLogger(this).error("#container",`element with id '${t}' not found`),s===r)return;if(this._stopMeasuring(),this.removeHandles("container"),s&&(s.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this._attribution=o(this._attribution),this.root&&(g(this.root),this._set("root",null)),this.userContent&&(i(this.userContent,s),g(this.userContent),this._set("userContent",null))),!r)return this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),void this._set("container",null);r.classList.add("esri-view");const l=document.createElement("div");l.className="esri-view-user-storage",i(r,l),r.appendChild(l),this._set("userContent",l);const c=document.createElement("div");c.className="esri-view-root",r.insertBefore(c,r.firstChild),this._set("root",c);const p=document.createElement("div");p.className="esri-view-surface",p.setAttribute("role","application"),p.tabIndex=0,c.appendChild(p),this._set("surface",p);const _=new f;c.appendChild(_.surface),this._set("overlay",_),this.addHandles(h(()=>_.needsRender,t=>{t&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=u({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=a(this._overlayRenderTaskHandle)}),"container"),this.addHandles([h(()=>({visible:this.attributionVisible,items:this.attributionItems,mode:this.attributionMode}),({visible:t,items:e,mode:i})=>{t?(this._attribution||(this._attribution=new m({attributionItems:this.attributionItems,mode:this.attributionMode})),this._attribution.appendBefore(c,this.ui?.container??null),this._attribution.attributionItems=e,this._attribution.mode=i):this._attribution=o(this._attribution)},d)],"container"),this.forceDOMReadyCycle(),this._set("container",r),this._startMeasuring()}get focused(){const t=document.activeElement===this.surface;return document.hasFocus()&&t}get size(){return[this.width,this.height]}get ui(){return this._get("ui")}set ui(t){const e=this._get("ui");e!==t&&e?.destroy(),this._set("ui",t)}blur(){this.surface?.blur()}focus(){this.surface?.focus()}pageToContainer(t,e,i){const s=this.position;return t-=s?s[0]:0,e-=s?s[1]:0,i?(i[0]=t,i[1]=e):i=[t,e],i}containerToPage(t,e,i){const s=this.position;return t+=s?s[0]:0,e+=s?s[1]:0,i?(i[0]=t,i[1]=e):i=[t,e],i}_updateAria(){const{surface:t,aria:e}=this;t&&(t.ariaLabelledByElements=e?.labelledByElements??null,t.ariaDescribedByElements=e?.describedByElements??null,t.ariaLabel=e?.label??null,t.ariaDescription=e?.description??null)}_handleUIChange(t,e){this.removeHandles("ui"),e&&e!==t&&e.destroy(),t&&(t.view=this,this.addHandles(h(()=>this.root,e=>{if(e){const i=document.createElement("div");e.insertBefore(i,this._attribution?.surface??null),t.container=i}else t.container=null},l),"ui")),this._set("ui",t)}_stopMeasuring(){this.removeHandles("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const t=this._freqInfo;t.freq=b,t.time=w;const e=u({prepare:t=>{const i=this._measure(),s=this._freqInfo;if(s.time+=t.deltaTime,i&&(s.freq=b,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const r=this._position();s.freq=r||i?b:Math.min(w,s.freq*H),!i&&s.freq>=C&&(e.pause(),this._get("resizing")&&this._set("resizing",!1))}}),i=new ResizeObserver(i=>{t.freq=b,t.time=w,e.resume()});null!=this.container&&i.observe(this.container);const n=r(()=>i.disconnect());this.addHandles([s(window,"resize",()=>{t.freq=b,t.time=w,e.resume()}),n,e],"measuring"),this._measure(),this._position()}_measure(){const t=this.container,e=t?t.clientWidth:0,i=t?t.clientHeight:0;if(0===e||0===i)return this.suspended||this._set("suspended",!0),!1;const s=this.width,r=this.height;if(e===s&&i===r)return this.suspended&&this._set("suspended",!1),!1;this._set("width",e),this._set("height",i),this.suspended&&this._set("suspended",!1);return this.emit("resize",{oldWidth:s,oldHeight:r,width:e,height:i}),!0}_position(){const t=this.container,e=this.position,i=t&&y(t);return!!i&&((!e||i[0]!==e[0]||i[1]!==e[1])&&(this._set("position",[i[0],i[1]]),!0))}forceDOMReadyCycle(){}};return t([c()],O.prototype,"_attribution",void 0),t([c()],O.prototype,"aria",void 0),t([c()],O.prototype,"attributionHeight",null),t([c()],O.prototype,"attributionMode",void 0),t([c()],O.prototype,"container",null),t([c({readOnly:!0})],O.prototype,"focused",null),t([c({readOnly:!0})],O.prototype,"height",void 0),t([c()],O.prototype,"messagesCommon",void 0),t([c({type:f})],O.prototype,"overlay",void 0),t([c({readOnly:!0})],O.prototype,"position",void 0),t([c({readOnly:!0})],O.prototype,"resizing",void 0),t([c({readOnly:!0})],O.prototype,"root",void 0),t([c({value:null,readOnly:!0})],O.prototype,"size",null),t([c({readOnly:!0})],O.prototype,"surface",void 0),t([c({readOnly:!0})],O.prototype,"suspended",void 0),t([c({nonNullable:!0})],O.prototype,"ui",null),t([c({readOnly:!0})],O.prototype,"userContent",void 0),t([c({readOnly:!0})],O.prototype,"width",void 0),t([c()],O.prototype,"widthBreakpoint",void 0),O=t([p("esri.views.DOMContainer")],O),O};export{O as DOMContainer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{clone as i}from"../../core/lang.js";import{equalsMaybe as n,destroyMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as o}from"../../core/promiseUtils.js";import a from"../../core/ReactiveSet.js";import{watch as p,syncAndInitial as l}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as d,subclass as h}from"../../core/accessorSupport/decorators.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as m,pointNear as y}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{defaultDrawingMode as v}from"./drawingModes.js";import{LegacyDrawManipulator as f}from"./LegacyDrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as P,sceneSnappingAtLocation as b}from"../interactive/dragEventPipeline.js";import{EditGeometry as T,Part as S}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as C}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as V}from"../interactive/sketch/constraints.js";import{getPointConstraint as w,getPolylineOrPolygonConstraint as O,pointToConstraintSpace as M,constraintSpaceToPoint as D}from"../interactive/sketch/constraintUtils.js";import E from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as I}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as H}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as G}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as j}from"../interactive/snapping/snappingUtils.js";const k="crosshair",Z="progress",L=Symbol(),U=Symbol();let A=class extends e{constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new a,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this._stagedPointerId=null,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=s(w),this._getPolylineOrPolygonConstraint=s(O),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new E,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=_(!!t.hasZ))}initializePointer(){const t=this.view.inputManager?.latestPointerInfo;null!=t&&this._updatePointer(t.location,t.id,t.type)}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,r="viewingMode"in e.state?e.state.viewingMode:2,s="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new C(new T(s,this.coordinateHelper),r),this._snappingOperation=new G({view:e}),this.addHandles([p(()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint}),({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&V(e));if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))},{equals:(t,e)=>t.stagedPoint===e.stagedPoint&&n(t.constraint,e.constraint)}),p(()=>this.view.viewpoint,(t,e)=>{t&&e&&u(t,e)&&this._onKeyboardBasedChange()})]),this._activePart=new S(i,r),this._editGeometryOperations.data.parts.push(this._activePart);const a=this.segmentLabels;null!=a&&(a.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions,automaticLengthMeasurementUtils:this.automaticLengthMeasurementUtils},this.addHandles(p(()=>this.labelOptions.enabled,t=>{a.visible=t},l))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],t=>{const e=t.vertices.map(t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)})),i=e.map(t=>t.coordinates),n=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getFirstVertex()?.pos)??null;m(n,this.firstVertex)||(this.firstVertex=n);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getLastVertex()?.pos)??null;m(r,this.lastVertex)||(this.lastVertex=r);const s=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.segments.at(-1)?.leftVertex?.pos)??null;switch(m(s,this.secondToLastVertex)||(this.secondToLastVertex=s),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}}));const c=this._manipulator=new f({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(c),c.grabbable="point"!==t&&"multipoint"!==t,this.addHandles([c.events.on("immediate-click",t=>this._onImmediateClick(t)),c.events.on("immediate-double-click",t=>this._onImmediateDoubleClick(t)),p(()=>this.drawingMode,()=>{this.removeHandles(L),this.addHandles(this._createManipulatorDragPipeline(c),L)},l),p(()=>({effectiveCursor:this.effectiveCursor}),({effectiveCursor:t})=>{c.cursor=t},l)]),j(this,()=>{const t=this.view.inputManager.latestPointerInfo?.type??"mouse",e=this._getSnappingContext(t);if(null!=this.snappingManager){const t=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e);this._updatingHandles.addPromise(o(t))}})}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _isDragging(){const{_stagedPointerId:t,_manipulator:e}=this;return null!=t&&this._pointerDownStates.has(t)||e.grabbing||!e.interactive}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activePart.vertices.map(t=>this.coordinateHelper.vectorToArray(t.pos))}get _constraint(){const{constraints:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":case"multipoint":return this._getPointConstraint(t);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t)}}set drawingMode(t){this._set("drawingMode",t??v)}get effectiveCursor(){return this.loading?Z:this._hideDefaultCursor?null:this.cursor||k}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activePart.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&y(t,i)||y(t,e)?null:t}get updating(){return this._updatingHandles.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t),this._activePart)}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,r="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!r,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t})),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=i(this.cursorVertex),n=i(t),r=n&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(n)??n),s=this._snapToClosingVertex(r),o=this._applyConstraints(s);y(e,o)||(this._set("cursorVertex",o),this.segmentLabels?.set("stagedVertex",null!=o?this.coordinateHelper.pointToVector(o):null),null==o||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activePart.vertices.length,coordinates:this.coordinateHelper.pointToArray(o)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||this._isDragging||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activePart;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return P(t,(t,e,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:s,cancelSnapping:o}=H({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next(t=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t)).next(o),e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||r&&!this.numCommittedVertices)&&this.commitStagedVertex()),t)).next(b(this.view,this.elevationInfo)).next(...s).next(t=>(r&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t)).next(t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t))})}_createManipulatorDragPipelineFreehand(t){return P(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t})})}_createManipulatorDragPipelineHybrid(t){return P(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),this.addHandles(this._editGeometryOperations.createUndoGroup(),U),this._processCursor(t.mapStart),this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),this.removeHandles(U),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t})})}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:r}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const s=this.elevationInfo?.mode;let o=this.defaultZ,a=t||"absolute-height"===s;if(null!=r&&(a=r),"on-the-ground"===s&&(a=!1),this._drawAtFixedElevation){o=(t?this.constraintZ:null)??e.getZ(this._activePart.vertices[0].pos),a=!1}return a?i:(n.defaultZ=o,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i&&"multipoint"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e&&"multipoint"!==this.geometryType||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=c(t.x,t.y);this._updatePointer(e,t.pointerId,t.pointerType)&&t.stopPropagation()}_updatePointer(t,e,i){return this._stagedScreenPoint=t,this._stagedPointerType=i,this._stagedPointerId=e,this._isDragging?(this._snappingOperation.abort(),!1):(this._processCursorMovementRelativeToSurface(t,i),!0)}_onKeyboardBasedChange(){"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._isDragging?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),r=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,this._processCursor(null),void i.abort();this._hideDefaultCursor=!1;const s=this.snappingManager;if(null==s)return this._processCursor(n),void i.abort();const a=this._getSnappingContext(e);this._updatingHandles.addPromise(o(i.snap({point:n,scenePoint:r},s,a)))}_applyConstraints(t){const{_constraint:e,constraints:i}=this;if(!t||!i||!e)return t;const{context:n}=i,r=M(t,n),s=r?e.closestTo(r):void 0;if(!s)return t;const o=D(s,t,n),a="2d"===this.view.type||"absolute-height"!==n.elevationInfo.mode;return null!=o&&a&&null!=this.constraintZ&&this.hasZ&&(o.z=this.constraintZ),o}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&z(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null,drawConstraints:this.constraints})}};function z(t,e,i){const n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=i}t([d()],A.prototype,"_hideDefaultCursor",void 0),t([d()],A.prototype,"_stagedPointerId",void 0),t([d()],A.prototype,"_isDragging",null),t([d()],A.prototype,"_snappingOperation",void 0),t([d()],A.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],A.prototype,"graphic",void 0),t([d()],A.prototype,"constraintsEnabled",void 0),t([d()],A.prototype,"constraints",void 0),t([d()],A.prototype,"_constraint",null),t([d()],A.prototype,"constraintZ",void 0),t([d()],A.prototype,"defaultZ",void 0),t([d()],A.prototype,"isDraped",void 0),t([d({constructOnly:!0})],A.prototype,"automaticLengthMeasurementUtils",void 0),t([d({value:v})],A.prototype,"drawingMode",null),t([d({constructOnly:!0})],A.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],A.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:E})],A.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],A.prototype,"geometryType",void 0),t([d({constructOnly:!0})],A.prototype,"hasM",void 0),t([d({constructOnly:!0})],A.prototype,"hasZ",void 0),t([d()],A.prototype,"cursor",void 0),t([d()],A.prototype,"effectiveCursor",null),t([d()],A.prototype,"loading",void 0),t([d({constructOnly:!0})],A.prototype,"manipulators",void 0),t([d({constructOnly:!0})],A.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],A.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],A.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],A.prototype,"snappingVisualizer",void 0),t([d()],A.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],A.prototype,"cursorVertex",null),t([d({readOnly:!0})],A.prototype,"visualizationCursorVertex",null),t([d()],A.prototype,"committableVertex",null),t([d()],A.prototype,"firstVertex",void 0),t([d()],A.prototype,"lastVertex",void 0),t([d()],A.prototype,"secondToLastVertex",void 0),t([d()],A.prototype,"updating",null),t([d({constructOnly:!0})],A.prototype,"view",void 0),A=t([h("esri.views.draw.DrawOperation")],A);export{A as DrawOperation,k as defaultCursor,Z as defaultLoadingCursor};
|
|
2
|
+
import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{clone as i}from"../../core/lang.js";import{equalsMaybe as n,destroyMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as o}from"../../core/promiseUtils.js";import a from"../../core/ReactiveSet.js";import{watch as p,syncAndInitial as l}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as d,subclass as h}from"../../core/accessorSupport/decorators.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as m,pointNear as y}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{defaultDrawingMode as v}from"./drawingModes.js";import{LegacyDrawManipulator as f}from"./LegacyDrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as P,sceneSnappingAtLocation as b}from"../interactive/dragEventPipeline.js";import{EditGeometry as T,Part as S}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as C}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as V}from"../interactive/sketch/constraints.js";import{getPointConstraint as w,getPolylineOrPolygonConstraint as O,pointToConstraintSpace as M,constraintSpaceToPoint as D}from"../interactive/sketch/constraintUtils.js";import E from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as I}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as H}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as G}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as j}from"../interactive/snapping/snappingUtils.js";const k="crosshair",Z="progress",L=Symbol(),U=Symbol();let A=class extends e{constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new a,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this._stagedPointerId=null,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=s(w),this._getPolylineOrPolygonConstraint=s(O),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new E,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=_(!!t.hasZ))}initializePointer(){const t=this.view.inputManager?.latestPointerInfo;null!=t&&"touch"!==t.type&&this._updatePointer(t.location,t.id,t.type)}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,r="viewingMode"in e.state?e.state.viewingMode:2,s="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new C(new T(s,this.coordinateHelper),r),this._snappingOperation=new G({view:e}),this.addHandles([p(()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint}),({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&V(e));if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))},{equals:(t,e)=>t.stagedPoint===e.stagedPoint&&n(t.constraint,e.constraint)}),p(()=>this.view.viewpoint,(t,e)=>{t&&e&&u(t,e)&&this._onKeyboardBasedChange()})]),this._activePart=new S(i,r),this._editGeometryOperations.data.parts.push(this._activePart);const a=this.segmentLabels;null!=a&&(a.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions,automaticLengthMeasurementUtils:this.automaticLengthMeasurementUtils},this.addHandles(p(()=>this.labelOptions.enabled,t=>{a.visible=t},l))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],t=>{const e=t.vertices.map(t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)})),i=e.map(t=>t.coordinates),n=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getFirstVertex()?.pos)??null;m(n,this.firstVertex)||(this.firstVertex=n);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getLastVertex()?.pos)??null;m(r,this.lastVertex)||(this.lastVertex=r);const s=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.segments.at(-1)?.leftVertex?.pos)??null;switch(m(s,this.secondToLastVertex)||(this.secondToLastVertex=s),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}}));const c=this._manipulator=new f({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(c),c.grabbable="point"!==t&&"multipoint"!==t,this.addHandles([c.events.on("immediate-click",t=>this._onImmediateClick(t)),c.events.on("immediate-double-click",t=>this._onImmediateDoubleClick(t)),p(()=>this.drawingMode,()=>{this.removeHandles(L),this.addHandles(this._createManipulatorDragPipeline(c),L)},l),p(()=>({effectiveCursor:this.effectiveCursor}),({effectiveCursor:t})=>{c.cursor=t},l)]),j(this,()=>{const t=this.view.inputManager.latestPointerInfo?.type??"mouse",e=this._getSnappingContext(t);if(null!=this.snappingManager){const t=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e);this._updatingHandles.addPromise(o(t))}})}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _isDragging(){const{_stagedPointerId:t,_manipulator:e}=this;return null!=t&&this._pointerDownStates.has(t)||e.grabbing||!e.interactive}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activePart.vertices.map(t=>this.coordinateHelper.vectorToArray(t.pos))}get _constraint(){const{constraints:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":case"multipoint":return this._getPointConstraint(t);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t)}}set drawingMode(t){this._set("drawingMode",t??v)}get effectiveCursor(){return this.loading?Z:this._hideDefaultCursor?null:this.cursor||k}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activePart.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&y(t,i)||y(t,e)?null:t}get updating(){return this._updatingHandles.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t),this._activePart)}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,r="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!r,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t})),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=i(this.cursorVertex),n=i(t),r=n&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(n)??n),s=this._snapToClosingVertex(r),o=this._applyConstraints(s);y(e,o)||(this._set("cursorVertex",o),this.segmentLabels?.set("stagedVertex",null!=o?this.coordinateHelper.pointToVector(o):null),null==o||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activePart.vertices.length,coordinates:this.coordinateHelper.pointToArray(o)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||this._isDragging||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activePart;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return P(t,(t,e,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:s,cancelSnapping:o}=H({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next(t=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t)).next(o),e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||r&&!this.numCommittedVertices)&&this.commitStagedVertex()),t)).next(b(this.view,this.elevationInfo)).next(...s).next(t=>(r&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t)).next(t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t))})}_createManipulatorDragPipelineFreehand(t){return P(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t})})}_createManipulatorDragPipelineHybrid(t){return P(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),this.addHandles(this._editGeometryOperations.createUndoGroup(),U),this._processCursor(t.mapStart),this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),this.removeHandles(U),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t})})}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:r}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const s=this.elevationInfo?.mode;let o=this.defaultZ,a=t||"absolute-height"===s;if(null!=r&&(a=r),"on-the-ground"===s&&(a=!1),this._drawAtFixedElevation){o=(t?this.constraintZ:null)??e.getZ(this._activePart.vertices[0].pos),a=!1}return a?i:(n.defaultZ=o,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i&&"multipoint"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e&&"multipoint"!==this.geometryType||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=c(t.x,t.y);this._updatePointer(e,t.pointerId,t.pointerType)&&t.stopPropagation()}_updatePointer(t,e,i){return this._stagedScreenPoint=t,this._stagedPointerType=i,this._stagedPointerId=e,this._isDragging?(this._snappingOperation.abort(),!1):(this._processCursorMovementRelativeToSurface(t,i),!0)}_onKeyboardBasedChange(){"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._isDragging?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),r=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,this._processCursor(null),void i.abort();this._hideDefaultCursor=!1;const s=this.snappingManager;if(null==s)return this._processCursor(n),void i.abort();const a=this._getSnappingContext(e);this._updatingHandles.addPromise(o(i.snap({point:n,scenePoint:r},s,a)))}_applyConstraints(t){const{_constraint:e,constraints:i}=this;if(!t||!i||!e)return t;const{context:n}=i,r=M(t,n),s=r?e.closestTo(r):void 0;if(!s)return t;const o=D(s,t,n),a="2d"===this.view.type||"absolute-height"!==n.elevationInfo.mode;return null!=o&&a&&null!=this.constraintZ&&this.hasZ&&(o.z=this.constraintZ),o}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&z(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null,drawConstraints:this.constraints})}};function z(t,e,i){const n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=i}t([d()],A.prototype,"_hideDefaultCursor",void 0),t([d()],A.prototype,"_stagedPointerId",void 0),t([d()],A.prototype,"_isDragging",null),t([d()],A.prototype,"_snappingOperation",void 0),t([d()],A.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],A.prototype,"graphic",void 0),t([d()],A.prototype,"constraintsEnabled",void 0),t([d()],A.prototype,"constraints",void 0),t([d()],A.prototype,"_constraint",null),t([d()],A.prototype,"constraintZ",void 0),t([d()],A.prototype,"defaultZ",void 0),t([d()],A.prototype,"isDraped",void 0),t([d({constructOnly:!0})],A.prototype,"automaticLengthMeasurementUtils",void 0),t([d({value:v})],A.prototype,"drawingMode",null),t([d({constructOnly:!0})],A.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],A.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:E})],A.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],A.prototype,"geometryType",void 0),t([d({constructOnly:!0})],A.prototype,"hasM",void 0),t([d({constructOnly:!0})],A.prototype,"hasZ",void 0),t([d()],A.prototype,"cursor",void 0),t([d()],A.prototype,"effectiveCursor",null),t([d()],A.prototype,"loading",void 0),t([d({constructOnly:!0})],A.prototype,"manipulators",void 0),t([d({constructOnly:!0})],A.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],A.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],A.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],A.prototype,"snappingVisualizer",void 0),t([d()],A.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],A.prototype,"cursorVertex",null),t([d({readOnly:!0})],A.prototype,"visualizationCursorVertex",null),t([d()],A.prototype,"committableVertex",null),t([d()],A.prototype,"firstVertex",void 0),t([d()],A.prototype,"lastVertex",void 0),t([d()],A.prototype,"secondToLastVertex",void 0),t([d()],A.prototype,"updating",null),t([d({constructOnly:!0})],A.prototype,"view",void 0),A=t([h("esri.views.draw.DrawOperation")],A);export{A as DrawOperation,k as defaultCursor,Z as defaultLoadingCursor};
|
package/views/draw/DrawTool.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__addDisposableResource as e,__disposeResources as t,__decorate as a}from"tslib";import{disposable as i}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as r}from"../../core/MapUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{when as s,initial as d,on as l,sync as p,watch as c}from"../../core/reactiveUtils.js";import{screenPointEqual as g,createScreenPoint as u}from"../../core/screenUtils.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as M}from"../../core/support/UpdatingHandles.js";import{createSnappingVisualizer as y}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as f,markHandled as _,getPointerType as w}from"./support/drawToolUtils.js";import{PluginContext as C}from"./support/PluginContext.js";import{viewEventToCommand as H}from"./support/input/drawToolInput.js";import{EditSessionManager as x}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as S}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as b}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as P}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as T}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as k}from"./support/managers/SurfaceManager.js";import{TooltipManager as I}from"./support/managers/TooltipManager.js";import{ViewEventPriorities as O}from"../input/InputManager.js";import{createCoordinateHelper as j}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as A}from"../interactive/InteractiveToolBase.js";import{KeyBindings as V,mediaKeys as E,sketchKeys as U,advancedSketchKeys as D,tooltipKeys as L}from"../interactive/keybindings.js";import{isInputModeAvailable as R}from"../interactive/tooltip/tooltipCommonUtils.js";const G=Symbol();let Z=class extends A{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._snappingVisualizer=null,this._updatingHandles=new M,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type="draw-2.0",this.automaticManipulatorSelection=!0,this.snappingManager=null,this.sketchOptions=null,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new P,this.globalStateManager=new S({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new x({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new T({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null}initialize(){const{view:e}=this;this.interactiveHandleManager=new b({view:e,renderer:this.renderer}),this._override("manipulators",this.interactiveHandleManager.manipulators),this.tooltipManager=new I({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(s(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:"outputGeometry"}),t.addOrUpdateVisual(this._vertexVisualId,{role:"vertex"}),this._updatingHandles.addPromise(y(e,t).then(e=>this._snappingVisualizer=e))},d)),this.addHandles([s(()=>this.view,e=>{this.surfaceManager?.destroy(),this.surfaceManager=new k({spatialReference:this.coordinateHelper.spatialReference,excludedGraphicsLayer:null,defaultZ:this.defaultZ,hasZ:this.hasZ,view:e,elevationInfo:this.elevationInfo,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},d),s(()=>this.sketchOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),l(()=>this.editSessionManager,"cancelPlugin",({plugin:e})=>{this._suspendPlugin(e)},p),l(()=>this.editSessionManager,"restartPlugin",({restartInfo:e})=>{this._resumePlugin(e)},p),l(()=>this.editGeometryOperations,["vertex-add","vertex-update","vertex-remove"],e=>{const t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),a=t.map(e=>e.coordinates);switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:a,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:a,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:a,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(const e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=o(this.surfaceManager),this.interactiveHandleManager=o(this.interactiveHandleManager),this.tooltipManager=o(this.tooltipManager)}get _tooltipDependencies(){const{defaultZ:e,editGeometryOperations:t,sketchOptions:a,directionOptions:i,view:n}=this;return t&&a&&n?{defaultZ:e,directionOptions:i,editGeometryOperations:t,sketchOptions:a,view:n,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,notifyTooltipsChanged:()=>{const{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}:null}get _editSessionManagerContext(){const{coordinateHelper:e,view:t}=this;return{coordinateHelper:e,viewingMode:"3d"===t?.type&&"global"===t.viewingMode?1:2}}get updating(){return this._updatingHandles.updating||this.lifecycleManager.updating}get coordinateHelper(){return j(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get geometry(){return this.editSessionManager.outputGeometry}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){return this.lastScreenPosition?this.view.toMap(this.lastScreenPosition):this.view.center}get movementCommandContext(){const{editGeometryOperations:e,tooltipManager:t,surfaceManager:a,snappingManager:i,interactiveHandleManager:n,_snappingVisualizer:r,defaultZ:o,hasZ:s,globalStateManager:{drawAtFixedElevation:d},view:l}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:a,interactiveHandleManager:n,snappingManager:i,snappingVisualizer:r,pointerType:"mouse",hasZ:s,defaultZ:o,view:l,drawAtFixedElevation:d}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){const t=this.lifecycleManager;e&&t.complete(e),0===t.pluginStack.length&&(this.emit("complete",{geometry:this.geometry,aborted:!1,type:"complete",vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null))}cancelFirstUserLeafPlugin(){const e=this.pluginStack.toArray().findLast(e=>!0!==e.configuration?.hidden);e&&this.lifecycleManager.cancel(e)}replaceLeaf(e){const t=this.lifecycleManager;t.updating?n.getLogger(this).info("Ignoring command; arrived while updating:","replaceLeaf"):t.replaceLeaf(e)}finishPart(){const e=this.mostUpstreamPlugin,t=e?.configuration;if(this.editGeometryOperations&&t&&t.kind?.includes("multipart")){const e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._guardCommand({action:"undo"},()=>this.editSessionManager.undo())}redo(){this._guardCommand({action:"redo"},()=>this.editSessionManager.redo())}executeCommand(e){return this._handleCommand(e)}addPromise(e){return this._updatingHandles.addPromise(e)}onActivate(){super.onActivate();const{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&(this.begin(this._pendingBeginRequest),this._pendingBeginRequest=null),this.addHandles([c(()=>this.geometry,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e}),this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?f(e):null})},d),s(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:g}),c(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{const a=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&a&&this.emit("cursor-update",{updated:a.pos,type:"vertex-update",operation:"apply",vertices:[{componentIndex:a.part.index,vertexIndex:a.index,coordinates:a.pos}]})},p),this._keybindings.register(e,O.TOOL),c(()=>e.viewpoint,(e,t)=>{e&&t&&h(e,t)&&this._handleCommand({action:"viewpoint-moved"})})],G)}onDeactivate(){super.onDeactivate(),this.removeHandles(G),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){const t=H(e);t&&this._handleCommand(t)}async _handleCommand(e){if(this.lifecycleManager.updating)n.getLogger(this).info("Ignoring command; arrived while updating:",e.action);else switch(e.action){case"view-drag":return await this._handleViewDragCommand(e);case"vertex-add":return this._guardCommand(e,()=>{_(e),this._commitNext()});case"vertex-add-and-finish-part":return this._handleVertexAddAndFinishPartCommand(e);case"cancel":return this._guardCommand(e,()=>this.cancel());case"complete":return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(_(e),this.complete(this.mostUpstreamPlugin))});case"finish-part":return this._guardCommand(e,()=>this.finishPart());case"undo":return this._guardCommand(e,()=>this.editSessionManager.undo());case"redo":return this._guardCommand(e,()=>this.editSessionManager.redo());case"next-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("forward"));case"previous-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("backward"));case"toggle-manipulator-follow":this.interactiveHandleManager?.toggleFollow()&&_(e);break;case"viewpoint-moved":return await this._handleViewpointMovedCommand(e);case"manipulator-move-to":return await this._handleManipulatorMoveToCommand(e);case"manipulator-drag-to":return await this._handleManipulatorDragToCommand(e);case"vertex-add-at-point":return await this._handleVertexAddAtPointCommand(e);case"show-tooltip":return this._guardCommand(e,async()=>{const t=this.tooltipManager?.tooltip;t&&R(t.info)&&(await t.enterInputMode(),_(e))});case"constraint-center":this.globalStateManager.setCentered(e.enabled);break;case"constraint-aspect":this.globalStateManager.setPreserveAspectRatio(e.enabled)}}async _handleViewDragCommand(e){if(!this.editable)return;const t=e.originalEvent,a=this.interactiveHandleManager?.capturingHandle;(!t||!("pointerType"in t)||"touch"!==t.pointerType||"capture-always"!==a?.captureMode&&"capture-when-engaged"!==a?.captureMode)&&"capture-when-engaged"!==this.interactiveHandleManager?.capturingHandle?.captureMode?this._before(e)&&_(e):_(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(_(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){this.editable&&(await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:w(e.originalEvent)})),this.interactiveHandleManager?.updateAllScreenPositions())}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;const t=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&_(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(t,{...this.movementCommandContext,pointerType:w(e.originalEvent)}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;const t=w(e.originalEvent),a=this._updateLastScreenPosition(e),i=this.interactiveHandleManager?.findHandleByManipulator(a);"touch"===t&&i&&"start"===e.state&&this.interactiveHandleManager?.releaseHandle();const n=this.interactiveHandleManager?.findHandleDragging(),r=this.interactiveHandleManager?.capturingHandle,o=n??r??i;o&&!i&&_(e),"capture-when-engaged"===o?.captureMode||"capture-always"===o?.captureMode&&"touch"===t?"end"===e.state?await this._updatingHandles.addPromise(o.noteDragEnd(a,{...this.movementCommandContext,pointerType:t}).then(()=>{o&&"touch"===w(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&"primary"===o.role&&(1===this.interactiveHandleManager?.handleCount?this._handleCommand({action:"vertex-add"}):this.interactiveHandleManager?.releaseHandle())})):"start"===e.state?await this._updatingHandles.addPromise(o.noteDragStart(a,{...this.movementCommandContext,pointerType:t}).then(()=>{o&&"touch"===w(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&!o.editSession?.lastPointAddedBySession&&this._handleCommand({action:"vertex-add"})})):await this._updatingHandles.addPromise(o?.moveTo(a,{...this.movementCommandContext,pointerType:w(e.originalEvent)})):"grabbable-object"===o?.captureMode&&(this.interactiveHandleManager?.releaseHandle(r),await this._updatingHandles.addPromise(o.moveTo(a,{...this.movementCommandContext,pointerType:t})))}async _handleVertexAddAtPointCommand(e){const t=this._updateLastScreenPosition(e),a=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t);this.editable&&a&&(this._before(e)||(_(e),await this._updatingHandles.addPromise(a.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:w(e.originalEvent)}).finally(()=>this._commitNext()))))}_makeKeyBindings(){const e=new V,t=(t,a)=>{e.addToggle(t,e=>this._handleCommand({action:a,originalEvent:e,enabled:"key-down"===e.type}))},a=(t,a)=>{e.add(t,e=>this._handleCommand({action:a,originalEvent:e}))};return t(E.preserveAspectRatio,"constraint-aspect"),t(U.center,"constraint-center"),a(D.toggleFollowManipulator,"toggle-manipulator-follow"),a(U.undo,"undo"),a(U.redo,"redo"),a(U.complete,"complete"),a(U.vertexAdd,"vertex-add"),a({key:L.enterInputMode,continuePropagation:!0,repeats:!0},"show-tooltip"),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);const t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){const a={stack:[],error:void 0,hasError:!1};try{const t=this.mostDownstreamPlugin;if(!t)return;let n=!1;const r=this.editGeometryOperations;e(a,r?i(r.on("vertex-add",()=>n=!0)):null,!1);t.completeStep?t.completeStep():this.complete(t),n&&this.tooltipManager?.unlockOnVertexPlacement()}catch(n){a.error=n,a.hasError=!0}finally{t(a)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){const t=u(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){const a=r(this._pluginContexts,e,()=>new C({drawTool:this,plugin:e,session:t}));return a.session=t,a}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;const t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,a){return this._before(e)?a?.():t()}};a([m()],Z.prototype,"_snappingVisualizer",void 0),a([m()],Z.prototype,"_tooltipDependencies",null),a([m()],Z.prototype,"_editSessionManagerContext",null),a([m({constructOnly:!0,nonNullable:!0})],Z.prototype,"view",void 0),a([m()],Z.prototype,"automaticManipulatorSelection",void 0),a([m()],Z.prototype,"updating",null),a([m()],Z.prototype,"coordinateHelper",null),a([m()],Z.prototype,"editGeometry",null),a([m()],Z.prototype,"editGeometryOperations",null),a([m()],Z.prototype,"geometry",null),a([m()],Z.prototype,"snappingManager",void 0),a([m()],Z.prototype,"sketchOptions",void 0),a([m()],Z.prototype,"elevationInfo",void 0),a([m()],Z.prototype,"hasZ",void 0),a([m()],Z.prototype,"defaultZ",void 0),a([m()],Z.prototype,"directionOptions",void 0),a([m()],Z.prototype,"canUndo",null),a([m()],Z.prototype,"canRedo",null),a([m()],Z.prototype,"pluginStack",null),a([m()],Z.prototype,"mostDownstreamPlugin",null),a([m()],Z.prototype,"mostUpstreamPlugin",null),a([m()],Z.prototype,"lastScreenPosition",void 0),a([m()],Z.prototype,"positionOfLastUserInput",null),a([m()],Z.prototype,"tooltipManager",void 0),a([m()],Z.prototype,"measurementManager",void 0),a([m()],Z.prototype,"globalStateManager",void 0),a([m()],Z.prototype,"editSessionManager",void 0),a([m()],Z.prototype,"lifecycleManager",void 0),a([m()],Z.prototype,"surfaceManager",void 0),a([m()],Z.prototype,"interactiveHandleManager",void 0),a([m()],Z.prototype,"renderer",void 0),a([m()],Z.prototype,"movementCommandContext",null),a([m()],Z.prototype,"tooltip",null),a([m()],Z.prototype,"activeTooltipInfo",null),Z=a([v("esri.views.draw.DrawTool")],Z);export{Z as DrawTool};
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t,__decorate as i}from"tslib";import{disposable as a}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as r}from"../../core/MapUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{when as s,initial as l,on as d,sync as p,watch as c}from"../../core/reactiveUtils.js";import{screenPointEqual as u,createScreenPoint as g}from"../../core/screenUtils.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as y}from"../../core/support/UpdatingHandles.js";import f from"../../geometry/Polygon.js";import{i as M,e as _}from"../../chunks/simplifyOperator.js";import{isExtent as w}from"../../geometry/support/jsonTypeUtils.js";import{isPolygon as C}from"../../geometry/support/typeUtils.js";import{isCurvedGeometry as H}from"../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as S}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{getMaxDeviationInPixels as P,getMinSegmentsPerCurve as x}from"../2d/layers/graphics/densificationConstants.js";import{createSnappingVisualizer as b}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as j,markHandled as T,getPointerType as k}from"./support/drawToolUtils.js";import{PluginContext as G}from"./support/PluginContext.js";import{viewEventToCommand as O}from"./support/input/drawToolInput.js";import{EditSessionManager as I}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as U}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as A}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as V}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as E}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as D}from"./support/managers/SurfaceManager.js";import{TooltipManager as R}from"./support/managers/TooltipManager.js";import{ViewEventPriorities as L}from"../input/InputManager.js";import{createCoordinateHelper as Z}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as B}from"../interactive/InteractiveToolBase.js";import{KeyBindings as F,mediaKeys as z,sketchKeys as q,advancedSketchKeys as K,tooltipKeys as N}from"../interactive/keybindings.js";import{isInputModeAvailable as $}from"../interactive/tooltip/tooltipCommonUtils.js";const J=Symbol();let Q=class extends B{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._snappingVisualizer=null,this._updatingHandles=new y,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type="draw-2.0",this.automaticManipulatorSelection=!0,this.snappingManager=null,this.sketchOptions=null,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new V,this.globalStateManager=new U({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new I({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new E({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null}initialize(){const{view:e}=this;this.interactiveHandleManager=new A({view:e,renderer:this.renderer}),this._override("manipulators",this.interactiveHandleManager.manipulators),this.tooltipManager=new R({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(s(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:"outputGeometry"}),t.addOrUpdateVisual(this._vertexVisualId,{role:"vertex"}),this._updatingHandles.addPromise(b(e,t).then(e=>this._snappingVisualizer=e))},l)),this.addHandles([s(()=>this.view,e=>{this.surfaceManager?.destroy(),this.surfaceManager=new D({spatialReference:this.coordinateHelper.spatialReference,excludedGraphicsLayer:null,defaultZ:this.defaultZ,hasZ:this.hasZ,view:e,elevationInfo:this.elevationInfo,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},l),s(()=>this.sketchOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),d(()=>this.editSessionManager,"cancelPlugin",({plugin:e})=>{this._suspendPlugin(e)},p),d(()=>this.editSessionManager,"restartPlugin",({restartInfo:e})=>{this._resumePlugin(e)},p),d(()=>this.editGeometryOperations,["vertex-add","vertex-update","vertex-remove"],e=>{const t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),i=t.map(e=>e.coordinates);switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(const e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=o(this.surfaceManager),this.interactiveHandleManager=o(this.interactiveHandleManager),this.tooltipManager=o(this.tooltipManager)}get _tooltipDependencies(){const{defaultZ:e,editGeometryOperations:t,sketchOptions:i,directionOptions:a,view:n}=this;return t&&i&&n?{defaultZ:e,directionOptions:a,editGeometryOperations:t,sketchOptions:i,view:n,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,getHelpMessageKey:()=>this.helpMessageKey,notifyTooltipsChanged:()=>{const{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}:null}get _editSessionManagerContext(){const{coordinateHelper:e,view:t}=this;return{coordinateHelper:e,viewingMode:"3d"===t?.type&&"global"===t.viewingMode?1:2}}get _densificationParameters(){const{view:e,coordinateHelper:t}=this,i=t.spatialReference,a=e?.spatialReference,n=e.resolution;if(!(i&&a&&n&&Number.isFinite(n)))return null;const r=a.metersPerUnit/i.metersPerUnit;return{maxDeviation:2**Math.round(Math.log2(n))*P()*r,minSegmentsPerCurve:x()}}get test(){return{densificationParameters:this._densificationParameters}}get updating(){return this._updatingHandles.updating||this.lifecycleManager.updating}get coordinateHelper(){return Z(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get unprocessedGeometry(){return this.editSessionManager.outputGeometry}get simplifiedGeometryPreview(){const e=this.editSessionManager.outputGeometry;if(e&&C(e))try{const t=this._densificationParameters,i=H(e)&&t?new f({...S(e,t)}):e;if(!M(i))return _(i)}catch(t){return e}return e}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){return this.lastScreenPosition?this.view.toMap(this.lastScreenPosition):this.view.center}get movementCommandContext(){const{editGeometryOperations:e,tooltipManager:t,surfaceManager:i,snappingManager:a,interactiveHandleManager:n,_snappingVisualizer:r,defaultZ:o,hasZ:s,globalStateManager:{drawAtFixedElevation:l},view:d}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:i,interactiveHandleManager:n,snappingManager:a,snappingVisualizer:r,pointerType:"mouse",hasZ:s,defaultZ:o,view:d,drawAtFixedElevation:l}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}get helpMessageKey(){return this.pluginStack.items.findLast(e=>e.helpMessageKey)?.helpMessageKey??"noTool"}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){const t=this.lifecycleManager;e&&t.complete(e),0===t.pluginStack.length&&(this._finalizeAndSimplifyGeometryResult(),this.emit("complete",{geometry:this.finalGeometry,aborted:!1,type:"complete",vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null))}cancelFirstUserLeafPlugin(){const e=this.pluginStack.toArray().findLast(e=>!0!==e.configuration?.hidden);e&&this.lifecycleManager.cancel(e)}replaceLeaf(e){const t=this.lifecycleManager;t.updating?n.getLogger(this).info("Ignoring command; arrived while updating:","replaceLeaf"):t.replaceLeaf(e)}finishPart(){const e=this.mostUpstreamPlugin,t=e?.configuration;if(this.editGeometryOperations&&t&&t.kind?.includes("multipart")){const e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._guardCommand({action:"undo"},()=>this.editSessionManager.undo())}redo(){this._guardCommand({action:"redo"},()=>this.editSessionManager.redo())}executeCommand(e){return this._handleCommand(e)}addPromise(e){return this._updatingHandles.addPromise(e)}onActivate(){super.onActivate();const{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&(this.begin(this._pendingBeginRequest),this._pendingBeginRequest=null),this.addHandles([c(()=>this.unprocessedGeometry,e=>{this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?j(e):null})},l),c(()=>this.simplifiedGeometryPreview,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e})},l),s(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:u}),c(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{const i=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&i&&this.emit("cursor-update",{updated:i.pos,type:"vertex-update",operation:"apply",vertices:[{componentIndex:i.part.index,vertexIndex:i.index,coordinates:i.pos}]})},p),this._keybindings.register(e,L.TOOL),c(()=>e.viewpoint,(e,t)=>{e&&t&&h(e,t)&&this._handleCommand({action:"viewpoint-moved"})})],J)}onDeactivate(){super.onDeactivate(),this.removeHandles(J),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){const t=O(e);t&&this._handleCommand(t)}async _handleCommand(e){if(this.lifecycleManager.updating)n.getLogger(this).info("Ignoring command; arrived while updating:",e.action);else switch(e.action){case"view-drag":return await this._handleViewDragCommand(e);case"vertex-add":return this._guardCommand(e,()=>{T(e),this._commitNext()});case"vertex-add-and-finish-part":return this._handleVertexAddAndFinishPartCommand(e);case"cancel":return this._guardCommand(e,()=>this.cancel());case"complete":return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(T(e),this.complete(this.mostUpstreamPlugin))});case"finish-part":return this._guardCommand(e,()=>this.finishPart());case"undo":return this._guardCommand(e,()=>this.editSessionManager.undo());case"redo":return this._guardCommand(e,()=>this.editSessionManager.redo());case"next-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("forward"));case"previous-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("backward"));case"toggle-manipulator-follow":this.interactiveHandleManager?.toggleFollow()&&T(e);break;case"viewpoint-moved":return await this._handleViewpointMovedCommand(e);case"manipulator-move-to":return await this._handleManipulatorMoveToCommand(e);case"manipulator-drag-to":return await this._handleManipulatorDragToCommand(e);case"vertex-add-at-point":return await this._handleVertexAddAtPointCommand(e);case"show-tooltip":return this._guardCommand(e,async()=>{const t=this.tooltipManager?.tooltip;t&&$(t.info)&&(await t.enterInputMode(),T(e))});case"constraint-center":this.globalStateManager.setCentered(e.enabled);break;case"constraint-aspect":this.globalStateManager.setPreserveAspectRatio(e.enabled)}}async _handleViewDragCommand(e){if(!this.editable)return;const t=e.originalEvent,i=this.interactiveHandleManager?.capturingHandle;(!t||!("pointerType"in t)||"touch"!==t.pointerType||"capture-always"!==i?.captureMode&&"capture-when-engaged"!==i?.captureMode)&&"capture-when-engaged"!==this.interactiveHandleManager?.capturingHandle?.captureMode?this._before(e)&&T(e):T(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(T(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){this.editable&&(await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:k(e.originalEvent)})),this.interactiveHandleManager?.updateAllScreenPositions())}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;const t=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&T(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(t,{...this.movementCommandContext,pointerType:k(e.originalEvent)}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;const t=k(e.originalEvent),i=this._updateLastScreenPosition(e),a=this.interactiveHandleManager?.findHandleByManipulator(i);"touch"===t&&a&&"start"===e.state&&this.interactiveHandleManager?.releaseHandle();const n=this.interactiveHandleManager?.findHandleDragging(),r=this.interactiveHandleManager?.capturingHandle,o=n??r??a;o&&!a&&T(e),"capture-when-engaged"===o?.captureMode||"capture-always"===o?.captureMode&&"touch"===t?"end"===e.state?await this._updatingHandles.addPromise(o.noteDragEnd(i,{...this.movementCommandContext,pointerType:t}).then(()=>{o&&"touch"===k(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&"primary"===o.role&&(1===this.interactiveHandleManager?.handleCount?this._handleCommand({action:"vertex-add"}):this.interactiveHandleManager?.releaseHandle())})):"start"===e.state?await this._updatingHandles.addPromise(o.noteDragStart(i,{...this.movementCommandContext,pointerType:t}).then(()=>{o&&"touch"===k(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&!o.editSession?.lastPointAddedBySession&&this._handleCommand({action:"vertex-add"})})):await this._updatingHandles.addPromise(o?.moveTo(i,{...this.movementCommandContext,pointerType:k(e.originalEvent)})):"grabbable-object"===o?.captureMode&&(this.interactiveHandleManager?.releaseHandle(r),await this._updatingHandles.addPromise(o.moveTo(i,{...this.movementCommandContext,pointerType:t})))}async _handleVertexAddAtPointCommand(e){const t=this._updateLastScreenPosition(e),i=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t);this.editable&&i&&(this._before(e)||(T(e),await this._updatingHandles.addPromise(i.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:k(e.originalEvent)}).finally(()=>this._commitNext()))))}_makeKeyBindings(){const e=new F,t=(t,i)=>{e.addToggle(t,e=>this._handleCommand({action:i,originalEvent:e,enabled:"key-down"===e.type}))},i=(t,i)=>{e.add(t,e=>this._handleCommand({action:i,originalEvent:e}))};return t(z.preserveAspectRatio,"constraint-aspect"),t(q.center,"constraint-center"),i(K.toggleFollowManipulator,"toggle-manipulator-follow"),i(q.undo,"undo"),i(q.redo,"redo"),i(q.complete,"complete"),i(q.vertexAdd,"vertex-add"),i({key:N.enterInputMode,continuePropagation:!0,repeats:!0},"show-tooltip"),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);const t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){const i={stack:[],error:void 0,hasError:!1};try{const t=this.mostDownstreamPlugin;if(!t)return;let n=!1;const r=this.editGeometryOperations;e(i,r?a(r.on("vertex-add",()=>n=!0)):null,!1);t.completeStep?t.completeStep():this.complete(t),n&&this.tooltipManager?.unlockOnVertexPlacement()}catch(n){i.error=n,i.hasError=!0}finally{t(i)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){const t=g(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){const i=r(this._pluginContexts,e,()=>new G({drawTool:this,plugin:e,session:t}));return i.session=t,i}_finalizeAndSimplifyGeometryResult(){const e=this.unprocessedGeometry;try{const t=e?_(e):e;t&&!w(t)?this.finalGeometry=t:this.finalGeometry=e}catch(t){n.getLogger(this).error("draw-tool:complete","geometry simplification failed",t)}}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;const t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,i){return this._before(e)?i?.():t()}};i([m()],Q.prototype,"_snappingVisualizer",void 0),i([m()],Q.prototype,"_tooltipDependencies",null),i([m()],Q.prototype,"_editSessionManagerContext",null),i([m()],Q.prototype,"_densificationParameters",null),i([m({constructOnly:!0,nonNullable:!0})],Q.prototype,"view",void 0),i([m()],Q.prototype,"automaticManipulatorSelection",void 0),i([m()],Q.prototype,"updating",null),i([m()],Q.prototype,"coordinateHelper",null),i([m()],Q.prototype,"editGeometry",null),i([m()],Q.prototype,"editGeometryOperations",null),i([m()],Q.prototype,"unprocessedGeometry",null),i([m()],Q.prototype,"finalGeometry",void 0),i([m()],Q.prototype,"simplifiedGeometryPreview",null),i([m()],Q.prototype,"snappingManager",void 0),i([m()],Q.prototype,"sketchOptions",void 0),i([m()],Q.prototype,"elevationInfo",void 0),i([m()],Q.prototype,"hasZ",void 0),i([m()],Q.prototype,"defaultZ",void 0),i([m()],Q.prototype,"directionOptions",void 0),i([m()],Q.prototype,"canUndo",null),i([m()],Q.prototype,"canRedo",null),i([m()],Q.prototype,"pluginStack",null),i([m()],Q.prototype,"mostDownstreamPlugin",null),i([m()],Q.prototype,"mostUpstreamPlugin",null),i([m()],Q.prototype,"lastScreenPosition",void 0),i([m()],Q.prototype,"positionOfLastUserInput",null),i([m()],Q.prototype,"tooltipManager",void 0),i([m()],Q.prototype,"measurementManager",void 0),i([m()],Q.prototype,"globalStateManager",void 0),i([m()],Q.prototype,"editSessionManager",void 0),i([m()],Q.prototype,"lifecycleManager",void 0),i([m()],Q.prototype,"surfaceManager",void 0),i([m()],Q.prototype,"interactiveHandleManager",void 0),i([m()],Q.prototype,"renderer",void 0),i([m()],Q.prototype,"movementCommandContext",null),i([m()],Q.prototype,"tooltip",null),i([m()],Q.prototype,"activeTooltipInfo",null),i([m()],Q.prototype,"helpMessageKey",null),Q=i([v("esri.views.draw.DrawTool")],Q);export{Q as DrawTool};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{isSome as e}from"../../../core/arrayUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import{watch as i,initial as r}from"../../../core/reactiveUtils.js";import{property as s,subclass as a}from"../../../core/accessorSupport/decorators.js";import p from"../../../geometry/Point.js";import l from"../../../geometry/Polyline.js";import{isBezierCurve as c}from"../../../geometry/support/curves/curveUtils.js";import{PluginBase as h}from"./PluginBase.js";const d=Symbol("left-vertex"),u=Symbol("right-vertex"),_=Symbol("cp1"),P=Symbol("cp2"),m=Symbol("endpoint"),f=Symbol("anchor");let y=class extends h{constructor(){super(...arguments),this._controlPoint1LineId=Symbol(),this._controlPoint2LineId=Symbol(),this._mirroredCp2VisualId=Symbol(),this.enableSplineBehavior=!0,this.state="placing-anchor"}get test(){return{computeCurve:this._computeCurve.bind(this),recomputeAndApply:this._recomputeAndApply.bind(this),cp1LineSymbol:this._controlPoint1LineId,cp2LineSymbol:this._controlPoint2LineId,controlPointId:this._mirroredCp2VisualId}}start(t,e){super.start(t,e);const o=t.session;o.preserveSharedRedoAfterOperation=!0,this.ownPlacedLeftAnchor=e?.ownPlacedLeftAnchor,this.leftAnchor=o.getInformationAboutPoint(-1,-1)?.point;let n=e?.state;if(!this.leftAnchor&&this.ownPlacedLeftAnchor?(this.leftAnchor=this.ownPlacedLeftAnchor,o.appendOrReplacePoint(d,this.leftAnchor),o?.groupGeometryChanges()):this.leftAnchor&&"placing-anchor"===e?.state&&(n="placing-control-point-1",this.ownPlacedLeftAnchor=null),this.state=this.leftAnchor?n??"placing-control-point-1":"placing-anchor",this.controlPoint1=e?.controlPoint1,this.endPoint=e?.endPoint,this.controlPoint2=e?.controlPoint2,this.enableSplineBehavior&&"placing-control-point-1"===this.state&&!n){const t=o.getInformationAboutPoint(-1,-1);if(t?.curveInfo&&c(t.curveInfo)){const[e,n]=t.curveInfo.b[2],{spatialReference:i}=t.point,r=new p({x:e,y:n,spatialReference:i}),s=
|
|
2
|
+
import{__decorate as t}from"tslib";import{isSome as e}from"../../../core/arrayUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import{watch as i,initial as r}from"../../../core/reactiveUtils.js";import{property as s,subclass as a}from"../../../core/accessorSupport/decorators.js";import p from"../../../geometry/Point.js";import l from"../../../geometry/Polyline.js";import{isBezierCurve as c}from"../../../geometry/support/curves/curveUtils.js";import{PluginBase as h}from"./PluginBase.js";const d=Symbol("left-vertex"),u=Symbol("right-vertex"),_=Symbol("cp1"),P=Symbol("cp2"),m=Symbol("endpoint"),f=Symbol("anchor");let y=class extends h{constructor(){super(...arguments),this._controlPoint1LineId=Symbol(),this._controlPoint2LineId=Symbol(),this._mirroredCp2VisualId=Symbol(),this.enableSplineBehavior=!0,this.state="placing-anchor"}get helpMessageKey(){switch(this.state){case"placing-control-point-1":return"curveBezierControlPoint1";case"placing-endpoint":return"curvePlaceEndPoint";case"placing-control-point-2":return"curveBezierControlPoint2";default:return"point"}}get test(){return{computeCurve:this._computeCurve.bind(this),recomputeAndApply:this._recomputeAndApply.bind(this),cp1LineSymbol:this._controlPoint1LineId,cp2LineSymbol:this._controlPoint2LineId,controlPointId:this._mirroredCp2VisualId}}start(t,e){super.start(t,e);const o=t.session;o.preserveSharedRedoAfterOperation=!0,this.ownPlacedLeftAnchor=e?.ownPlacedLeftAnchor,this.leftAnchor=o.getInformationAboutPoint(-1,-1)?.point;let n=e?.state;if(!this.leftAnchor&&this.ownPlacedLeftAnchor?(this.leftAnchor=this.ownPlacedLeftAnchor,o.appendOrReplacePoint(d,this.leftAnchor),o?.groupGeometryChanges()):this.leftAnchor&&"placing-anchor"===e?.state&&(n="placing-control-point-1",this.ownPlacedLeftAnchor=null),this.state=this.leftAnchor?n??"placing-control-point-1":"placing-anchor",this.controlPoint1=e?.controlPoint1,this.endPoint=e?.endPoint,this.controlPoint2=e?.controlPoint2,this.enableSplineBehavior&&"placing-control-point-1"===this.state&&!n){const t=o.getInformationAboutPoint(-1,-1);if(t?.curveInfo&&c(t.curveInfo)){const[e,n]=t.curveInfo.b[2],{spatialReference:i}=t.point,r=new p({x:e,y:n,spatialReference:i}),s=C(t.point,r);this.controlPoint1=s,o?.pushUndoStep(this._captureState()),this.state="placing-endpoint",o?.pushUndoStep(this._captureState())}}this.addHandles([i(()=>this._anchorCursor?.outputMapPosition,t=>{t&&(this.leftAnchor=this.ownPlacedLeftAnchor=t,this._session?.appendOrReplacePoint(d,t))}),i(()=>this._cp1Cursor?.outputMapPosition,t=>{t&&(this.controlPoint1=t,this._recomputeAndApply())}),i(()=>this._endpointCursor?.outputMapPosition,t=>{t&&(this.endPoint=t,this._recomputeAndApply())}),i(()=>this._cp2Cursor?.outputMapPosition,t=>{t&&(this.controlPoint2=t,this._recomputeAndApply())})],this._ownHandlesKey),this._applyState(this.state),this._setupRendering(t)}completeStep(){if(this._isComplete)return;const t=this._session?.peekUndoStep();if(t){const e=this._captureState();t&&t.state===e?.state&&(t.controlPoint1=e.controlPoint1,t.controlPoint2=e.controlPoint2,t.endPoint=e.endPoint,t.leftAnchor=e.leftAnchor)}else this._session?.pushUndoStep(this._captureState());try{switch(this._session.preserveSharedRedoAfterOperation=!1,this.state){case"placing-anchor":this._applyState(this.state="placing-control-point-1");break;case"placing-control-point-1":this._applyState(this.state="placing-endpoint");break;case"placing-endpoint":this._applyState(this.state="placing-control-point-2");break;case"placing-control-point-2":this._context?.requestComplete()}}finally{this._session.preserveSharedRedoAfterOperation=!0}this._session?.pushUndoStep(this._captureState())}beforeAttachPlugin(t){return{useStandaloneSession:!0}}suspend(){return this._captureState()}_applyState(t){const e=this._session;if(!e)throw new o("drawTool:invalid-state","Bezier: attempted to apply state while context invalid");switch(e.automaticRestart=!1,this.removeHandles(_),this.removeHandles(m),this.removeHandles(P),this.removeHandles(f),t){case"placing-anchor":e.automaticRestart=!0,this._setupAnchorCursor();break;case"placing-control-point-1":{const{ownPlacedLeftAnchor:t}=this;e.automaticRestart=!t,t&&e.groupGeometryChanges(),this._setupCP1Cursor();break}case"placing-endpoint":this._setupCP1Cursor(),this._setupEndpointCursor();break;case"placing-control-point-2":this._setupCP1Cursor(),this._setupEndpointCursor(),this._setupCP2Cursor()}}_setupAnchorCursor(){this._anchorCursor=this._context.createInteractiveHandle({defaultCaptureMode:"capture-always",inputMapPosition:this._context.positionOfLastUserInput,role:"primary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(n(()=>{this._anchorCursor&&(this._context?.removeInteractiveHandle(this._anchorCursor),this._anchorCursor=null)}),f)}_setupCP1Cursor(){const t="placing-control-point-1"===this.state?"capture-always":"grabbable-object";this._cp1Cursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.controlPoint1,role:"secondary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(n(()=>{this._cp1Cursor&&(this._context?.removeInteractiveHandle(this._cp1Cursor),this._cp1Cursor=null)}),_)}_setupEndpointCursor(){const t="placing-endpoint"===this.state?"capture-always":"grabbable-object";this._endpointCursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.endPoint??this.controlPoint1,role:"primary",selfSnappingEnabled:!0,snappingEnabled:!0}),this.addHandles(n(()=>{this._endpointCursor&&(this._context?.removeInteractiveHandle(this._endpointCursor),this._endpointCursor=null)}),m)}_setupCP2Cursor(){const t="placing-control-point-2"===this.state?"capture-always":"grabbable-object";this._cp2Cursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.controlPoint2??this.endPoint??this._context.positionOfLastUserInput,role:"secondary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(n(()=>{this._cp2Cursor&&(this._context?.removeInteractiveHandle(this._cp2Cursor),this._cp2Cursor=null)}),P)}_computeCurve(){const{leftAnchor:t,controlPoint1:e,endPoint:o,controlPoint2:n,state:i}=this;return t?"placing-control-point-1"===i&&e?g(e,e,e):"placing-endpoint"===i&&e&&o?g(o,e,o):e&&o&&n?g(o,e,n,{flipControlPoint2:!0}):null:null}_recomputeAndApply(){const t=this._computeCurve();t&&this._session?.appendOrReplaceCurve(u,t)}_setupRendering(t){t.addOrUpdateVisual(this._controlPoint1LineId,{role:"constructionLine",state:"idle"}),t.addOrUpdateVisual(this._controlPoint2LineId,{role:"constructionLine",state:"idle"}),t.addOrUpdateVisual(this._mirroredCp2VisualId,{role:"controlPoint",state:"idle"}),this.addHandles([i(()=>[this.controlPoint1,this.controlPoint2,this.endPoint,this.leftAnchor],([e,o,n,i])=>{const{state:r}=this;if(i&&e&&"placing-control-point-1"!==r&&"placing-anchor"!==r){const o=new l({paths:[[[i.x,i.y],[e.x,e.y]]],spatialReference:i.spatialReference});t.addOrUpdateVisual(this._controlPoint1LineId,{geometry:o})}else t.addOrUpdateVisual(this._controlPoint1LineId,{geometry:null});if(o&&n&&i){const e=C(n,o),i=new l({paths:[[[o.x,o.y],[e.x,e.y]]],spatialReference:o.spatialReference});t.addOrUpdateVisual(this._controlPoint2LineId,{geometry:i}),t.addOrUpdateVisual(this._mirroredCp2VisualId,{geometry:e})}else t.addOrUpdateVisual(this._controlPoint2LineId,{geometry:null}),t.addOrUpdateVisual(this._mirroredCp2VisualId,{geometry:null})},r)],this._ownHandlesKey)}_captureState(){const{state:t,controlPoint1:e,controlPoint2:o,endPoint:n,leftAnchor:i,ownPlacedLeftAnchor:r}=this;return{state:t,controlPoint1:e,endPoint:n,controlPoint2:o,leftAnchor:i,ownPlacedLeftAnchor:r}}};function g(t,o,n,i){const r=[t.x,t.y,t.z,t.m].filter(e),s=i?.flipControlPoint2?C(t,n):n;return{b:[r,[o.x,o.y],[s.x,s.y]]}}function C(t,e){const{x:o,y:n,spatialReference:i}=t,{x:r,y:s}=e;return new p({x:o+(o-r),y:n+(n-s),spatialReference:i})}t([s()],y.prototype,"_anchorCursor",void 0),t([s()],y.prototype,"_cp1Cursor",void 0),t([s()],y.prototype,"_endpointCursor",void 0),t([s()],y.prototype,"_cp2Cursor",void 0),t([s()],y.prototype,"enableSplineBehavior",void 0),t([s()],y.prototype,"state",void 0),t([s()],y.prototype,"helpMessageKey",null),t([s()],y.prototype,"controlPoint1",void 0),t([s()],y.prototype,"controlPoint2",void 0),t([s()],y.prototype,"endPoint",void 0),t([s()],y.prototype,"leftAnchor",void 0),t([s()],y.prototype,"ownPlacedLeftAnchor",void 0),y=t([a("esri.views.draw.plugins.BezierSegmentPlugin")],y);export{y as BezierSegmentPlugin,g as createBezier,C as mirrorControlPoint};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{makeHandle as i}from"../../../core/handleUtils.js";import{watch as r}from"../../../core/reactiveUtils.js";import{property as
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{makeHandle as i}from"../../../core/handleUtils.js";import{watch as r}from"../../../core/reactiveUtils.js";import{property as n,subclass as o}from"../../../core/accessorSupport/decorators.js";import{geometryToCoordinates as s}from"../../../geometry/support/coordsUtils.js";import{PluginBase as a}from"./PluginBase.js";const p=Symbol("left-anchor-vertex"),c=Symbol("right-vertex"),h=Symbol("anchor"),l=Symbol("endpoint"),d=Symbol("interior-point");let u=class extends a{constructor(){super(...arguments),this.arcDrawingMode="interior-first",this.state="placing-anchor"}get helpMessageKey(){switch(this.state){case"placing-interior":return"curveInteriorPoint";case"placing-endpoint":return"curvePlaceEndPoint";default:return"point"}}get test(){return{state:this.state,captureState:()=>this._captureState()}}start(t,e){super.start(t,e);const i=t.session;i.preserveSharedRedoAfterOperation=!0,this.ownPlacedLeftAnchor=e?.ownPlacedLeftAnchor,this.leftAnchor=i.getInformationAboutPoint(-1,-1)?.point;let n=e?.state;!this.leftAnchor&&this.ownPlacedLeftAnchor?(this.leftAnchor=this.ownPlacedLeftAnchor,i.appendOrReplacePoint(p,this.leftAnchor),i?.groupGeometryChanges()):this.leftAnchor&&"placing-anchor"===e?.state&&(n=this._getNextState("placing-anchor"),this.ownPlacedLeftAnchor=null),this.state=this.leftAnchor?n??this._getNextState("placing-anchor"):"placing-anchor",this.interiorPoint=e?.interiorPoint,this.endpoint=e?.endpoint,this.addHandles([r(()=>this._anchorCursor?.outputMapPosition,t=>{t&&(this.leftAnchor=this.ownPlacedLeftAnchor=t,this._session?.appendOrReplacePoint(p,t))}),r(()=>this._interiorPointCursor?.outputMapPosition,t=>{t&&(this.interiorPoint=t,this._recomputeAndApply())}),r(()=>this._endpointCursor?.outputMapPosition,t=>{t&&(this.endpoint=t,this._recomputeAndApply())})],this._ownHandlesKey),this._applyState(this.state)}async completeStep(){if(this._isComplete)return;const t=this._session?.peekUndoStep();if(t){const e=this._captureState();t&&t.state===e.state&&(t.leftAnchor=e.leftAnchor,t.interiorPoint=e.interiorPoint,t.endpoint=e.endpoint)}else this._session?.pushUndoStep(this._captureState());"placing-anchor"===this.state&&this.ownPlacedLeftAnchor&&this._session?.groupGeometryChanges();try{this._session.preserveSharedRedoAfterOperation=!1;const t=this._getNextState(this.state);null===t?this._context?.requestComplete():this._applyState(this.state=t)}finally{this._session.preserveSharedRedoAfterOperation=!0}this._session?.pushUndoStep(this._captureState())}beforeAttachPlugin(t){return{useStandaloneSession:!0}}suspend(){return this._captureState()}_applyState(t){const i=this._session;if(!i)throw new e("drawTool:invalid-state","Circular Arc: attempted to apply state while context invalid");this.removeHandles(h),this.removeHandles(l),this.removeHandles(d),i.automaticRestart=this._computeAutomaticRestart(),"placing-anchor"!==t?("placing-interior"!==t&&"interior-first"!==this.arcDrawingMode||this._setupInteriorPointCursor(),"placing-endpoint"!==t&&"end-first"!==this.arcDrawingMode||this._setupEndpointCursor()):this._setupAnchorCursor()}_setupAnchorCursor(){this._anchorCursor=this._context.createInteractiveHandle({defaultCaptureMode:"capture-always",inputMapPosition:this._context.positionOfLastUserInput,role:"primary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(i(()=>{this._anchorCursor&&(this._context?.removeInteractiveHandle(this._anchorCursor),this._anchorCursor=null)}),h)}_setupInteriorPointCursor(){const t="placing-interior"===this.state?"capture-always":"grabbable-object";this._interiorPointCursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.interiorPoint??this.endpoint,role:"secondary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(i(()=>{this._interiorPointCursor&&(this._context?.removeInteractiveHandle(this._interiorPointCursor),this._interiorPointCursor=null)}),d)}_setupEndpointCursor(){const t="placing-endpoint"===this.state?"capture-always":"grabbable-object";this._endpointCursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.endpoint??this.interiorPoint,role:"primary",selfSnappingEnabled:!0,snappingEnabled:!0}),this.addHandles(i(()=>{this._endpointCursor&&(this._context?.removeInteractiveHandle(this._endpointCursor),this._endpointCursor=null)}),l)}_captureState(){const{state:t,endpoint:e,interiorPoint:i,leftAnchor:r,ownPlacedLeftAnchor:n}=this;return{state:t,endpoint:e,interiorPoint:i,leftAnchor:r,ownPlacedLeftAnchor:n}}_computeAutomaticRestart(){return"placing-anchor"===this.state||("placing-interior"===this.state?"interior-first"===this.arcDrawingMode&&!this.ownPlacedLeftAnchor:"end-first"===this.arcDrawingMode&&!this.ownPlacedLeftAnchor)}_makeCurve(){const{interiorPoint:t,endpoint:e}=this;if(!t&&!e)return null;const i=e??t,r=s(t??e);return{c:[s(i),_(r)]}}_recomputeAndApply(){const t=this._makeCurve();t&&this._session?.appendOrReplaceCurve(c,t)}_getNextState(t){switch(t){case"placing-anchor":return"interior-first"===this.arcDrawingMode?"placing-interior":"placing-endpoint";case"placing-interior":return"interior-first"===this.arcDrawingMode?"placing-endpoint":null;case"placing-endpoint":return"end-first"===this.arcDrawingMode?"placing-interior":null}}};function _(t){return 2===t.length?t:[t[0]??0,t[1]??0]}t([n()],u.prototype,"_anchorCursor",void 0),t([n()],u.prototype,"_endpointCursor",void 0),t([n()],u.prototype,"_interiorPointCursor",void 0),t([n()],u.prototype,"arcDrawingMode",void 0),t([n()],u.prototype,"interiorPoint",void 0),t([n()],u.prototype,"endpoint",void 0),t([n()],u.prototype,"leftAnchor",void 0),t([n()],u.prototype,"ownPlacedLeftAnchor",void 0),t([n()],u.prototype,"state",void 0),t([n()],u.prototype,"helpMessageKey",null),u=t([o("esri.views.draw.plugins.CircularArcSegmentPlugin")],u);export{u as CircularArcSegmentPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{watch as t,sync as
|
|
2
|
+
import{__decorate as e}from"tslib";import{watch as t,sync as n,syncAndInitial as a}from"../../../core/reactiveUtils.js";import{property as i,subclass as s}from"../../../core/accessorSupport/decorators.js";import{PluginBase as r}from"./PluginBase.js";const o=Symbol("primary-vertex");let p=class extends r{constructor(){super(...arguments),this.completeOnDragEnd=!0}get helpMessageKey(){return this._interactiveHandle?.dragging?"freehandEnd":"freehandStart"}start(e){super.start(e);const{session:i,positionOfLastUserInput:s}=e;s&&i.appendOrReplacePoint(o,s),this._interactiveHandle||(this._interactiveHandle=e.createInteractiveHandle({defaultCaptureMode:"capture-when-engaged",snappingEnabled:!1,selfSnappingEnabled:!1},{disableDefaultXYFields:!0}),this.addHandles([t(()=>this._interactiveHandle?.outputMapPosition,e=>{e&&!this._isComplete&&this._session?.appendOrReplacePoint(o,e,{forceAppend:!!this._interactiveHandle?.dragging})},n)],this._ownHandlesKey),this.completeOnDragEnd&&this.addHandles(t(()=>this._interactiveHandle?.dragging,(t,n)=>{!t&&n&&e.requestComplete()},a),this._ownHandlesKey))}};e([i()],p.prototype,"_interactiveHandle",void 0),e([i()],p.prototype,"completeOnDragEnd",void 0),e([i()],p.prototype,"helpMessageKey",null),p=e([s("esri.views.draw.plugins.FreehandSegmentPlugin")],p);export{p as FreehandSegmentPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{subclass as
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t,subclass as o}from"../../../core/accessorSupport/decorators.js";import{isPoint as r}from"../../../geometry/support/typeUtils.js";import{PluginBase as n}from"./PluginBase.js";let s=class extends n{get helpMessageKey(){return"multipoint"}start(e){super.start(e),e.session.appendOrReplacePart(null,[])}beforeAttachPlugin(e){return{useStandaloneSession:!0,geometryType:"point"}}detachPlugin(e,t){if("complete"!==t)return;const o=this._context?.getSession(e),n=this._session,s=o?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"point"});s&&r(s)&&n&&(n.appendOrReplacePoint(null,s),n.appendOrReplacePart(null,[]),n.automaticRestart=!1,n.groupGeometryChanges()),e.configuration&&this._context?.requestBeginDownstreamPlugin(e.configuration)}};e([t()],s.prototype,"helpMessageKey",null),s=e([o("esri.views.draw.plugins.MultipointPlugin")],s);export{s as MultipointPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{watch as t,sync as s}from"../../../core/reactiveUtils.js";import{property as i,subclass as r}from"../../../core/accessorSupport/decorators.js";import{PluginBase as a}from"./PluginBase.js";const o=Symbol("primary-vertex");let n=class extends a{start(e){super.start(e);const{session:i,positionOfLastUserInput:r}=e;r&&i.appendOrReplacePoint(o,r),this._interactiveHandle||(this._interactiveHandle=e.createInteractiveHandle({defaultCaptureMode:"capture-always"}),this.addHandles([t(()=>this._interactiveHandle?.outputMapPosition,e=>{e&&!this._isComplete&&this._session?.appendOrReplacePoint(o,e)},s)],this._ownHandlesKey))}};e([i()],n.prototype,"_interactiveHandle",void 0),n=e([r("esri.views.draw.plugins.PointPlugin")],n);export{n as PointPlugin};
|
|
2
|
+
import{__decorate as e}from"tslib";import{watch as t,sync as s}from"../../../core/reactiveUtils.js";import{property as i,subclass as r}from"../../../core/accessorSupport/decorators.js";import{PluginBase as a}from"./PluginBase.js";const o=Symbol("primary-vertex");let n=class extends a{constructor(){super(...arguments),this.enableHelpMessages=!1}get helpMessageKey(){return this.enableHelpMessages?"point":null}start(e){super.start(e);const{session:i,positionOfLastUserInput:r}=e;r&&i.appendOrReplacePoint(o,r),this._interactiveHandle||(this._interactiveHandle=e.createInteractiveHandle({defaultCaptureMode:"capture-always"}),this.addHandles([t(()=>this._interactiveHandle?.outputMapPosition,e=>{e&&!this._isComplete&&this._session?.appendOrReplacePoint(o,e)},s)],this._ownHandlesKey))}};e([i()],n.prototype,"enableHelpMessages",void 0),e([i()],n.prototype,"helpMessageKey",null),e([i()],n.prototype,"_interactiveHandle",void 0),n=e([r("esri.views.draw.plugins.PointPlugin")],n);export{n as PointPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{watch as e,initial as o}from"../../../core/reactiveUtils.js";import{property as n,subclass as i}from"../../../core/accessorSupport/decorators.js";import s from"../../../geometry/Polyline.js";import{isPolygon as r}from"../../../geometry/support/typeUtils.js";import{getPaths as
|
|
2
|
+
import{__decorate as t}from"tslib";import{watch as e,initial as o}from"../../../core/reactiveUtils.js";import{property as n,subclass as i}from"../../../core/accessorSupport/decorators.js";import s from"../../../geometry/Polyline.js";import{isPolygon as r}from"../../../geometry/support/typeUtils.js";import{getPaths as l}from"../../../geometry/support/curves/curveUtils.js";import{pointEquals as a}from"../../../layers/graphics/dehydratedFeatureComparison.js";import{PolylinePlugin as d}from"./PolylinePlugin.js";import{knownFieldDisplayOrders as p}from"../support/types.js";import{screenDistance as u}from"../../interactive/snapping/snappingUtils.js";const c=5,m=Symbol("polygon-snap-to-close-constraint"),y=Symbol("polygon-area-measurement"),g=Symbol("polygon-area-field");let f=class extends d{constructor(){super(...arguments),this._autoCloseLineVisualId=Symbol("polygon-auto-close-on-commit"),this._defaultClosingLineVisualId=Symbol("polygon-default-close-on-cancel"),this.clickToCloseEnabled=!0}get _totalPreviewGeometry(){const{_session:t}=this;if(!t)return null;const e=t.lastPointAddedBySession?.partIndex,o=this._downstreamEditSession?.lastPointAddedBySession?.partIndex,n=e??o;if(!t||null==n)return null;const i=t?.getInformationAboutPoint(0,n),s=t?.getInformationAboutPoint(-1,n);return t?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"polygon",firstIncludedPoint:i,lastIncludedPoint:s})}get helpMessageKey(){const t=this._session?.lastPointAddedBySession;return t?null!=t.pointIndex&&t.pointIndex>0?"polygonTwoVertices":"polygonOneVertex":"polygonZeroVertices"}get test(){const{_autoCloseLineVisualId:t,_defaultClosingLineVisualId:e}=this;return{_autoCloseLineVisualId:t,_defaultClosingLineVisualId:e}}start(t){super.start(t),t.createConstraint(m,(t,e)=>this._snapToClosingVertex(t,e)),t.addOrUpdateVisual(this._autoCloseLineVisualId,{role:"outline",state:"active"}),t.addOrUpdateVisual(this._defaultClosingLineVisualId,{role:"outline",state:"idle"}),this.addHandles([e(()=>this._downstreamEditSession?.lastPointAddedBySession,t=>{if(!t||null==t.pointIndex)return this._context?.addOrUpdateVisual(this._autoCloseLineVisualId,{geometry:null}),void this._context?.addOrUpdateVisual(this._defaultClosingLineVisualId,{geometry:null});const e=this._session?.getInformationAboutPoint(t.pointIndex-1,t.partIndex),o=this._session?.getInformationAboutPoint(0,t.partIndex);if(t.point&&o?.point){const e=[t.point.x,t.point.y],n=[o.point.x,o.point.y],i=new s({spatialReference:t.point.spatialReference,paths:[[e,n]]});this._context?.addOrUpdateVisual(this._autoCloseLineVisualId,{geometry:i})}else this._context?.addOrUpdateVisual(this._autoCloseLineVisualId,{geometry:null});if(e?.point&&o?.point){const t=[e.point.x,e.point.y],n=[o.point.x,o.point.y],i=new s({spatialReference:o.point.spatialReference,paths:[[t,n]]});this._context?.addOrUpdateVisual(this._defaultClosingLineVisualId,{geometry:i})}else this._context?.addOrUpdateVisual(this._defaultClosingLineVisualId,{geometry:null})},o)],this._ownHandlesKey)}detachPlugin(t,e){const{_session:o}=this,n=o?.lastPointAddedBySession;if(!n||null==n.pointIndex)return;"complete"===e&&this._context?.setGlobalState("drawAtFixedElevation",!0);const i=o.getInformationAboutPoint(0,n.partIndex),s=o.getInformationAboutPoint(n.pointIndex-1,n.partIndex);if("complete"===e&&this.clickToCloseEnabled&&(n.pointIndex>2||2===n.pointIndex&&n.curveInfo)&&(a(i?.point,n.point)||a(s?.point,n.point))){!n.curveInfo&&o?.eraseLastOperation(),this._context?.requestComplete()}else"complete"===e&&this._context?.requestBeginDownstreamPlugin(t.configuration,{cancelExisting:!1})}afterUndoRedo(){const t=this._session?.lastPointAddedBySession;this._context?.setGlobalState("drawAtFixedElevation",!!t||void 0)}_getCommittedGeometry(){return this._session?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"polygon"})}_setupGeometrySpecificTooltip(){this._context&&(this._areaField??=this._context.createMeasuredField({id:g,preset:"area",getMeasurementInput:()=>this._totalPreviewGeometry,measure:async(t,e)=>{if(!t||!r(t))return null;const o=l(t)?.at(-1);if(!o||o.length<2||!t.curveRings&&o.length<3)return null;const n=e.inputUnitInfos.area.unit;return this._context?.measureArea(t,y,"tooltip",n)},fieldProperties:{readOnly:!0,displayOrder:p.ShapeMeasurements}}))}_snapToClosingVertex(t,e){const{_session:o}=this;if("primary"!==e.handle.role||!o)return t;if(!o?.sessionIsOperatingOnSameGeometry(e.editSession))return t;const n=e.editSession?.lastPointAddedBySession;if(!n||null==n.pointIndex||n.pointIndex<2)return t;const i=o.getInformationAboutPoint(0,n.partIndex);if(!t||!i?.point)return t;const s=e.toScreen(t);if(!s)return t;const r=e.toScreen(i.point);if(!r)return t;if(u(s,r)<=c)return i.point;const l=o.getInformationAboutPoint(n.pointIndex-1,n.partIndex);if(!l?.point)return t;const a=e.toScreen(l.point);return a&&u(s,a)<=c?l.point:t}};t([n()],f.prototype,"_areaField",void 0),t([n()],f.prototype,"_totalPreviewGeometry",null),t([n()],f.prototype,"clickToCloseEnabled",void 0),t([n()],f.prototype,"helpMessageKey",null),f=t([i("esri.views.draw.plugins.PolygonPlugin")],f);export{f as PolygonPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{zeroDegreesGeographic as t,createLength as i}from"../../../core/quantity.js";import{watch as o,initial as s}from"../../../core/reactiveUtils.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{isPolyline as l}from"../../../geometry/support/typeUtils.js";import{PluginBase as a}from"./PluginBase.js";import{knownFieldDisplayOrders as d}from"../support/types.js";import{directionForVertices as p}from"../../support/angularMeasurementUtils.js";const m=Symbol("polyline-committed-length-measurement"),u=Symbol("polyline-staged-measurement"),c=Symbol("polyline-cursor-distance-measurement"),h=Symbol("polyline-distance-field"),_=Symbol("polyline-direction-field"),y=Symbol("polyline-total-length-field");let g=class extends a{constructor(){super(...arguments),this._lineVisualId=Symbol()}get _downstreamGeometry(){return this._downstreamEditSession?.generatePreviewGeometry({includeAutomaticConnection:!0,geometryType:"polyline"})}get _downstreamEditSession(){const{_downstreamPlugin:e,_context:t}=this;return e?t?.getSession(e):null}get _committed(){return this._getCommittedGeometry()}start(e){super.start(e);const{session:t}=e;t.automaticRestart=!1,e.addOrUpdateVisual(this._lineVisualId,{role:"outline",state:"active"}),this.addHandles([o(()=>this._downstreamEditSession?.lastPointAddedBySession,t=>{this._cursorVertex=t;const i=this._downstreamGeometry,o=this._session;t&&o?(this._lastVertex=null!=t.pointIndex&&t.pointIndex>0?o.getInformationAboutPoint(t.pointIndex-1,t.partIndex):null,this._secondToLastVertex=null!=t.pointIndex&&t.pointIndex>1?o.getInformationAboutPoint(t.pointIndex-2,t.partIndex):null):(this._lastVertex=null,this._secondToLastVertex=null),e.addOrUpdateVisual(this._lineVisualId,{geometry:i})},s)],this._ownHandlesKey),this._setupTooltips()}complete(){this._session?.complete(),this._isComplete=!0,this.removeHandles(this._ownHandlesKey),this.removeHandles(this._downstreamHandlesKey)}attachPlugin(e){this._downstreamPlugin=e,this.notifyChange("_downstreamEditSession")}detachPlugin(e,t){this.notifyChange("_committed"),"complete"===t&&e.configuration&&this._context?.requestBeginDownstreamPlugin(e.configuration)}_getCommittedGeometry(){return this._session?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"polyline"})}_setupTooltips(){this._context&&(this._distanceField??=this._context.createMeasuredField({id:h,preset:"distance",getMeasurementInput:()=>[this._lastVertex?.point,this._cursorVertex?.point],measure:async(e,t)=>{if(!e||!e[0]||!e[1])return null;const i=t.inputUnitInfos.length.unit;return this._context?.measureDistance([e[0],e[1]],c,"tooltip",i)},fieldProperties:{displayOrder:d.Coordinates+11},fieldFilters:{appliesToHandlesWithRole:"primary"}}),this._directionField??=this._context.createMeasuredField({id:_,preset:"direction",getMeasurementInput:()=>[this._lastVertex?.point,this._cursorVertex?.point],measure:async([e,i],o)=>{const s=o.sketchOptions.values.effectiveDirectionMode;if(e&&i){const o=p(this._secondToLastVertex?.point,e,i,s);return this._directionField&&(this._directionField.readOnly="absolute"===s?!e:!this._secondToLastVertex?.point),o??("absolute"===s||this._secondToLastVertex?t:null)}return null},fieldProperties:{displayOrder:d.Coordinates+10},fieldFilters:{appliesToHandlesWithRole:"primary"}}),this._setupGeometrySpecificTooltip())}_setupGeometrySpecificTooltip(){this._context&&(this._lengthField??=this._context.createMeasuredField({id:y,preset:"totalLength",getMeasurementInput:()=>[this._committed,this._downstreamGeometry],measure:async([e,t],o,s)=>{const n=o.inputUnitInfos.length.unit,r=t&&l(t)?await(this._context?.measureLength(t,u,"tooltip",n)):void 0,a=e&&e!==s?.[0]&&l(e)?await(this._context?.measureLength(e,m,"tooltip",n)):e?this._cachedCommittedLength:null;return this._cachedCommittedLength=a,(a||r)&&(e||0!==r?.value)?i((a?.value??0)+(r?.value??0),n):null},fieldProperties:{displayOrder:d.ShapeMeasurements}}))}};e([n()],g.prototype,"_downstreamPlugin",void 0),e([n()],g.prototype,"_lastVertex",void 0),e([n()],g.prototype,"_cursorVertex",void 0),e([n()],g.prototype,"_secondToLastVertex",void 0),e([n()],g.prototype,"_lengthField",void 0),e([n()],g.prototype,"_distanceField",void 0),e([n()],g.prototype,"_directionField",void 0),e([n()],g.prototype,"_downstreamGeometry",null),e([n()],g.prototype,"_downstreamEditSession",null),e([n()],g.prototype,"_committed",null),g=e([r("esri.views.draw.plugins.PolylinePlugin")],g);export{g as PolylinePlugin};
|
|
2
|
+
import{__decorate as e}from"tslib";import{zeroDegreesGeographic as t,createLength as i}from"../../../core/quantity.js";import{watch as o,initial as s}from"../../../core/reactiveUtils.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{isPolyline as l}from"../../../geometry/support/typeUtils.js";import{PluginBase as a}from"./PluginBase.js";import{knownFieldDisplayOrders as d}from"../support/types.js";import{directionForVertices as p}from"../../support/angularMeasurementUtils.js";const m=Symbol("polyline-committed-length-measurement"),u=Symbol("polyline-staged-measurement"),c=Symbol("polyline-cursor-distance-measurement"),h=Symbol("polyline-distance-field"),_=Symbol("polyline-direction-field"),y=Symbol("polyline-total-length-field");let g=class extends a{constructor(){super(...arguments),this._lineVisualId=Symbol()}get _downstreamGeometry(){return this._downstreamEditSession?.generatePreviewGeometry({includeAutomaticConnection:!0,geometryType:"polyline"})}get _downstreamEditSession(){const{_downstreamPlugin:e,_context:t}=this;return e?t?.getSession(e):null}get _committed(){return this._getCommittedGeometry()}get helpMessageKey(){return this._session?.lastPointAddedBySession?"polylineOneVertex":"polylineZeroVertices"}start(e){super.start(e);const{session:t}=e;t.automaticRestart=!1,e.addOrUpdateVisual(this._lineVisualId,{role:"outline",state:"active"}),this.addHandles([o(()=>this._downstreamEditSession?.lastPointAddedBySession,t=>{this._cursorVertex=t;const i=this._downstreamGeometry,o=this._session;t&&o?(this._lastVertex=null!=t.pointIndex&&t.pointIndex>0?o.getInformationAboutPoint(t.pointIndex-1,t.partIndex):null,this._secondToLastVertex=null!=t.pointIndex&&t.pointIndex>1?o.getInformationAboutPoint(t.pointIndex-2,t.partIndex):null):(this._lastVertex=null,this._secondToLastVertex=null),e.addOrUpdateVisual(this._lineVisualId,{geometry:i})},s)],this._ownHandlesKey),this._setupTooltips()}complete(){this._session?.complete(),this._isComplete=!0,this.removeHandles(this._ownHandlesKey),this.removeHandles(this._downstreamHandlesKey)}attachPlugin(e){this._downstreamPlugin=e,this.notifyChange("_downstreamEditSession")}detachPlugin(e,t){this.notifyChange("_committed"),"complete"===t&&e.configuration&&this._context?.requestBeginDownstreamPlugin(e.configuration)}_getCommittedGeometry(){return this._session?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"polyline"})}_setupTooltips(){this._context&&(this._distanceField??=this._context.createMeasuredField({id:h,preset:"distance",getMeasurementInput:()=>[this._lastVertex?.point,this._cursorVertex?.point],measure:async(e,t)=>{if(!e||!e[0]||!e[1])return null;const i=t.inputUnitInfos.length.unit;return this._context?.measureDistance([e[0],e[1]],c,"tooltip",i)},fieldProperties:{displayOrder:d.Coordinates+11},fieldFilters:{appliesToHandlesWithRole:"primary"}}),this._directionField??=this._context.createMeasuredField({id:_,preset:"direction",getMeasurementInput:()=>[this._lastVertex?.point,this._cursorVertex?.point],measure:async([e,i],o)=>{const s=o.sketchOptions.values.effectiveDirectionMode;if(e&&i){const o=p(this._secondToLastVertex?.point,e,i,s);return this._directionField&&(this._directionField.readOnly="absolute"===s?!e:!this._secondToLastVertex?.point),o??("absolute"===s||this._secondToLastVertex?t:null)}return null},fieldProperties:{displayOrder:d.Coordinates+10},fieldFilters:{appliesToHandlesWithRole:"primary"}}),this._setupGeometrySpecificTooltip())}_setupGeometrySpecificTooltip(){this._context&&(this._lengthField??=this._context.createMeasuredField({id:y,preset:"totalLength",getMeasurementInput:()=>[this._committed,this._downstreamGeometry],measure:async([e,t],o,s)=>{const n=o.inputUnitInfos.length.unit,r=t&&l(t)?await(this._context?.measureLength(t,u,"tooltip",n)):void 0,a=e&&e!==s?.[0]&&l(e)?await(this._context?.measureLength(e,m,"tooltip",n)):e?this._cachedCommittedLength:null;return this._cachedCommittedLength=a,(a||r)&&(e||0!==r?.value)?i((a?.value??0)+(r?.value??0),n):null},fieldProperties:{displayOrder:d.ShapeMeasurements}}))}};e([n()],g.prototype,"_downstreamPlugin",void 0),e([n()],g.prototype,"_lastVertex",void 0),e([n()],g.prototype,"_cursorVertex",void 0),e([n()],g.prototype,"_secondToLastVertex",void 0),e([n()],g.prototype,"_lengthField",void 0),e([n()],g.prototype,"_distanceField",void 0),e([n()],g.prototype,"_directionField",void 0),e([n()],g.prototype,"_downstreamGeometry",null),e([n()],g.prototype,"_downstreamEditSession",null),e([n()],g.prototype,"_committed",null),e([n()],g.prototype,"helpMessageKey",null),g=e([r("esri.views.draw.plugins.PolylinePlugin")],g);export{g as PolylinePlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{watch as t,syncAndInitial as i,sync as s}from"../../../core/reactiveUtils.js";import{property as r,subclass as a}from"../../../core/accessorSupport/decorators.js";import{PluginBase as n}from"./PluginBase.js";import{createSquare as o,createCircle as l,createEllipse as d,createRectangle as p}from"../support/createUtils.js";import{knownFieldDisplayOrders as
|
|
2
|
+
import{__decorate as e}from"tslib";import{watch as t,syncAndInitial as i,sync as s}from"../../../core/reactiveUtils.js";import{property as r,subclass as a}from"../../../core/accessorSupport/decorators.js";import{PluginBase as n}from"./PluginBase.js";import{createSquare as o,createCircle as l,createEllipse as d,createRectangle as p}from"../support/createUtils.js";import{knownFieldDisplayOrders as h}from"../support/types.js";const u=Symbol("own-shape"),c=Symbol("shape-area-measurement"),m=Symbol("shape-size-measurement-x"),f=Symbol("shape-size-measurement-y"),y=Symbol("shape-area-field"),g=Symbol("shape-x-size-field"),_=Symbol("shape-y-size-field"),S=Symbol("shape-radius-field");let v=class extends n{constructor(){super(...arguments),this.shapeType="rectangle",this.defaultCentered=!1,this.defaultUniform=!1}get _globalModifierState(){return this._context?.getGlobalState()}get helpMessageKey(){return this._interactiveHandle?.dragging?"shapeEndHybrid":"shapeStartHybrid"}get effectiveUniform(){return this.defaultUniform!==!!this._globalModifierState?.preserveAspectRatio}get effectiveCentered(){return this.defaultCentered!==this._globalModifierState?.centered}set shapeResult(e){this._set("shapeResult",e),e?"center"in e?(this._radiusField?.show(),this._xSizeField?.hide(),this._ySizeField?.hide(),this._areaField?.show()):"midpoints"in e&&e.midpoints&&(this._radiusField?.hide(),this._xSizeField?.show(),this._ySizeField?.show(),this._areaField?.show()):(this._xSizeField?.hide(),this._ySizeField?.hide(),this._radiusField?.hide(),this._areaField?.hide());const t=e?.geometry,i=this._session;if(i&&t){const e=t.curveRings??t.rings,s=e?.at(0);s&&i.appendOrReplacePart(u,s)}}start(e){super.start(e),this._interactiveHandle??=e.createInteractiveHandle({defaultCaptureMode:"capture-when-engaged",selfSnappingEnabled:!1},{disableDefaultXYFields:!0}),this.addHandles([t(()=>[this._interactiveHandle?.outputMapPosition,this.effectiveCentered,this.effectiveUniform],([e,t,i])=>{if(!e||this._isComplete)return;const s=this._interactiveHandle?.outputMapPositionOfDragStart??e,r=s===e?null:e;this.shapeResult=this._generateShape(s,r,t,i)},i),t(()=>this._interactiveHandle?.dragging,(t,i)=>{t&&e.setGlobalState("drawAtFixedElevation",!0),!t&&i&&"grabbable-object"!==this._interactiveHandle?.captureMode&&e.requestComplete()},s)],this._ownHandlesKey),this._areaField??=this._context?.createMeasuredField({id:y,preset:"area",getMeasurementInput:()=>this.shapeResult?.geometry,measure:async(e,t)=>{if(!e)return null;const i=t.inputUnitInfos.area.unit;return this._context?.measureArea(e,c,"tooltip",i)},fieldProperties:{displayOrder:h.ShapeMeasurements}});const r=Symbol("Size-group");this._xSizeField??=this._context?.createMeasuredField({id:g,preset:"generic-length",getMeasurementInput:()=>this.shapeResult,measure:async(e,t)=>e&&"midpoints"in e&&e.midpoints?this._context?.measureDistance([e.midpoints?.left,e.midpoints?.right],m,"tooltip",t.inputUnitInfos.length.unit):null,fieldProperties:{displayOrder:h.Middle+1,displayGroup:r,title:e=>e.messages.sketch.size,readOnly:!0}}),this._ySizeField??=this._context?.createMeasuredField({id:_,preset:"generic-length",getMeasurementInput:()=>this.shapeResult,measure:async(e,t)=>e&&"midpoints"in e&&e.midpoints?this._context?.measureDistance([e.midpoints?.bottom,e.midpoints?.top],f,"tooltip",t.inputUnitInfos.length.unit):null,fieldProperties:{displayOrder:h.Middle+2,displayGroup:r,title:e=>e.messages.sketch.size,readOnly:!0}}),this._radiusField??=this._context?.createMeasuredField({id:S,preset:"radius",getMeasurementInput:()=>this.shapeResult,measure:async(e,t)=>{if(e&&"center"in e&&null!=e.center)return this._context?.measureDistance([e.center,e.edge],f,"tooltip",t.inputUnitInfos.length.unit)},fieldProperties:{displayOrder:h.Middle+1,readOnly:!0}})}_generateShape(e,t,i,s){const{shapeType:r}=this,{resolution:a}=this._context?.getViewInformation()??{},n=this._context?.getViewAlignedSurfaceCoordinateSystem(e);if(!n||null==a)return null;const h=[e.x,e.y],u=t&&[t.x,t.y];if(!u){const e=[[h,n.makeMapPoint(h[0]+48*a,h[1])],n,!0];return"rectangle"===r?o(...e):l(...e,void 0)}const c=[[h,u],n,i];return s?"circle"===r?l(...c,void 0):o(...c):"circle"===r?d(...c):p(...c)}};e([r()],v.prototype,"_interactiveHandle",void 0),e([r()],v.prototype,"_areaField",void 0),e([r()],v.prototype,"_xSizeField",void 0),e([r()],v.prototype,"_ySizeField",void 0),e([r()],v.prototype,"_radiusField",void 0),e([r()],v.prototype,"_globalModifierState",null),e([r()],v.prototype,"shapeType",void 0),e([r()],v.prototype,"defaultCentered",void 0),e([r()],v.prototype,"defaultUniform",void 0),e([r()],v.prototype,"helpMessageKey",null),e([r()],v.prototype,"effectiveUniform",null),e([r()],v.prototype,"effectiveCentered",null),e([r()],v.prototype,"shapeResult",null),v=e([a("esri.views.draw.plugins.ShapePlugin")],v);export{v as ShapePlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import{createTask as o}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import{getOrCreateMapValue as n}from"../../../../core/MapUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import s from"../../../../core/ReactiveMap.js";import{watch as l,syncAndInitial as a,initial as p}from"../../../../core/reactiveUtils.js";import{property as d}from"../../../../core/accessorSupport/decorators.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../../../../core/support/UpdatingHandles.js";import{isLoaded as m,load as f}from"../../../../geometry/coordinateFormatter.js";import{absoluteHeightElevationInfo as h}from"../../../../support/elevationInfoUtils.js";import{ManagedTooltipField as g}from"../ManagedTooltipField.js";import{getConstraintContext as v}from"../../../interactive/sketch/constraintUtils.js";import{makeTooltip as y}from"../../../interactive/tooltip/tooltipCommonUtils.js";import{makeScalarField as _,makeOrientationField as F,makeAreaField as H,makeLengthField as T,makeRadiusField as I,makeTotalLengthField as w,makeSizeField as
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import{createTask as o}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import{getOrCreateMapValue as n}from"../../../../core/MapUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import s from"../../../../core/ReactiveMap.js";import{watch as l,syncAndInitial as a,initial as p}from"../../../../core/reactiveUtils.js";import{property as d}from"../../../../core/accessorSupport/decorators.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../../../../core/support/UpdatingHandles.js";import{isLoaded as m,load as f}from"../../../../geometry/coordinateFormatter.js";import{absoluteHeightElevationInfo as h}from"../../../../support/elevationInfoUtils.js";import{ManagedTooltipField as g}from"../ManagedTooltipField.js";import{getConstraintContext as v}from"../../../interactive/sketch/constraintUtils.js";import{makeTooltip as y}from"../../../interactive/tooltip/tooltipCommonUtils.js";import{makeScalarField as _,makeOrientationField as F,makeAreaField as H,makeLengthField as T,makeRadiusField as I,makeTotalLengthField as w,makeSizeField as x,makeScaleField as k,makeYField as M,makeXField as j,makeLongitudeField as A,makeLatitudeField as b,makeElevationField as E,makeDistanceField as C,makeDirectionField as O}from"../../../interactive/tooltip/fields/fields.js";import{TooltipField as L}from"../../../interactive/tooltip/fields/TooltipField.js";import{DynamicTooltipInfo as P}from"../../../interactive/tooltip/infos/DynamicTooltipInfo.js";let R=class extends e{constructor(t){super(t),this._pluginTooltipFieldRegistry=new s,this._updatingHandles=new u,this._coordinateFormatterLoadTask=null,this.constraintsEnabled=!0,this.keepTooltipAliveEvenWhenTooltipsAreNotEnabled=!1}initialize(){this.addHandles([l(()=>[this.effectiveEnabled,this.context?.view,this.context?.sketchOptions],([t,e,o])=>{const{context:i}=this;t&&e&&o?(this._tooltipInfo??=new P({sketchOptions:o,getAllFields:()=>this.allFields,getActiveHandle:()=>this.effectiveActiveHandle,getHelpMessageKey:()=>this.context?.getHelpMessageKey(),viewType:e.type}),this._tooltip||this._setupTooltip(i)):(this._tooltip=r(this._tooltip),this._tooltipInfo=r(this._tooltipInfo),this.inputModeHandle=null)},a)])}destroy(){this._tooltip=r(this._tooltip),this._tooltipInfo=r(this._tooltipInfo)}get context(){return this.getDependencies?.()}get focusedHandle(){return this.context?.getActiveHandle?.()}get effectiveActiveHandle(){return this._tooltip?.isInInputMode?this.inputModeHandle:this.focusedHandle}get updating(){return this._updatingHandles.updating}get tooltip(){return this._tooltip}get tooltipInfo(){return this._tooltipInfo}get elevationConstraint(){return this.getConstraints(this.focusedHandle)?.elevation}get allFields(){return Array.from(this._pluginTooltipFieldRegistry.values()).flatMap(t=>Array.from(t.values()))}get effectiveEnabled(){return this.context?.sketchOptions.tooltips.effectiveEnabled||this.keepTooltipAliveEvenWhenTooltipsAreNotEnabled}getConstraints(t){const{tooltipInfo:e,context:o}=this,{view:i,editGeometryOperations:n,elevationInfo:r,sketchOptions:s}=o??{},l=this.getLastScreenPosition?.();if(!(l&&i&&e&&n&&s))return null;const{coordinateHelper:a,spatialReference:p}=n.data,d=i.toMap(l);if(!d)return null;const c=v(d,i,p,r??h,a.hasZ(),s.values.effectiveDirectionMode),u=e.getConstraintFieldsForHandle(t),m={context:c};for(const f of u)switch(f.name){case"direction":case"distance":case"elevation":m[f.name]=f.committed;break;case"x":m[f.name]=D(f.committed),m.longitude=U(f.committed);break;case"y":m[f.name]=D(f.committed),m.latitude=U(f.committed)}return m}unlockOnVertexPlacement(){this.tooltipInfo?.allFields.forEach(t=>{t.unlockOnVertexPlacement&&(t.committed=null)})}unregisterPluginFields(t){const e=this._pluginTooltipFieldRegistry.get(t);e?.forEach(t=>t.destroy()),e?.clear(),this._pluginTooltipFieldRegistry.delete(t)}createMeasuredField(t,{id:e,preset:o,getMeasurementInput:i,measure:n,fieldProperties:r,fieldFilters:s}){const a=this._getOrCreateField(t,e,o,r,s);return a.registerMeasurement(i,n,()=>this.tooltipInfo?.renderContext),a.addHandles(l(()=>this.tooltipInfo?.isEffectiveVisibleField(a.field),t=>a.enabled=!!t,p)),a}createCustomField(t,{id:e,preset:o,fieldProperties:i,fieldFilters:n}){return this._getOrCreateField(t,e,o,i,n)}_setupTooltip(t){const e=this._tooltip=y(()=>({view:t.view,options:t.sketchOptions.tooltips,info:this.tooltipInfo}));e.addHandles([l(()=>this.focusedHandle,t=>{!t||e.isInInputMode&&null!=this.inputModeHandle||(this.inputModeHandle=t)},a),l(()=>this.focusedHandle?.screenPosition,t=>{t?(e.position=t,e.hidden=!1):e.hidden=!0},a),e.on("commit",()=>{this.context?.notifyTooltipsChanged()})]),this._coordinateFormatterLoadTask||m()||(this._coordinateFormatterLoadTask=o(()=>f()),this.addHandles(this._coordinateFormatterLoadTask),this._updatingHandles.addPromise(this._coordinateFormatterLoadTask.promise))}_getOrCreateField(t,e,o,i,r){const l=n(this._pluginTooltipFieldRegistry,t,()=>new s);if(l.has(e))return l.get(e);const a=new g({field:G(o,i),displayGroup:i?.displayGroup,...r});return l.set(e,a),a}};function U(t){return null!=t&&"unit"in t&&"rotationType"in t?t:null}function D(t){return null==t||"rotationType"in t?null:t}function G(t,e){const o=e?{...e}:{};switch(delete o.displayGroup,t){case"area":return H({...o,name:"area"});case"direction":return O({...o,name:"direction"});case"distance":return C({...o,name:"distance"});case"elevation":{const t=E({...o,name:"elevation"});return t.showAsZ=!0,t}case"latitude":return b({...o,name:"y"});case"longitude":return A({...o,name:"x"});case"x":return j({...o,name:"x"});case"y":return M({...o,name:"y"});case"orientation":return F({...o,name:"orientation"});case"scale":return k({...o,name:"scale"});case"size":return x({...o,name:"size"});case"totalLength":return w({...o,name:"totalLength"});case"radius":return I({...o,name:"radius"});case"generic-length":return T({...o,name:null});case"generic-area":return H({...o,name:null});case"generic-angle":return F({...o,name:null});case"generic-scalar":return _({...o,name:null});default:if(!o)throw new i("draw-tool:tooltips:invalid-field-config","Attempted to create a tooltip without a preset definition and without tooltip configuration.");return new L(o)}}t([d()],R.prototype,"_updatingHandles",void 0),t([d()],R.prototype,"_tooltip",void 0),t([d()],R.prototype,"_tooltipInfo",void 0),t([d()],R.prototype,"_coordinateFormatterLoadTask",void 0),t([d()],R.prototype,"getDependencies",void 0),t([d()],R.prototype,"getLastScreenPosition",void 0),t([d()],R.prototype,"context",null),t([d()],R.prototype,"inputModeHandle",void 0),t([d()],R.prototype,"focusedHandle",null),t([d()],R.prototype,"effectiveActiveHandle",null),t([d()],R.prototype,"updating",null),t([d()],R.prototype,"tooltip",null),t([d()],R.prototype,"tooltipInfo",null),t([d()],R.prototype,"constraintsEnabled",void 0),t([d()],R.prototype,"elevationConstraint",null),t([d()],R.prototype,"allFields",null),t([d()],R.prototype,"keepTooltipAliveEvenWhenTooltipsAreNotEnabled",void 0),t([d()],R.prototype,"effectiveEnabled",null),R=t([c("esri.views.draw.support.managers.TooltipManager")],R);export{R as TooltipManager};
|