@arcgis/core 4.28.0-next.20231002 → 4.28.0-rc.0
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/02120d192eafd7612475.js +1 -0
- package/assets/esri/core/workers/chunks/{4d967e98d229f18d61f5.js → 09e8babe75407c2e64c4.js} +1 -1
- package/assets/esri/core/workers/chunks/0beebbb0c6dad0e742d7.js +1 -0
- package/assets/esri/core/workers/chunks/0d8ca51043c7784aed96.js +1 -0
- package/assets/esri/core/workers/chunks/112e89da628bdea5355c.js +1 -0
- package/assets/esri/core/workers/chunks/{5e9edd06e624f385fa4b.js → 121a9e148509f2fe2210.js} +1 -1
- package/assets/esri/core/workers/chunks/1856d16d738f44f58084.js +1 -0
- package/assets/esri/core/workers/chunks/{0526d623d0b4c12929bd.js → 18ab9cc85a1a7988fdfd.js} +1 -1
- package/assets/esri/core/workers/chunks/{7c960a2694c4c3123acf.js → 1a36703ebe934749646e.js} +1 -1
- package/assets/esri/core/workers/chunks/24a0cf405195421c0d06.js +1 -0
- package/assets/esri/core/workers/chunks/24ff267cf253feac22de.js +1 -0
- package/assets/esri/core/workers/chunks/{3c8613596659801fd6ab.js → 29cab345819ec02ed60a.js} +1 -1
- package/assets/esri/core/workers/chunks/{169a61c6e128b8a16021.js → 2c560a075d9ef2069ed1.js} +1 -1
- package/assets/esri/core/workers/chunks/2f8e71dac98135bbc3e6.js +1 -0
- package/assets/esri/core/workers/chunks/341fb51b2165522963b3.js +1 -0
- package/assets/esri/core/workers/chunks/{ad8e0f82cb1feafa9e2f.js → 36ab90fb34b9716a9983.js} +1 -1
- package/assets/esri/core/workers/chunks/{2688213bbff536da7917.js → 3ea0b872436fce84b927.js} +1 -1
- package/assets/esri/core/workers/chunks/40633064c290dc2af9ea.js +1 -0
- package/assets/esri/core/workers/chunks/42ec4c80b0c2944cd65c.js +1 -0
- package/assets/esri/core/workers/chunks/44b870cb53ba68b17c32.js +1 -0
- package/assets/esri/core/workers/chunks/{8a7fa4e8b0d14da7c9eb.js → 4cc680fe4c9c39d2f853.js} +1 -1
- package/assets/esri/core/workers/chunks/{6730c9f0890191a95fdb.js → 4d81aa50d90f5701a343.js} +1 -1
- package/assets/esri/core/workers/chunks/4e0bf30da4281070e453.js +1 -0
- package/assets/esri/core/workers/chunks/4e6bf1efe3b0b474cbb4.js +1 -0
- package/assets/esri/core/workers/chunks/52cef7cd3aaaa4f45c94.js +1 -0
- package/assets/esri/core/workers/chunks/{4e04242e707c0eb3aa4a.js → 5a3ccc0a19ac8fa9e524.js} +1 -1
- package/assets/esri/core/workers/chunks/5e907ec0ee1565b5fbbc.js +1 -0
- package/assets/esri/core/workers/chunks/66ba749ab0a631bbfdec.js +1 -0
- package/assets/esri/core/workers/chunks/6b14d89d689a21014aec.js +1 -0
- package/assets/esri/core/workers/chunks/6b1856303d1562f05100.js +1 -0
- package/assets/esri/core/workers/chunks/{576269fd1f9049876aa1.js → 6b7b5544ed1f9a84623f.js} +1 -1
- package/assets/esri/core/workers/chunks/710a6268de62003af825.js +1 -0
- package/assets/esri/core/workers/chunks/77923afde29ae1ff10ca.js +1 -0
- package/assets/esri/core/workers/chunks/784ffd52315a4d55d683.js +1 -0
- package/assets/esri/core/workers/chunks/7cf7f2b991a7cbdad2ce.js +1 -0
- package/assets/esri/core/workers/chunks/{70dffbf49b0633b1a5f1.js → 8f3680fee85a05839489.js} +1 -1
- package/assets/esri/core/workers/chunks/97aecf210938015cc7a3.js +1 -0
- package/assets/esri/core/workers/chunks/{c7ebd5d431fb996bfcee.js → 9f8207c82a17508a87a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{557305b91f77569ce664.js → a01ffe03b1465c21b9e6.js} +1 -1
- package/assets/esri/core/workers/chunks/a298c9031962951e55a9.js +1 -0
- package/assets/esri/core/workers/chunks/{329669a9beda89b028dd.js → a5a7bbdd8298016535bc.js} +1 -1
- package/assets/esri/core/workers/chunks/a877a4826cd6a46ec99b.js +1 -0
- package/assets/esri/core/workers/chunks/ad38e456a7cee940a165.js +1 -0
- package/assets/esri/core/workers/chunks/adfbc168be8c49b51e1b.js +1 -0
- package/assets/esri/core/workers/chunks/b0526633a93ef69ec47b.js +1 -0
- package/assets/esri/core/workers/chunks/b99bc08a01e9250b0a31.js +1 -0
- package/assets/esri/core/workers/chunks/{36c4b4c3eca57417da2c.js → c260ad3434bb00ba64a7.js} +1 -1
- package/assets/esri/core/workers/chunks/{39922ce232338de076ae.js → c459c8d8630eb4b955b1.js} +1 -1
- package/assets/esri/core/workers/chunks/c92e75b79aff7b505b31.js +1 -0
- package/assets/esri/core/workers/chunks/ca85e88dad30b5f2956b.js +1 -0
- package/assets/esri/core/workers/chunks/{8e56d40691b6bf75d7cc.js → ce409944221a784ddb61.js} +1 -1
- package/assets/esri/core/workers/chunks/d13f75f233cf313e5a1d.js +1 -0
- package/assets/esri/core/workers/chunks/d60d5f006375f7fcc88c.js +1 -0
- package/assets/esri/core/workers/chunks/{77958089748dc31757cf.js → d6ded127949160103f69.js} +1 -1
- package/assets/esri/core/workers/chunks/d8c696da42f8f8919b83.js +1 -0
- package/assets/esri/core/workers/chunks/{304c81f6297ecba3a324.js → d95eed98316e59f8f35d.js} +1 -1
- package/assets/esri/core/workers/chunks/df7267892b6e0493e1d7.js +1 -0
- package/assets/esri/core/workers/chunks/{52dca349e1a45555954d.js → e52d5a48e83d8df36f92.js} +1 -1
- package/assets/esri/core/workers/chunks/e8688b6cc3b3c1010b43.js +1 -0
- package/assets/esri/core/workers/chunks/e8c7cc974420c0b92d0e.js +1 -0
- package/assets/esri/core/workers/chunks/{b7ef554b1213307499fc.js → e93442c6d92229f3a4b0.js} +1 -1
- package/assets/esri/core/workers/chunks/{ef5772ca1848d6d01b88.js → eda86faa708cfe4c9f9a.js} +1 -1
- package/assets/esri/core/workers/chunks/f2718e260f594537f7fd.js +1 -0
- package/assets/esri/core/workers/chunks/f6b7036114b1d754fdd9.js +1 -0
- package/assets/esri/core/workers/chunks/{c4631241dc777ca77aaa.js → f6c0680c535c5a3c73ee.js} +1 -1
- package/assets/esri/core/workers/chunks/{a0ea1d3e22d52b8a59a8.js → fa6103e3d4e857b0035b.js} +9 -9
- package/assets/esri/core/workers/chunks/fac3e57784d7f37053af.js +1 -0
- package/assets/esri/geometry/support/pe-wasm.wasm +0 -0
- package/assets/esri/t9n/common.json +1 -1
- package/assets/esri/t9n/common_ar.json +1 -1
- package/assets/esri/t9n/common_bg.json +1 -1
- package/assets/esri/t9n/common_bs.json +1 -1
- package/assets/esri/t9n/common_ca.json +1 -1
- package/assets/esri/t9n/common_cs.json +1 -1
- package/assets/esri/t9n/common_da.json +1 -1
- package/assets/esri/t9n/common_de.json +1 -1
- package/assets/esri/t9n/common_el.json +1 -1
- package/assets/esri/t9n/common_en.json +1 -1
- package/assets/esri/t9n/common_es.json +1 -1
- package/assets/esri/t9n/common_et.json +1 -1
- package/assets/esri/t9n/common_fi.json +1 -1
- package/assets/esri/t9n/common_fr.json +1 -1
- package/assets/esri/t9n/common_he.json +1 -1
- package/assets/esri/t9n/common_hr.json +1 -1
- package/assets/esri/t9n/common_hu.json +1 -1
- package/assets/esri/t9n/common_id.json +1 -1
- package/assets/esri/t9n/common_it.json +1 -1
- package/assets/esri/t9n/common_ja.json +1 -1
- package/assets/esri/t9n/common_ko.json +1 -1
- package/assets/esri/t9n/common_lt.json +1 -1
- package/assets/esri/t9n/common_lv.json +1 -1
- package/assets/esri/t9n/common_nb.json +1 -1
- package/assets/esri/t9n/common_nl.json +1 -1
- package/assets/esri/t9n/common_pl.json +1 -1
- package/assets/esri/t9n/common_pt-BR.json +1 -1
- package/assets/esri/t9n/common_pt-PT.json +1 -1
- package/assets/esri/t9n/common_ro.json +1 -1
- package/assets/esri/t9n/common_ru.json +1 -1
- package/assets/esri/t9n/common_sk.json +1 -1
- package/assets/esri/t9n/common_sl.json +1 -1
- package/assets/esri/t9n/common_sr.json +1 -1
- package/assets/esri/t9n/common_sv.json +1 -1
- package/assets/esri/t9n/common_th.json +1 -1
- package/assets/esri/t9n/common_tr.json +1 -1
- package/assets/esri/t9n/common_uk.json +1 -1
- package/assets/esri/t9n/common_vi.json +1 -1
- package/assets/esri/t9n/common_zh-CN.json +1 -1
- package/assets/esri/t9n/common_zh-HK.json +1 -1
- package/assets/esri/t9n/common_zh-TW.json +1 -1
- package/assets/esri/themes/base/widgets/_DirectionalPad.scss +2 -1
- package/assets/esri/themes/base/widgets/_FeatureForm.scss +0 -1
- 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/pe-wasm.js +1 -1
- package/config.js +1 -1
- package/core/pbf.js +1 -1
- package/geometry/support/WKIDUnitConversion.js +1 -1
- package/geometry/support/plane.js +1 -1
- package/interfaces.d.ts +37 -39
- package/kernel.js +1 -1
- package/layers/GroupLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/graphics/editingSupport.js +1 -1
- package/layers/graphics/sources/WFSSourceWorker.js +1 -1
- package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
- package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
- package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
- package/layers/mixins/OperationalLayer.js +1 -1
- package/layers/save/featureLayerUtils.js +1 -1
- package/layers/save/groupLayerUtils.js +5 -0
- package/layers/save/utils.js +1 -1
- package/layers/support/LayerLoadContext.js +5 -0
- package/layers/support/featureLayerUtils.js +1 -1
- package/layers/support/labelFormatUtils.js +1 -1
- package/layers/support/layersCreator.js +1 -1
- package/layers/support/versionUtils.js +1 -1
- package/networks/UtilityNetwork.js +1 -1
- package/package.json +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/portal/support/jsonContext.js +1 -1
- package/portal/support/layersLoader.js +1 -1
- package/portal/support/loadUtils.js +5 -0
- package/portal/support/portalItemUtils.js +1 -1
- package/portal/support/portalLayers.js +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/rest/print.js +1 -1
- package/support/basemapUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/PolygonSymbol3D.js +1 -1
- package/views/2d/engine/imagery/RasterBitmap.js +1 -1
- package/views/2d/engine/imagery/colorizer/shadedrelief.js +1 -1
- package/views/2d/engine/imagery/colorizer/stretch.js +1 -1
- package/views/2d/input/handlers/KeyPan.js +1 -1
- package/views/2d/input/handlers/KeyRotate.js +1 -1
- package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBFIndirect.js +1 -1
- package/views/3d/input/handlers/KeyboardNavigation.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
- package/views/3d/layers/i3s/featureEditing.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/draw/DrawGraphicTool.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/Box.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/input/VisibilityChange.js +5 -0
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/FeatureSnappingSourceInfo.js +5 -0
- package/views/interactive/snapping/SnappingContext.js +1 -1
- package/views/interactive/snapping/SnappingDragPipelineStep.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/snappingUtils.js +1 -1
- package/webdoc/support/saveUtils.js +1 -1
- package/webdoc/webdocSaveUtils.js +1 -1
- package/widgets/DirectionalPad/DirectionalPadViewModel.js +1 -1
- package/widgets/DirectionalPad/constants.js +1 -1
- package/widgets/DirectionalPad.js +1 -1
- package/widgets/Editor/Upload.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
- package/widgets/FeatureForm/featureFormUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/support/DatePicker.js +1 -1
- package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
- package/widgets/support/Selector2D/SelectionOperation2D.js +1 -1
- package/widgets/support/Selector2D.js +1 -1
- package/widgets/support/TimePicker.js +1 -1
- package/widgets/support/dateUtils.js +1 -1
- package/assets/esri/core/workers/chunks/027f8b57565c65fbccda.js +0 -1
- package/assets/esri/core/workers/chunks/048265fb5953350e3e33.js +0 -1
- package/assets/esri/core/workers/chunks/0b9cf14f8aafb76c578b.js +0 -1
- package/assets/esri/core/workers/chunks/0ebf58c927bfc4c9d4fe.js +0 -1
- package/assets/esri/core/workers/chunks/10fd951bd296b2beeeba.js +0 -1
- package/assets/esri/core/workers/chunks/1224475f3eefdfd59c76.js +0 -1
- package/assets/esri/core/workers/chunks/162b0220e24e9ba72655.js +0 -1
- package/assets/esri/core/workers/chunks/1e611cad53b745ee146f.js +0 -1
- package/assets/esri/core/workers/chunks/24b1bf1a5d80f43a6c9a.js +0 -1
- package/assets/esri/core/workers/chunks/29ed31fd4f9d5cf53686.js +0 -1
- package/assets/esri/core/workers/chunks/2b6d1c8e4ed759767827.js +0 -1
- package/assets/esri/core/workers/chunks/34b44b0fab88f838885c.js +0 -1
- package/assets/esri/core/workers/chunks/364f55294a1d7bf163d7.js +0 -1
- package/assets/esri/core/workers/chunks/3714ab435dd5ccf9e694.js +0 -1
- package/assets/esri/core/workers/chunks/3788009a5ece453011f3.js +0 -1
- package/assets/esri/core/workers/chunks/3aafe8160b3bfbaa6935.js +0 -1
- package/assets/esri/core/workers/chunks/41c002e4c42c581cda8d.js +0 -1
- package/assets/esri/core/workers/chunks/47be4c75dd6372b96fe4.js +0 -1
- package/assets/esri/core/workers/chunks/4e8d1e6051f6654a5e83.js +0 -1
- package/assets/esri/core/workers/chunks/53746e9976758630159b.js +0 -1
- package/assets/esri/core/workers/chunks/5449fdd69e12e5cbd12a.js +0 -1
- package/assets/esri/core/workers/chunks/57ce4ece0147afb0d43c.js +0 -1
- package/assets/esri/core/workers/chunks/5e83d21400a5dec05c81.js +0 -1
- package/assets/esri/core/workers/chunks/6047f4487dcd37cca98e.js +0 -1
- package/assets/esri/core/workers/chunks/6967d2b3721678b38774.js +0 -1
- package/assets/esri/core/workers/chunks/6ac5ca7de651e3d672a1.js +0 -1
- package/assets/esri/core/workers/chunks/6b7ee9164149428edb9e.js +0 -1
- package/assets/esri/core/workers/chunks/6c495077cc79e1898927.js +0 -1
- package/assets/esri/core/workers/chunks/6d43648d5326e01b4474.js +0 -1
- package/assets/esri/core/workers/chunks/74fb07de0f990d45af89.js +0 -1
- package/assets/esri/core/workers/chunks/8e9a52062ce059153a89.js +0 -1
- package/assets/esri/core/workers/chunks/919a57d372419785cd5e.js +0 -1
- package/assets/esri/core/workers/chunks/939f0a1a7d605e389e45.js +0 -1
- package/assets/esri/core/workers/chunks/9932f23ba6589df14a3d.js +0 -1
- package/assets/esri/core/workers/chunks/a25a38c9f338e0beffef.js +0 -1
- package/assets/esri/core/workers/chunks/a97581e584336b46ede7.js +0 -1
- package/assets/esri/core/workers/chunks/b1cb932cfadc4dc3f1e4.js +0 -1
- package/assets/esri/core/workers/chunks/be3fb6113b0b27b94537.js +0 -1
- package/assets/esri/core/workers/chunks/c37119f5692e19aa1ce2.js +0 -1
- package/assets/esri/core/workers/chunks/c685f16435d9861bbbd0.js +0 -1
- package/assets/esri/core/workers/chunks/d5dfc03673aec8aa57e2.js +0 -1
- package/assets/esri/core/workers/chunks/e6416a2684866d677b3e.js +0 -1
- package/assets/esri/core/workers/chunks/eb01f4cdb9b918cc61e7.js +0 -1
- package/assets/esri/core/workers/chunks/eb4aed4fdb44495a4fe6.js +0 -1
- package/assets/esri/core/workers/chunks/ec8258c9dc1491e97fc8.js +0 -1
- package/assets/esri/core/workers/chunks/eeac53da496de4cd4182.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{j as s}from"../../../../chunks/vec2.js";import{s as i,f as a,j as n,i as o,g as l,c as u,l as c,o as h,e as p}from"../../../../chunks/vec3.js";import{c as f}from"../../../../chunks/vec3f64.js";import{O as m}from"../../../../chunks/vec4f64.js";import{PlaneIndex as T}from"../../../../geometry/support/frustum.js";import{create as d,distance2 as _,fromPoints as E,closestLineSegmentPoint as A}from"../../../../geometry/support/lineSegment.js";import{create as R,fromPoints as I,signedDistance as S,normal as g}from"../../../../geometry/support/plane.js";import{newLayout as O}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as b}from"../core/shaderLibrary/ShaderOutput.js";import v from"../lib/GLMaterial.js";import{Material as L,RenderOccludedFlag as P}from"../lib/Material.js";import{RenderSlot as N}from"../lib/RenderSlot.js";import{isTranslationMatrix as C}from"../lib/Util.js";import{VertexAttribute as y}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as j}from"./VisualVariablePassParameters.js";import{LineMarkerAnchor as U}from"../shaders/LineMarkerTechniqueConfiguration.js";import{r as D}from"../../../../chunks/RibbonLine.glsl.js";import{vertexAttributeLocations as F,RibbonLineTechnique as w}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as B,CapType as J}from"../shaders/RibbonLineTechniqueConfiguration.js";var M;!function(e){e[e.LEFT_JOIN_START=-2]="LEFT_JOIN_START",e[e.LEFT_JOIN_END=-1]="LEFT_JOIN_END",e[e.LEFT_CAP_START=-4]="LEFT_CAP_START",e[e.LEFT_CAP_END=-5]="LEFT_CAP_END",e[e.RIGHT_JOIN_START=2]="RIGHT_JOIN_START",e[e.RIGHT_JOIN_END=1]="RIGHT_JOIN_END",e[e.RIGHT_CAP_START=4]="RIGHT_CAP_START",e[e.RIGHT_CAP_END=5]="RIGHT_CAP_END"}(M||(M={}));class x extends L{constructor(e){super(e,new z),this._configuration=new B,this._vertexAttributeLocations=F}getConfiguration(e,t){this._configuration.output=e,this._configuration.draped=t.slot===N.DRAPED_MATERIAL;const r=null!=this.parameters.stipplePattern&&e!==b.Highlight;return this._configuration.stippleEnabled=r,this._configuration.stippleOffColorEnabled=r&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=r&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasOccludees=this.parameters.hasOccludees,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&V(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.occluder=this.parameters.renderOccluded===P.OccludeAndTransparentStencil,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.multipassEnabled=t.multipassEnabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration.wireframe=this.parameters.wireframe,this._configuration}intersectDraped(e,r,s,i,a,n){if(!s.options.selectionMode)return;const o=e.attributes.get(y.POSITION).data,l=e.attributes.get(y.SIZE);let u=this.parameters.width;if(this.parameters.vvSize){const r=e.attributes.get(y.SIZEFEATUREATTRIBUTE).data[0];u*=t(this.parameters.vvSize.offset[0]+r*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else l&&(u*=l.data[0]);const c=i[0],h=i[1],p=(u/2+4)*e.screenToWorldRatio;let f=Number.MAX_VALUE,m=0;for(let T=0;T<o.length-5;T+=3){const e=o[T],r=o[T+1],s=c-e,i=h-r,a=o[T+3]-e,n=o[T+4]-r,l=t((a*s+n*i)/(a*a+n*n),0,1),u=a*l-s,p=n*l-i,d=u*u+p*p;d<f&&(f=d,m=T/3)}f<p*p&&a(n.dist,n.normal,m,!1)}intersect(r,p,f,m,d,R){if(!f.options.selectionMode||!r.visible)return;if(!C(p))return void e.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const O=r.attributes,b=O.get(y.POSITION).data;let v=this.parameters.width;if(this.parameters.vvSize){const e=O.get(y.SIZEFEATUREATTRIBUTE).data[0];v*=t(this.parameters.vvSize.offset[0]+e*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else O.has(y.SIZE)&&(v*=O.get(y.SIZE).data[0]);const L=f.camera,P=Q;s(P,f.point);const N=v*L.pixelRatio/2+4*L.pixelRatio;i(oe[0],P[0]-N,P[1]+N,0),i(oe[1],P[0]+N,P[1]+N,0),i(oe[2],P[0]+N,P[1]-N,0),i(oe[3],P[0]-N,P[1]-N,0);for(let e=0;e<4;e++)if(!L.unprojectFromRenderScreen(oe[e],le[e]))return;I(L.eye,le[0],le[1],ue),I(L.eye,le[1],le[2],ce),I(L.eye,le[2],le[3],he),I(L.eye,le[3],le[0],pe);let j=Number.MAX_VALUE,U=0;const D=Z(this.parameters,O)?b.length-2:b.length-5;for(let e=0;e<D;e+=3){W[0]=b[e]+p[12],W[1]=b[e+1]+p[13],W[2]=b[e+2]+p[14];const t=(e+3)%b.length;if(Y[0]=b[t]+p[12],Y[1]=b[t+1]+p[13],Y[2]=b[t+2]+p[14],S(ue,W)<0&&S(ue,Y)<0||S(ce,W)<0&&S(ce,Y)<0||S(he,W)<0&&S(he,Y)<0||S(pe,W)<0&&S(pe,Y)<0)continue;if(L.projectToRenderScreen(W,K),L.projectToRenderScreen(Y,$),K[2]<0&&$[2]>0){a(X,W,Y);const e=L.frustum,t=-S(e[T.NEAR],W)/n(X,g(e[T.NEAR]));o(X,X,t),l(W,W,X),L.projectToRenderScreen(W,K)}else if(K[2]>0&&$[2]<0){a(X,Y,W);const e=L.frustum,t=-S(e[T.NEAR],Y)/n(X,g(e[T.NEAR]));o(X,X,t),l(Y,Y,X),L.projectToRenderScreen(Y,$)}else if(K[2]<0&&$[2]<0)continue;K[2]=0,$[2]=0;const r=_(E(K,$,re),P);r<j&&(j=r,u(ee,W),u(te,Y),U=e/3)}const F=f.rayBegin,w=f.rayEnd;if(j<N*N){let e=Number.MAX_VALUE;if(A(E(ee,te,re),E(F,w,se),q)){a(q,q,F);const t=c(q);o(q,q,1/t),e=t/h(F,w)}R(e,q,U,!1)}}get _layout(){const e=O().vec3f(y.POSITION).f32(y.SUBDIVISIONFACTOR).vec2f(y.UV0).vec3f(y.AUXPOS1).vec3f(y.AUXPOS2);return this.parameters.vvSize?e.f32(y.SIZEFEATUREATTRIBUTE):e.f32(y.SIZE),this.parameters.vvColor?e.f32(y.COLORFEATUREATTRIBUTE):e.vec4f(y.COLOR),this.parameters.vvOpacity&&e.f32(y.OPACITYFEATUREATTRIBUTE),has("enable-feature:objectAndLayerId-rendering")&&e.vec4u8(y.OBJECTANDLAYERIDCOLOR),e}createBufferWriter(){return new H(this._layout,this.parameters)}produces(e,t){if(t===b.Color||t===b.Alpha||t===b.Highlight||t===b.Depth||t===b.ObjectAndLayerIdColor){if(e===N.DRAPED_MATERIAL)return!0;if(this.parameters.renderOccluded===P.OccludeAndTransparentStencil)return e===N.OPAQUE_MATERIAL||e===N.OCCLUDER_MATERIAL||e===N.TRANSPARENT_OCCLUDER_MATERIAL;if(t===b.Color||t===b.Alpha){return e===(this.parameters.writeDepth?N.TRANSPARENT_MATERIAL:N.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL)}return e===N.OPAQUE_MATERIAL}return!1}createGLMaterial(e){return new G(e)}validateParameters(e){"miter"!==e.join&&(e.miterLimit=0),null!=e.markerParameters&&(e.markerScale=e.markerParameters.width/e.width)}}class G extends v{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextureRepository.release(this._stipplePattern),this._stipplePattern=null}_updateOccludeeState(e){e.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:e.hasOccludees})}beginSlot(e){this._output!==b.Color&&this._output!==b.Alpha||this._updateOccludeeState(e);const t=this._material.parameters.stipplePattern;return this._stipplePattern!==t&&(this._material.setParameters({stippleTexture:this._stippleTextureRepository.swap(t,this._stipplePattern)}),this._stipplePattern=t),this.ensureTechnique(w,e)}}class z extends j{constructor(){super(...arguments),this.width=0,this.color=m,this.join="miter",this.cap=J.BUTT,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.hasOccludees=!1,this.wireframe=!1}}class H{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t,this.numJoinSubdivisions=0;const r=t.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=r;break;case"round":this.numJoinSubdivisions=D+r}}_isClosed(e){return Z(this._parameters,e.attributes)}allocate(e){return this.vertexBufferLayout.createBuffer(e)}elementCount(e){const t=2,r=e.attributes.get(y.POSITION).indices.length/2+1,s=this._isClosed(e);let i=s?2:2*t;return i+=((s?r:r-1)-(s?0:1))*(2*this.numJoinSubdivisions+4),i+=2,this._parameters.wireframe&&(i=2+4*(i-2)),i}write(e,t,r,s,a){const n=ie,o=ae,l=ne,c=r.attributes.get(y.POSITION),f=c.indices,m=c.data.length/3,T=r.attributes.get(y.DISTANCETOSTART)?.data;f&&f.length!==2*(m-1)&&console.warn("RibbonLineMaterial does not support indices");let d=1,_=0;const E=this.vertexBufferLayout.fields.has(y.SIZEFEATUREATTRIBUTE);E?_=r.attributes.get(y.SIZEFEATUREATTRIBUTE).data[0]:r.attributes.has(y.SIZE)&&(d=r.attributes.get(y.SIZE).data[0]);let A=[1,1,1,1],R=0;const I=this.vertexBufferLayout.fields.has(y.COLORFEATUREATTRIBUTE);I?R=r.attributes.get(y.COLORFEATUREATTRIBUTE).data[0]:r.attributes.has(y.COLOR)&&(A=r.attributes.get(y.COLOR).data);const S=has("enable-feature:objectAndLayerId-rendering")?r.objectAndLayerIdColor:null;let g=0;const O=this.vertexBufferLayout.fields.has(y.OPACITYFEATUREATTRIBUTE);O&&(g=r.attributes.get(y.OPACITYFEATUREATTRIBUTE).data[0]);const b=new Float32Array(s.buffer),v=has("enable-feature:objectAndLayerId-rendering")?new Uint8Array(s.buffer):null,L=this.vertexBufferLayout.stride/4;let P=a*L;const N=P;let C=0;const j=T?(e,t,r)=>C=T[r]:(e,t,r)=>C+=h(e,t),U=has("enable-feature:objectAndLayerId-rendering"),D=(e,t,r,s,i,a,n)=>{if(b[P++]=t[0],b[P++]=t[1],b[P++]=t[2],b[P++]=s,b[P++]=n,b[P++]=i,b[P++]=e[0],b[P++]=e[1],b[P++]=e[2],b[P++]=r[0],b[P++]=r[1],b[P++]=r[2],b[P++]=E?_:d,I)b[P++]=R;else{const e=Math.min(4*a,A.length-4);b[P++]=A[e],b[P++]=A[e+1],b[P++]=A[e+2],b[P++]=A[e+3]}O&&(b[P++]=g),U&&(null!=S&&(v[4*P]=S[0],v[4*P+1]=S[1],v[4*P+2]=S[2],v[4*P+3]=S[3]),P++)};P+=L,i(o,c.data[0],c.data[1],c.data[2]),e&&p(o,o,e);const F=this._isClosed(r);if(F){const t=c.data.length-3;i(n,c.data[t],c.data[t+1],c.data[t+2]),e&&p(n,n,e)}else i(l,c.data[3],c.data[4],c.data[5]),e&&p(l,l,e),D(o,o,l,1,M.LEFT_CAP_START,0,0),D(o,o,l,1,M.RIGHT_CAP_START,0,0),u(n,o),u(o,l);const w=F?0:1,B=F?m:m-1;for(let h=w;h<B;h++){const t=(h+1)%m*3;i(l,c.data[t],c.data[t+1],c.data[t+2]),e&&p(l,l,e),j(n,o,h),D(n,o,l,0,M.LEFT_JOIN_END,h,C),D(n,o,l,0,M.RIGHT_JOIN_END,h,C);const r=this.numJoinSubdivisions;for(let e=0;e<r;++e){const t=(e+1)/(r+1);D(n,o,l,t,M.LEFT_JOIN_END,h,C),D(n,o,l,t,M.RIGHT_JOIN_END,h,C)}D(n,o,l,1,M.LEFT_JOIN_START,h,C),D(n,o,l,1,M.RIGHT_JOIN_START,h,C),u(n,o),u(o,l)}F?(i(l,c.data[3],c.data[4],c.data[5]),e&&p(l,l,e),C=j(n,o,B),D(n,o,l,0,M.LEFT_JOIN_END,w,C),D(n,o,l,0,M.RIGHT_JOIN_END,w,C)):(C=j(n,o,B),D(n,o,o,0,M.LEFT_CAP_END,B,C),D(n,o,o,0,M.RIGHT_CAP_END,B,C)),k(b,N+L,b,N,L);P=k(b,P-L,b,P,L),this._parameters.wireframe&&this._addWireframeVertices(s,N,P,L)}_addWireframeVertices(e,t,r,s){const i=new Float32Array(e.buffer,r*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(e.buffer,t*Float32Array.BYTES_PER_ELEMENT,r-t);let n=0;const o=e=>n=k(a,e,i,n,s);for(let l=0;l<a.length-1;l+=2*s)o(l),o(l+2*s),o(l+1*s),o(l+2*s),o(l+1*s),o(l+3*s)}}function k(e,t,r,s,i){for(let a=0;a<i;a++)r[s++]=e[t++];return s}function Z(e,t){if(!e.isClosed)return!1;return t.get(y.POSITION).indices.length>2}function V(e){return e.anchor===U.Tip&&e.hideOnShortSegments&&"begin-end"===e.placement&&e.worldSpace}const W=f(),Y=f(),X=f(),q=f(),Q=f(),K=r(),$=r(),ee=f(),te=f(),re=d(),se=d(),ie=f(),ae=f(),ne=f(),oe=[r(),r(),r(),r()],le=[f(),f(),f(),f()],ue=R(),ce=R(),he=R(),pe=R();export{z as Parameters,x as RibbonLineMaterial};
|
|
5
|
+
import has from"../../../../core/has.js";import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{j as s}from"../../../../chunks/vec2.js";import{s as i,f as a,j as n,i as o,g as l,c as u,l as c,o as h,e as p}from"../../../../chunks/vec3.js";import{c as f}from"../../../../chunks/vec3f64.js";import{O as m}from"../../../../chunks/vec4f64.js";import{PlaneIndex as T}from"../../../../geometry/support/frustum.js";import{create as d,distance2 as _,fromPoints as E,closestLineSegmentPoint as A}from"../../../../geometry/support/lineSegment.js";import{create as R,fromPoints as I,signedDistance as S,normal as g}from"../../../../geometry/support/plane.js";import{newLayout as O}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as b}from"../core/shaderLibrary/ShaderOutput.js";import v from"../lib/GLMaterial.js";import{Material as L,RenderOccludedFlag as P}from"../lib/Material.js";import{RenderSlot as N}from"../lib/RenderSlot.js";import{isTranslationMatrix as C}from"../lib/Util.js";import{VertexAttribute as y}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as j}from"./VisualVariablePassParameters.js";import{LineMarkerAnchor as U}from"../shaders/LineMarkerTechniqueConfiguration.js";import{r as D}from"../../../../chunks/RibbonLine.glsl.js";import{vertexAttributeLocations as F,RibbonLineTechnique as w}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as B,CapType as J}from"../shaders/RibbonLineTechniqueConfiguration.js";var M;!function(e){e[e.LEFT_JOIN_START=-2]="LEFT_JOIN_START",e[e.LEFT_JOIN_END=-1]="LEFT_JOIN_END",e[e.LEFT_CAP_START=-4]="LEFT_CAP_START",e[e.LEFT_CAP_END=-5]="LEFT_CAP_END",e[e.RIGHT_JOIN_START=2]="RIGHT_JOIN_START",e[e.RIGHT_JOIN_END=1]="RIGHT_JOIN_END",e[e.RIGHT_CAP_START=4]="RIGHT_CAP_START",e[e.RIGHT_CAP_END=5]="RIGHT_CAP_END"}(M||(M={}));class x extends L{constructor(e){super(e,new z),this._configuration=new B,this._vertexAttributeLocations=F}getConfiguration(e,t){this._configuration.output=e,this._configuration.draped=t.slot===N.DRAPED_MATERIAL;const r=null!=this.parameters.stipplePattern&&e!==b.Highlight;return this._configuration.stippleEnabled=r,this._configuration.stippleOffColorEnabled=r&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=r&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasOccludees=this.parameters.hasOccludees,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&V(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.occluder=this.parameters.renderOccluded===P.OccludeAndTransparentStencil,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.multipassEnabled=t.multipassEnabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration.wireframe=this.parameters.wireframe,this._configuration}intersectDraped(e,r,s,i,a,n){if(!s.options.selectionMode)return;const o=e.attributes.get(y.POSITION).data,l=e.attributes.get(y.SIZE);let u=this.parameters.width;if(this.parameters.vvSize){const r=e.attributes.get(y.SIZEFEATUREATTRIBUTE).data[0];u*=t(this.parameters.vvSize.offset[0]+r*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else l&&(u*=l.data[0]);const c=i[0],h=i[1],p=(u/2+4)*e.screenToWorldRatio;let f=Number.MAX_VALUE,m=0;for(let T=0;T<o.length-5;T+=3){const e=o[T],r=o[T+1],s=c-e,i=h-r,a=o[T+3]-e,n=o[T+4]-r,l=t((a*s+n*i)/(a*a+n*n),0,1),u=a*l-s,p=n*l-i,d=u*u+p*p;d<f&&(f=d,m=T/3)}f<p*p&&a(n.dist,n.normal,m,!1)}intersect(r,p,f,m,d,R){if(!f.options.selectionMode||!r.visible)return;if(!C(p))return void e.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const O=r.attributes,b=O.get(y.POSITION).data;let v=this.parameters.width;if(this.parameters.vvSize){const e=O.get(y.SIZEFEATUREATTRIBUTE).data[0];v*=t(this.parameters.vvSize.offset[0]+e*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else O.has(y.SIZE)&&(v*=O.get(y.SIZE).data[0]);const L=f.camera,P=Q;s(P,f.point);const N=v*L.pixelRatio/2+4*L.pixelRatio;i(oe[0],P[0]-N,P[1]+N,0),i(oe[1],P[0]+N,P[1]+N,0),i(oe[2],P[0]+N,P[1]-N,0),i(oe[3],P[0]-N,P[1]-N,0);for(let e=0;e<4;e++)if(!L.unprojectFromRenderScreen(oe[e],le[e]))return;I(L.eye,le[0],le[1],ue),I(L.eye,le[1],le[2],ce),I(L.eye,le[2],le[3],he),I(L.eye,le[3],le[0],pe);let j=Number.MAX_VALUE,U=0;const D=Z(this.parameters,O)?b.length-2:b.length-5;for(let e=0;e<D;e+=3){W[0]=b[e]+p[12],W[1]=b[e+1]+p[13],W[2]=b[e+2]+p[14];const t=(e+3)%b.length;if(Y[0]=b[t]+p[12],Y[1]=b[t+1]+p[13],Y[2]=b[t+2]+p[14],S(ue,W)<0&&S(ue,Y)<0||S(ce,W)<0&&S(ce,Y)<0||S(he,W)<0&&S(he,Y)<0||S(pe,W)<0&&S(pe,Y)<0)continue;if(L.projectToRenderScreen(W,K),L.projectToRenderScreen(Y,$),K[2]<0&&$[2]>0){a(X,W,Y);const e=L.frustum,t=-S(e[T.NEAR],W)/n(X,g(e[T.NEAR]));o(X,X,t),l(W,W,X),L.projectToRenderScreen(W,K)}else if(K[2]>0&&$[2]<0){a(X,Y,W);const e=L.frustum,t=-S(e[T.NEAR],Y)/n(X,g(e[T.NEAR]));o(X,X,t),l(Y,Y,X),L.projectToRenderScreen(Y,$)}else if(K[2]<0&&$[2]<0)continue;K[2]=0,$[2]=0;const r=_(E(K,$,re),P);r<j&&(j=r,u(ee,W),u(te,Y),U=e/3)}const F=f.rayBegin,w=f.rayEnd;if(j<N*N){let e=Number.MAX_VALUE;if(A(E(ee,te,re),E(F,w,se),q)){a(q,q,F);const t=c(q);o(q,q,1/t),e=t/h(F,w)}R(e,q,U,!1)}}get _layout(){const e=O().vec3f(y.POSITION).f32(y.SUBDIVISIONFACTOR).vec2f(y.UV0).vec3f(y.AUXPOS1).vec3f(y.AUXPOS2);return this.parameters.vvSize?e.f32(y.SIZEFEATUREATTRIBUTE):e.f32(y.SIZE),this.parameters.vvColor?e.f32(y.COLORFEATUREATTRIBUTE):e.vec4f(y.COLOR),this.parameters.vvOpacity&&e.f32(y.OPACITYFEATUREATTRIBUTE),has("enable-feature:objectAndLayerId-rendering")&&e.vec4u8(y.OBJECTANDLAYERIDCOLOR),e}createBufferWriter(){return new H(this._layout,this.parameters)}produces(e,t){if(t===b.Depth&&!this.parameters.writeLinearDepth)return!1;if(t===b.Color||t===b.Alpha||t===b.Highlight||t===b.Depth||t===b.ObjectAndLayerIdColor){if(e===N.DRAPED_MATERIAL)return!0;if(this.parameters.renderOccluded===P.OccludeAndTransparentStencil)return e===N.OPAQUE_MATERIAL||e===N.OCCLUDER_MATERIAL||e===N.TRANSPARENT_OCCLUDER_MATERIAL;if(t===b.Color||t===b.Alpha){return e===(this.parameters.writeDepth?N.TRANSPARENT_MATERIAL:N.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL)}return e===N.OPAQUE_MATERIAL}return!1}createGLMaterial(e){return new G(e)}validateParameters(e){"miter"!==e.join&&(e.miterLimit=0),null!=e.markerParameters&&(e.markerScale=e.markerParameters.width/e.width)}}class G extends v{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextureRepository.release(this._stipplePattern),this._stipplePattern=null}_updateOccludeeState(e){e.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:e.hasOccludees})}beginSlot(e){this._output!==b.Color&&this._output!==b.Alpha||this._updateOccludeeState(e);const t=this._material.parameters.stipplePattern;return this._stipplePattern!==t&&(this._material.setParameters({stippleTexture:this._stippleTextureRepository.swap(t,this._stipplePattern)}),this._stipplePattern=t),this.ensureTechnique(w,e)}}class z extends j{constructor(){super(...arguments),this.width=0,this.color=m,this.join="miter",this.cap=J.BUTT,this.miterLimit=5,this.writeDepth=!0,this.writeLinearDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.hasOccludees=!1,this.wireframe=!1}}class H{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t,this.numJoinSubdivisions=0;const r=t.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=r;break;case"round":this.numJoinSubdivisions=D+r}}_isClosed(e){return Z(this._parameters,e.attributes)}allocate(e){return this.vertexBufferLayout.createBuffer(e)}elementCount(e){const t=2,r=e.attributes.get(y.POSITION).indices.length/2+1,s=this._isClosed(e);let i=s?2:2*t;return i+=((s?r:r-1)-(s?0:1))*(2*this.numJoinSubdivisions+4),i+=2,this._parameters.wireframe&&(i=2+4*(i-2)),i}write(e,t,r,s,a){const n=ie,o=ae,l=ne,c=r.attributes.get(y.POSITION),f=c.indices,m=c.data.length/3,T=r.attributes.get(y.DISTANCETOSTART)?.data;f&&f.length!==2*(m-1)&&console.warn("RibbonLineMaterial does not support indices");let d=1,_=0;const E=this.vertexBufferLayout.fields.has(y.SIZEFEATUREATTRIBUTE);E?_=r.attributes.get(y.SIZEFEATUREATTRIBUTE).data[0]:r.attributes.has(y.SIZE)&&(d=r.attributes.get(y.SIZE).data[0]);let A=[1,1,1,1],R=0;const I=this.vertexBufferLayout.fields.has(y.COLORFEATUREATTRIBUTE);I?R=r.attributes.get(y.COLORFEATUREATTRIBUTE).data[0]:r.attributes.has(y.COLOR)&&(A=r.attributes.get(y.COLOR).data);const S=has("enable-feature:objectAndLayerId-rendering")?r.objectAndLayerIdColor:null;let g=0;const O=this.vertexBufferLayout.fields.has(y.OPACITYFEATUREATTRIBUTE);O&&(g=r.attributes.get(y.OPACITYFEATUREATTRIBUTE).data[0]);const b=new Float32Array(s.buffer),v=has("enable-feature:objectAndLayerId-rendering")?new Uint8Array(s.buffer):null,L=this.vertexBufferLayout.stride/4;let P=a*L;const N=P;let C=0;const j=T?(e,t,r)=>C=T[r]:(e,t,r)=>C+=h(e,t),U=has("enable-feature:objectAndLayerId-rendering"),D=(e,t,r,s,i,a,n)=>{if(b[P++]=t[0],b[P++]=t[1],b[P++]=t[2],b[P++]=s,b[P++]=n,b[P++]=i,b[P++]=e[0],b[P++]=e[1],b[P++]=e[2],b[P++]=r[0],b[P++]=r[1],b[P++]=r[2],b[P++]=E?_:d,I)b[P++]=R;else{const e=Math.min(4*a,A.length-4);b[P++]=A[e],b[P++]=A[e+1],b[P++]=A[e+2],b[P++]=A[e+3]}O&&(b[P++]=g),U&&(null!=S&&(v[4*P]=S[0],v[4*P+1]=S[1],v[4*P+2]=S[2],v[4*P+3]=S[3]),P++)};P+=L,i(o,c.data[0],c.data[1],c.data[2]),e&&p(o,o,e);const F=this._isClosed(r);if(F){const t=c.data.length-3;i(n,c.data[t],c.data[t+1],c.data[t+2]),e&&p(n,n,e)}else i(l,c.data[3],c.data[4],c.data[5]),e&&p(l,l,e),D(o,o,l,1,M.LEFT_CAP_START,0,0),D(o,o,l,1,M.RIGHT_CAP_START,0,0),u(n,o),u(o,l);const w=F?0:1,B=F?m:m-1;for(let h=w;h<B;h++){const t=(h+1)%m*3;i(l,c.data[t],c.data[t+1],c.data[t+2]),e&&p(l,l,e),j(n,o,h),D(n,o,l,0,M.LEFT_JOIN_END,h,C),D(n,o,l,0,M.RIGHT_JOIN_END,h,C);const r=this.numJoinSubdivisions;for(let e=0;e<r;++e){const t=(e+1)/(r+1);D(n,o,l,t,M.LEFT_JOIN_END,h,C),D(n,o,l,t,M.RIGHT_JOIN_END,h,C)}D(n,o,l,1,M.LEFT_JOIN_START,h,C),D(n,o,l,1,M.RIGHT_JOIN_START,h,C),u(n,o),u(o,l)}F?(i(l,c.data[3],c.data[4],c.data[5]),e&&p(l,l,e),C=j(n,o,B),D(n,o,l,0,M.LEFT_JOIN_END,w,C),D(n,o,l,0,M.RIGHT_JOIN_END,w,C)):(C=j(n,o,B),D(n,o,o,0,M.LEFT_CAP_END,B,C),D(n,o,o,0,M.RIGHT_CAP_END,B,C)),k(b,N+L,b,N,L);P=k(b,P-L,b,P,L),this._parameters.wireframe&&this._addWireframeVertices(s,N,P,L)}_addWireframeVertices(e,t,r,s){const i=new Float32Array(e.buffer,r*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(e.buffer,t*Float32Array.BYTES_PER_ELEMENT,r-t);let n=0;const o=e=>n=k(a,e,i,n,s);for(let l=0;l<a.length-1;l+=2*s)o(l),o(l+2*s),o(l+1*s),o(l+2*s),o(l+1*s),o(l+3*s)}}function k(e,t,r,s,i){for(let a=0;a<i;a++)r[s++]=e[t++];return s}function Z(e,t){if(!e.isClosed)return!1;return t.get(y.POSITION).indices.length>2}function V(e){return e.anchor===U.Tip&&e.hideOnShortSegments&&"begin-end"===e.placement&&e.worldSpace}const W=f(),Y=f(),X=f(),q=f(),Q=f(),K=r(),$=r(),ee=f(),te=f(),re=d(),se=d(),ie=f(),ae=f(),ne=f(),oe=[r(),r(),r(),r()],le=[f(),f(),f(),f()],ue=R(),ce=R(),he=R(),pe=R();export{z as Parameters,x as RibbonLineMaterial};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{createResolver as e}from"../../../../core/promiseUtils.js";import{d as t}from"../../../../chunks/vec4f64.js";import{ColorFormat as r,DepthFormat as s}from"../core/FBOCache.js";import{RenderRequestType as i,Decorations as o}from"../lib/basicInterfaces.js";import{RenderState as n}from"../../../support/RenderState.js";import{resampleHermite as a}from"../../../support/screenshotUtils.js";import{PixelFormat as h,DataType as c}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as l}from"../../../webgl/FramebufferObject.js";import{createEmptyImageData as d}from"../../../../core/imageUtils.js";class f{constructor(e,t,r){this.parameters=e,this.frameHasDecorations=t,this.fbos=r}}class u{constructor(e,t,r,s){this._rctx=e,this._renderFunctions=t,this._forceCameraHook=r,this._disposeOffscreenBuffers=s,this.supersample=!0,this._screenshotQueue=new Array}destroy(){this._rctx=null}async takeScreenshot(t){await this._renderFunctions.prepareOverlay(),this._renderFunctions.requestRenderScene(i.BACKGROUND);const r=e();return this._screenshotQueue.push({settings:t,resolver:r}),r.promise}update(e,t){for(const r of this._screenshotQueue){if(null==this._rctx){r.resolver.reject();continue}const s={...r.settings,pixelRatio:r.settings.pixelRatio*e.parameters.camera.pixelRatio},i=this._renderScreenshot(e,s,t);r.resolver(i)}this._screenshotQueue.length=0}_renderScreenshotOverlay(e,t,r){e.width=t.width,e.height=t.height;const s=e.getContext("2d"),i=r.pixelRatio;return s.save(),s.translate(0,t.height),s.scale(1,-1),r.region&&s.translate(-r.region.x,-r.region.y),s.scale(i,i),t=this._renderFunctions.renderOverlay(e,r.disableDecorations?o.OFF:o.ON,t),s.restore(),t}_readbackScreenshot(e,t){return e.resample?this._readbackScreenshotResampled({...e,resample:e.resample},t):this._readbackScreenshotImmediate(e,t)}_readbackScreenshotResampled(e,t){const{framebufferWidth:r,framebufferHeight:s,region:i,resample:o}=e,n=this._ensureScreenshotEncodeCanvas();let l=d(r,s,n);this._rctx.gl.readPixels(0,0,r,s,h.RGBA,c.UNSIGNED_BYTE,new Uint8Array(l.data.buffer)),t(),l=this._renderScreenshotOverlay(n,l,{...e,region:void 0});const f=d(i.width,i.height,n);return a(l,f,!0,o.region.x,s-(o.region.y+o.region.height),o.region.width,o.region.height)}_readbackScreenshotImmediate(e,t){const{framebufferHeight:r,region:s}=e,i=this._ensureScreenshotEncodeCanvas(),o=d(s.width,s.height,i);return this._rctx.gl.readPixels(s.x,r-(s.y+s.height),s.width,s.height,h.RGBA,c.UNSIGNED_BYTE,new Uint8Array(o.data.buffer)),t(),this._renderScreenshotOverlay(i,o,e)}_renderScreenshot(e,i,a){const h=e.parameters.camera,c={width:i.framebufferWidth,height:i.framebufferHeight};l(c,Math.min(this._rctx.parameters.maxTextureSize,this._rctx.parameters.maxRenderbufferSize));let d=!1;const f=i.disableDecorations&&e.frameHasDecorations,u=c.width!==h.fullWidth||c.height!==h.fullHeight,m=i.ignorePadding&&h.pixelRatio!==i.pixelRatio,p=u||f||m||i.objectAndLayerIdColor;let _=null;i.objectAndLayerIdColor&&(_=e.fbos.acquire(r.RGBA,c.width,c.height),_.acquireDepth(s.
|
|
5
|
+
import{createResolver as e}from"../../../../core/promiseUtils.js";import{d as t}from"../../../../chunks/vec4f64.js";import{ColorFormat as r,DepthFormat as s}from"../core/FBOCache.js";import{RenderRequestType as i,Decorations as o}from"../lib/basicInterfaces.js";import{RenderState as n}from"../../../support/RenderState.js";import{resampleHermite as a}from"../../../support/screenshotUtils.js";import{PixelFormat as h,DataType as c}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as l}from"../../../webgl/FramebufferObject.js";import{createEmptyImageData as d}from"../../../../core/imageUtils.js";class f{constructor(e,t,r){this.parameters=e,this.frameHasDecorations=t,this.fbos=r}}class u{constructor(e,t,r,s){this._rctx=e,this._renderFunctions=t,this._forceCameraHook=r,this._disposeOffscreenBuffers=s,this.supersample=!0,this._screenshotQueue=new Array}destroy(){this._rctx=null}async takeScreenshot(t){await this._renderFunctions.prepareOverlay(),this._renderFunctions.requestRenderScene(i.BACKGROUND);const r=e();return this._screenshotQueue.push({settings:t,resolver:r}),r.promise}update(e,t){for(const r of this._screenshotQueue){if(null==this._rctx){r.resolver.reject();continue}const s={...r.settings,pixelRatio:r.settings.pixelRatio*e.parameters.camera.pixelRatio},i=this._renderScreenshot(e,s,t);r.resolver(i)}this._screenshotQueue.length=0}_renderScreenshotOverlay(e,t,r){e.width=t.width,e.height=t.height;const s=e.getContext("2d"),i=r.pixelRatio;return s.save(),s.translate(0,t.height),s.scale(1,-1),r.region&&s.translate(-r.region.x,-r.region.y),s.scale(i,i),t=this._renderFunctions.renderOverlay(e,r.disableDecorations?o.OFF:o.ON,t),s.restore(),t}_readbackScreenshot(e,t){return e.resample?this._readbackScreenshotResampled({...e,resample:e.resample},t):this._readbackScreenshotImmediate(e,t)}_readbackScreenshotResampled(e,t){const{framebufferWidth:r,framebufferHeight:s,region:i,resample:o}=e,n=this._ensureScreenshotEncodeCanvas();let l=d(r,s,n);this._rctx.gl.readPixels(0,0,r,s,h.RGBA,c.UNSIGNED_BYTE,new Uint8Array(l.data.buffer)),t(),l=this._renderScreenshotOverlay(n,l,{...e,region:void 0});const f=d(i.width,i.height,n);return a(l,f,!0,o.region.x,s-(o.region.y+o.region.height),o.region.width,o.region.height)}_readbackScreenshotImmediate(e,t){const{framebufferHeight:r,region:s}=e,i=this._ensureScreenshotEncodeCanvas(),o=d(s.width,s.height,i);return this._rctx.gl.readPixels(s.x,r-(s.y+s.height),s.width,s.height,h.RGBA,c.UNSIGNED_BYTE,new Uint8Array(o.data.buffer)),t(),this._renderScreenshotOverlay(i,o,e)}_renderScreenshot(e,i,a){const h=e.parameters.camera,c={width:i.framebufferWidth,height:i.framebufferHeight};l(c,Math.min(this._rctx.parameters.maxTextureSize,this._rctx.parameters.maxRenderbufferSize));let d=!1;const f=i.disableDecorations&&e.frameHasDecorations,u=c.width!==h.fullWidth||c.height!==h.fullHeight,m=i.ignorePadding&&h.pixelRatio!==i.pixelRatio,p=u||f||m||i.objectAndLayerIdColor;let _=null;i.objectAndLayerIdColor&&(_=e.fbos.acquire(r.RGBA,c.width,c.height),_.acquireDepth(s.DEPTH_STENCIL_BUFFER));let g=null;if(p){const s=h.clone();if(i.ignorePadding){const e=t(s.padding);for(let t=0;t<4;t++)e[t]=Math.round(e[t]/s.pixelRatio*i.pixelRatio);s.padding=e}s.fullWidth=c.width,s.fullHeight=c.height,s.pixelRatio=i.pixelRatio;const l=h.fovX-s.fovX,f=h.fovY-s.fovY;l<0&&l<f?s.fovX=h.fovX:f<0&&f<l&&(s.fovY=h.fovY);const u={camera:s,contentCamera:s,mode:n.IDLE,alignPixelEnabled:!0,contentPixelRatio:s.pixelRatio};this._forceCameraHook(u),d=!0,g=e.fbos.acquire(r.RGBA,c.width,c.height);const m=i.disableDecorations?o.OFF:o.ON;this._renderFunctions.renderScene(g,_,u,m,a),this._disposeOffscreenBuffers()}const b=()=>{this._rctx.bindFramebuffer(null),g?.release()};this._rctx.bindFramebuffer(g?.fbo);const x=this._readbackScreenshot(i,b);let v=null;if(i.objectAndLayerIdColor){const e=()=>{this._rctx.bindFramebuffer(null),_?.release()};this._rctx.bindFramebuffer(_?.fbo),v=this._readbackScreenshot(i,e),this._rctx.bindFramebuffer(null)}if(p&&!this._rctx.contextAttributes.alpha)for(let t=3;t<x.data.length;t+=4)x.data[t]=255;if(v&&!this._rctx.contextAttributes.alpha)for(let t=3;t<v.data.length;t+=4)v.data[t]=255;return d&&this._forceCameraHook(e.parameters),[x,v]}_ensureScreenshotEncodeCanvas(){return this._screenshotEncodeCanvas||(this._screenshotEncodeCanvas=document.createElement("canvas")),this._screenshotEncodeCanvas}}export{f as ScreenshotContext,u as ScreenshotManager};
|
package/views/DOMContainer.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{byId as t,reparent as s,empty as i}from"../core/domUtils.js";import{on as r}from"../core/events.js";import o from"../core/Logger.js";import{destroyMaybe as n,removeMaybe as a}from"../core/maybe.js";import{watch as h,initial as d}from"../core/reactiveUtils.js";import{addFrameTask as
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{byId as t,reparent as s,empty as i}from"../core/domUtils.js";import{on as r}from"../core/events.js";import has from"../core/has.js";import o from"../core/Logger.js";import{destroyMaybe as n,removeMaybe as a}from"../core/maybe.js";import{watch as h,initial as d,whenOnce as l}from"../core/reactiveUtils.js";import{addFrameTask as u}from"../core/scheduling.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import m from"./overlay/ViewOverlay.js";import{onLocaleChange as f}from"../intl/locale.js";import{fetchMessageBundle as g}from"../intl/messages.js";const y=[0,0];function v(e){const t=(e.ownerDocument||window.document).defaultView,s=e.getBoundingClientRect();return y[0]=s.left+(t?.pageXOffset??0),y[1]=s.top+(t?.pageYOffset??0),y}function _(e){e&&(i(e),e.parentNode&&e.parentNode.removeChild(e))}function w(e){const t=document.createElement("div");return e.appendChild(t),t}const C=16,H=750,O=512,j=2,b=i=>{let y=class extends i{constructor(...e){super(...e),this._freqInfo={freq:C,time:H},this._overlayRenderTaskHandle=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.ui=null,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([h((()=>this.cursor),(e=>{const{surface:t}=this;t&&t.setAttribute("data-cursor",e)})),h((()=>this.navigating),(e=>{const{surface:t}=this;t&&t.setAttribute("data-navigating",e.toString())}))])}initialize(){const e=has("mac"),t=async()=>{e&&(await l((()=>this.ready)),this.messagesCommon=await g("esri/t9n/common").catch((()=>{})))};t(),this.addHandles([h((()=>this.ui),((e,t)=>this._handleUIChange(e,t)),d),this.on("focus",(()=>this.notifyChange("focused"))),this.on("blur",(()=>this.notifyChange("focused"))),f(t),h((()=>[this.surface,this.messagesCommon]),(()=>{e&&this.surface?.setAttribute("aria-label",this.messagesCommon?.ariaLabels.navigationMacVoceOver??"")}))])}destroy(){this.destroyed||(this.ui=n(this.ui),this.container=null)}get container(){return this._get("container")??null}set container(e){const i=this._get("container"),r=t(e);if(r||"string"!=typeof e||o.getLogger(this).error("#container",`element with id '${e}' not found`),i===r)return;if(this._stopMeasuring(),i&&(i.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this.root&&(_(this.root),this._set("root",null)),this.userContent&&(s(this.userContent,i),_(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 n=document.createElement("div");n.className="esri-view-user-storage",s(r,n),r.appendChild(n),this._set("userContent",n);const d=document.createElement("div");d.className="esri-view-root",r.insertBefore(d,r.firstChild),this._set("root",d);const l=document.createElement("div");l.className="esri-view-surface",l.setAttribute("role","application"),l.tabIndex=0,d.appendChild(l),this._set("surface",l);const c=new m;d.appendChild(c.surface),this._set("overlay",c),this.addHandles(h((()=>c.needsRender),(e=>{e&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=u({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=a(this._overlayRenderTaskHandle)}))),this.forceDOMReadyCycle(),this._set("container",r),this._startMeasuring()}get focused(){const e=document.activeElement===this.surface;return document.hasFocus()&&e}get size(){return[this.width,this.height]}blur(){this.surface?.blur()}focus(){this.surface?.focus()}pageToContainer(e,t,s){const i=this.position;return e-=i?i[0]:0,t-=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}containerToPage(e,t,s){const i=this.position;return e+=i?i[0]:0,t+=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}_handleUIChange(e,t){this.removeHandles("ui"),t&&t!==e&&t.destroy(),e&&(e.view=this,this.addHandles(h((()=>this.root),(t=>{e.container=t?w(t):null}),d),"ui")),this._set("ui",e)}_stopMeasuring(){this.removeHandles("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const e=this._freqInfo;e.freq=C,e.time=H,this.addHandles([r(window,"resize",(()=>{e.freq=C,e.time=H})),u({prepare:e=>{const t=this._measure(),s=this._freqInfo;if(s.time+=e.deltaTime,t&&(s.freq=C,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const i=this._position();s.freq=i||t?C:Math.min(H,s.freq*j),!t&&s.freq>=O&&this._get("resizing")&&this._set("resizing",!1)}})],"measuring"),this._measure(),this._position()}_measure(){const e=this.container,t=e?e.clientWidth:0,s=e?e.clientHeight:0;if(0===t||0===s)return this.suspended||this._set("suspended",!0),!1;const i=this.width,r=this.height;return t===i&&s===r?(this.suspended&&this._set("suspended",!1),!1):(this._set("width",t),this._set("height",s),this.suspended&&this._set("suspended",!1),this.emit("resize",{oldWidth:i,oldHeight:r,width:t,height:s}),!0)}_position(){const e=this.container,t=this.position,s=e&&v(e);return!!s&&((!t||s[0]!==t[0]||s[1]!==t[1])&&(this._set("position",[s[0],s[1]]),!0))}forceDOMReadyCycle(){}};return e([c()],y.prototype,"container",null),e([c({readOnly:!0})],y.prototype,"focused",null),e([c({readOnly:!0})],y.prototype,"height",void 0),e([c()],y.prototype,"messagesCommon",void 0),e([c({type:m})],y.prototype,"overlay",void 0),e([c({readOnly:!0})],y.prototype,"position",void 0),e([c({readOnly:!0})],y.prototype,"resizing",void 0),e([c({readOnly:!0})],y.prototype,"root",void 0),e([c({value:null,readOnly:!0})],y.prototype,"size",null),e([c({readOnly:!0})],y.prototype,"surface",void 0),e([c({readOnly:!0})],y.prototype,"suspended",void 0),e([c()],y.prototype,"ui",void 0),e([c({readOnly:!0})],y.prototype,"userContent",void 0),e([c({readOnly:!0})],y.prototype,"width",void 0),e([c()],y.prototype,"widthBreakpoint",void 0),y=e([p("esri.views.DOMContainer")],y),y};export{b as DOMContainer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import i from"../../core/Evented.js";import{makeHandle as o}from"../../core/handleUtils.js";import{destroyMaybe as r}from"../../core/maybe.js";import{memoize as n}from"../../core/memoize.js";import{createLength as l,zeroMeters as a,zeroSquareMeters as s,zeroDegrees as p}from"../../core/quantityUtils.js";import{watch as c,syncAndInitial as h}from"../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as u}from"../../core/unitUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getConvertedElevation as g}from"../../support/elevationInfoUtils.js";import{createSquare as v,createRectangle as f,createCircle as _,createEllipse as w,createPolygon as O,createPolyline as x,createMultipoint as G}from"./support/createUtils.js";import{getDrawHelpMessage as V}from"./support/helpMessageUtils.js";import{createViewAlignedCoordinateSystem as T}from"./support/surfaceCoordinateSystems.js";import{InteractiveToolBase as b}from"../interactive/InteractiveToolBase.js";import{tooltipKeys as C}from"../interactive/keybindings.js";import I from"../interactive/sketch/SketchLabelOptions.js";import j from"../interactive/sketch/SketchTooltipOptions.js";import{intersectAll as S,getDistanceConstraint as U,getOrientationConstraint as k,getElevationConstraint as M}from"../interactive/tooltip/constraintUtils.js";import{DrawPointTooltipInfo as P,DrawPolylineTooltipInfo as z,DrawPolygonTooltipInfo as D,DrawMeshTooltipInfo as E,DrawRectangleTooltipInfo as H,DrawCircleTooltipInfo as A}from"../interactive/tooltip/DrawTooltipInfos.js";import{Tooltip as R}from"../interactive/tooltip/Tooltip.js";import{orientationBetweenPoints as L}from"../support/angularMeasurementUtils.js";import{autoAreaByElevationMode as Z}from"../support/automaticAreaMeasurementUtils.js";import{autoLengthByElevationMode as F,autoDirectDistanceByElevationModeBetweenPoints as N,autoHorizontalDistanceByElevationModeBetweenPoints as q}from"../support/automaticLengthMeasurementUtils.js";import{autorun as B}from"../../core/accessorSupport/trackingUtils.js";class J{constructor(){this.regularVertices=null,this.activeVertex=null,this.full=null,this.outline=null,this.circle=null,this.rectangle=null}}let K=class extends(i.EventedMixin(b)){constructor(t){super(t),this._graphic=null,this._createOperationGeometry=null,this.defaultZ=0,this.geometryType=null,this.hasZ=!0,this.labelOptions=new I,this.geometryToPlace=null,this.mode=null,this.snappingManager=null,this.snapToScene=!1,this.tooltip=null,this.tooltipOptions=new j,this._getPointConstraint=n((t=>t)),this._getPolylineOrPolygonConstraint=n(((t,e,i)=>S([t,e,i]))),this._getDistanceConstraint=n(U),this._getOrientationConstraint=n(k),this._getElevationConstraint=n(M)}initialize(){this.internalGraphicsLayer=new y({listMode:"hide",internal:!0}),this.view.map.layers.add(this.internalGraphicsLayer),this.drawOperation=this.makeDrawOperation();const t=this.tooltipOptions,e=this.view.type;this.tooltipInfos={point:new P({tooltipOptions:t,viewType:e}),polyline:new z({tooltipOptions:t,viewType:e}),polygon:new D({tooltipOptions:t,viewType:e}),mesh:new E({tooltipOptions:t,viewType:e}),rectangle:new H({tooltipOptions:t}),circle:new A({tooltipOptions:t})},this.addHandles([this.drawOperation.on("vertex-add",(t=>this.onVertexAdd(t))),this.drawOperation.on("vertex-remove",(t=>this.onVertexRemove(t))),this.drawOperation.on("vertex-update",(t=>this.onVertexUpdate(t))),this.drawOperation.on("cursor-update",(t=>this.onCursorUpdate(t))),this.drawOperation.on("complete",(t=>this.onComplete(t))),c((()=>this.tooltipOptions.enabled),(t=>{this.tooltip=t?new R({view:this.view,info:this._tooltipInfo}):r(this.tooltip)}),h),B((()=>this._updateTooltipInfo()))]),this.finishToolCreation()}destroy(){this.drawOperation=r(this.drawOperation),this.tooltip=r(this.tooltip),this._destroyAllVisualisations(),this.view.map.remove(this.internalGraphicsLayer),this.internalGraphicsLayer=r(this.internalGraphicsLayer),this._set("view",null)}get _defaultElevation(){return l(this.defaultZ,"meters")}get canRedo(){return this.drawOperation.canRedo}get canUndo(){return this.drawOperation.canUndo}set centered(t){this._set("centered",t),this._updateGraphic()}set enabled(t){this.drawOperation.interactive=t,this._set("enabled",t)}set forceUniformSize(t){this._set("forceUniformSize",t),this._updateGraphic()}get graphic(){return this._graphic}set graphicSymbol(t){this._set("graphicSymbol",t),null!=this._graphic&&(this._graphic.symbol=t)}get updating(){return this.drawOperation?.updating??!1}completeCreateOperation(){this.drawOperation.complete()}onInputEvent(t){const e=this._tooltipInfo;if("key-down"===t.type&&t.key===C.enterInputMode&&null!=e&&e.editableFields.length>0&&this.tooltipOptions.inputEnabled)return e.enterInputMode(),void t.stopPropagation();this.drawOperation.onInputEvent(t)}redo(){this.drawOperation.redo()}reset(){}undo(){this.drawOperation.undo()}_destroyAllVisualisations(){this.removeHandles(W.outline),this.removeHandles(W.regularVertices),this.removeHandles(W.activeVertex),this.removeHandles(Q)}_createOrUpdateGraphic(t){if(null!=this._graphic)return this.updateGraphicGeometry(this._graphic,t),this._graphic;const i=this._graphic=new e({...this.graphicProperties,symbol:this.graphicSymbol});return this.updateGraphicGeometry(i,t),this.internalGraphicsLayer.add(i),this.addHandles(this.initializeGraphic(i)),this.notifyChange("graphic"),this.addHandles(o((()=>{this.internalGraphicsLayer.remove(i),r(i),this._graphic===i&&(this._graphic=null)})),Q),i}updateGraphicGeometry(t,e){t.geometry=e}_getCreateOperationGeometry(t={operationComplete:!1}){const{drawOperation:e}=this;if(null==e||0===e.numVertices)return null;const{coordinateHelper:i,view:o}=e,r=e.stagedVertex,n=e.committedVertices,l=n.slice(),a=null!=r;a&&l.push(i.pointToArray(r));const s=a?i.pointToArray(r):n.splice(-1)[0],p=l.length,c=o.spatialReference,h="3d"===o.type&&"global"===o.viewingMode,u=new J;switch(this.geometryType){case"point":case"mesh":u.regularVertices=n,u.activeVertex=s,u.full=i.arrayToPoint(l[0]);break;case"multipoint":u.regularVertices=n,u.activeVertex=s,p>0&&(u.full=G(l,c));break;case"polyline":u.regularVertices=n,u.activeVertex=s,p>0&&(u.full=x([l],c,h));break;case"polygon":u.regularVertices=n,u.activeVertex=s,p>0&&(u.full=O([l],c,h,!0));break;case"circle":if(p>0){const e=T(o,l[0]);if(1===p&&t.operationComplete){const t=l[0],i=e.makeMapPoint(t[0]+Y*o.resolution,t[1]);u.circle=_([t,i],e,!0),u.full=null!=u.circle?u.circle.geometry:null}else 2===p&&(this.forceUniformSize?(u.circle=_(l,e,this.centered),u.full=null!=u.circle?u.circle.geometry:null):(u.rectangle=w(l,e,this.centered),u.full=u.rectangle.geometry))}break;case"rectangle":if(p>0){const e=T(o,l[0]);if(1===p&&t.operationComplete){const t=l[0],i=e.makeMapPoint(t[0]+Y*o.resolution,t[1]);u.rectangle=v([t,i],e,!0),u.full=u.rectangle.geometry}else 2===p&&(u.rectangle=this.forceUniformSize?v(l,e,this.centered):f(l,e,this.centered),u.full=u.rectangle.geometry)}break;default:return null}switch(this.geometryType){case"point":case"multipoint":break;case"polyline":u.outline=p>1?x([l],c,h):null;break;case"polygon":u.outline=p>1?O([l],c,h):null;break;case"circle":case"rectangle":u.outline="polygon"===u.full?.type?O(u.full.rings,c,h):null}return u}initializeGraphic(t){return o()}onComplete(t){this._updateGraphic();let e=null;if(this.drawOperation.isCompleted){const t=this._getCreateOperationGeometry({operationComplete:!0});null!=t&&(e=this._createOrUpdateGraphic(t.full).clone())}this._createOperationGeometry=null,this.emit("complete",{graphic:e,...t})}onCursorUpdate(t){this._updateGraphic(),this.emit("cursor-update",t)}onDeactivate(){this.drawOperation.isCompleted||this.drawOperation.cancel()}onVertexAdd(t){this._updateGraphic(),this._clearConstraints(),this.emit("vertex-add",t)}onVertexRemove(t){this._updateGraphic(),this._clearConstraints(),this.emit("vertex-remove",t)}onVertexUpdate(t){this._updateGraphic(),this.emit("vertex-update",t)}_updateGraphic(){const t=this._getCreateOperationGeometry();this._createOperationGeometry=t,null!=t?(null!=t.outline?this.addHandles(this.onOutlineChanged(t.outline),W.outline):this.removeHandles(W.outline),null!=t.regularVertices?this.addHandles(this.onRegularVerticesChanged(t.regularVertices),W.regularVertices):this.removeHandles(W.regularVertices),null!=t.activeVertex?this.addHandles(this.onActiveVertexChanged(t.activeVertex),W.activeVertex):this.removeHandles(W.activeVertex),null!=t.full?this._createOrUpdateGraphic(t.full):this.removeHandles(Q)):this._destroyAllVisualisations()}get _tooltipInfo(){const{drawOperation:t,graphic:e,view:i}=this;if(!t)return null;const o=this.tooltipInfos,r=e?.geometry?.type;switch(this.geometryType){case"point":return"2d"===i.type&&0===this.defaultZ?null:"point"===r?o.point:null;case"polyline":return"polyline"===r?o.polyline:null;case"polygon":return"polygon"===r?o.polygon:null;case"rectangle":return"polygon"===r?o.rectangle:null;case"circle":return"polygon"===r?o.circle:null;case"mesh":return"mesh"===r?o.mesh:null;default:return null}}_updateTooltipInfo(){const{_tooltipInfo:t,tooltip:e}=this;if(t&&e){switch(t.type){case"draw-point":this._updateDrawPointTooltipInfo(t);break;case"draw-polyline":this._updateDrawPolylineTooltipInfo(t);break;case"draw-polygon":this._updateDrawPolygonTooltipInfo(t);break;case"draw-rectangle":this._updateDrawRectangleTooltipInfo(t);break;case"draw-circle":this._updateDrawCircleTooltipInfo(t);break;case"draw-mesh":this.updateDrawMeshTooltipInfo(t)}e.info=t}}_updateDrawPointTooltipInfo(t){const{drawOperation:e,graphic:i,view:o,tooltipOptions:r}=this,{elevationInfo:n,stagedVertex:l}=e;if(t.tooltipOptions=r,t.viewType=o.type,t.helpMessage=V("point",i?.geometry),this.updateElevation(t.elevation),!l)return void(e.constraint=void 0);const a=e.coordinateHelper.spatialReference;e.constraint=this._getPointConstraint(this._getElevationConstraint(t.elevation.committed,a,o,n))}_updateDrawPolylineTooltipInfo(t){const e=this._createOperationGeometry,i=null!=e?e.full:null;if("polyline"!==i?.type)return;const{drawOperation:o,tooltipOptions:r,view:n}=this,{lastVertex:l,stagedVertex:s}=o;this._updatePolylineOrPolygonCommon(t,s);const p=F(i,this._elevationMode);t.totalLength.actual=p??a,t.totalLength.hidden=null==length||!l,t.tooltipOptions=r,t.viewType=n.type,t.helpMessage=V("polyline",i),this.updateElevation(t.elevation)}_updateDrawPolygonTooltipInfo(t){const e=this._createOperationGeometry,i=null!=e?e.full:null;if("polygon"!==i?.type)return;const{drawOperation:o,tooltipOptions:r,view:n}=this,{lastVertex:l}=o;let a=o.stagedVertex;"polygon"===i?.type&&l&&!a&&(a=i.getPoint(0,i.rings[0].length-1)),this._updatePolylineOrPolygonCommon(t,a);const p=Z(i,this._elevationMode);t.area.actual=p??s,t.area.hidden=null==p&&!l,t.tooltipOptions=r,t.viewType=n.type,t.helpMessage=V("polygon",i),this.updateElevation(t.elevation)}_updatePolylineOrPolygonCommon(t,e){const{view:i,drawOperation:o}=this,{elevationInfo:r,lastVertex:n}=o;if(!n||!e)return t.distance.hidden=!0,t.orientation.hidden=!0,void(o.constraint=void 0);const l=N(n,e,this._elevationMode);t.distance.actual=l??a,t.distance.hidden=!1;const s=L(n,e);t.orientation.actual=s??p,t.orientation.hidden=!1;const c=o.coordinateHelper.spatialReference;o.constraint=this._getPolylineOrPolygonConstraint(this._getDistanceConstraint(n,t.distance.committed,i,r),this._getOrientationConstraint(n,t.orientation.committed,i,r),this._getElevationConstraint(t.elevation.committed,c,i,r))}updateDrawMeshTooltipInfo(t){}_updateDrawRectangleTooltipInfo(t){t.tooltipOptions=this.tooltipOptions,t.xSize=this._xSize??a,t.ySize=this._ySize??a,t.area=this._fullGeometryArea??s}_updateDrawCircleTooltipInfo(t){const{forceUniformSize:e}=this;t.tooltipOptions=this.tooltipOptions,t.radius=e?this._circleRadius??a:null,t.xSize=e?null:this._xSize??a,t.ySize=e?null:this._ySize??a,t.area=this._fullGeometryArea??s}get _circleRadius(){const t=this._createOperationGeometry;return null!=t?.circle?.center&&null!=t.circle.edge?q(t.circle.center,t.circle.edge,this._elevationMode):null}get _xSize(){const t=this._createOperationGeometry?.rectangle?.midpoints;return null!=t?q(t.left,t.right,this._elevationMode):null}get _ySize(){const t=this._createOperationGeometry?.rectangle?.midpoints;return null!=t?q(t.top,t.bottom,this._elevationMode):null}get _fullGeometryArea(){const t=this._createOperationGeometry?.full;return"polygon"!==t?.type?null:Z(t,this._elevationMode)}updateElevation(t){t.actual=this._vertexTooltipElevation}get _vertexTooltipElevation(){const{tooltipOptions:t,view:e,drawOperation:i}=this;if(null==i)return this._defaultElevation;const o=i.stagedVertex??i.lastVertex;if(null==o||"2d"===e.type)return this._defaultElevation;const r={mode:t.elevation.mode,offset:0},n=(g(e,o,i.elevationInfo,r)??0)*u(o.spatialReference);return l(n,"meters")}get _elevationMode(){return this.drawOperation.isDraped?"on-the-ground":"absolute-height"}_clearConstraints(){for(const[,t]of Object.entries(this.tooltipInfos))t.unlockAllFields()}};t([d()],K.prototype,"_createOperationGeometry",void 0),t([d()],K.prototype,"_defaultElevation",null),t([d({value:!0})],K.prototype,"centered",null),t([d({nonNullable:!0})],K.prototype,"defaultZ",void 0),t([d()],K.prototype,"drawOperation",void 0),t([d({value:!0})],K.prototype,"enabled",null),t([d({value:!0})],K.prototype,"forceUniformSize",null),t([d({constructOnly:!0})],K.prototype,"geometryType",void 0),t([d()],K.prototype,"graphic",null),t([d({constructOnly:!0})],K.prototype,"graphicProperties",void 0),t([d()],K.prototype,"graphicSymbol",null),t([d({constructOnly:!0})],K.prototype,"hasZ",void 0),t([d({constructOnly:!0,type:I})],K.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],K.prototype,"geometryToPlace",void 0),t([d({constructOnly:!0})],K.prototype,"mode",void 0),t([d()],K.prototype,"snappingManager",void 0),t([d()],K.prototype,"snapToScene",void 0),t([d()],K.prototype,"tooltip",void 0),t([d()],K.prototype,"tooltipInfos",void 0),t([d({constructOnly:!0,type:j})],K.prototype,"tooltipOptions",void 0),t([d({readOnly:!0})],K.prototype,"type",void 0),t([d({readOnly:!0})],K.prototype,"updating",null),t([d({constructOnly:!0,nonNullable:!0})],K.prototype,"view",void 0),t([d()],K.prototype,"_tooltipInfo",null),t([d()],K.prototype,"_circleRadius",null),t([d()],K.prototype,"_xSize",null),t([d()],K.prototype,"_ySize",null),t([d()],K.prototype,"_fullGeometryArea",null),t([d()],K.prototype,"_vertexTooltipElevation",null),t([d()],K.prototype,"_elevationMode",null),K=t([m("esri.views.draw.DrawGraphicTool")],K);const Q="create-operation-graphic",W={outline:"outline-visual",regularVertices:"regular-vertices-visual",activeVertex:"active-vertex-visual"};function X(t){switch(t){case"point":case"polyline":case"polygon":case"multipoint":return t;case"circle":case"rectangle":return"segment";case"mesh":return"point"}}const Y=48;export{J as CreateOperationGeometry,K as DrawGraphicTool,X as geometryTypeToDrawOperationGeometryType};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import o from"../../core/Evented.js";import{makeHandle as i}from"../../core/handleUtils.js";import{destroyMaybe as r}from"../../core/maybe.js";import{memoize as n}from"../../core/memoize.js";import{createLength as l,zeroMeters as a,zeroSquareMeters as s,zeroDegrees as p}from"../../core/quantityUtils.js";import{watch as c,syncAndInitial as h}from"../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as u}from"../../core/unitUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getConvertedElevation as g}from"../../support/elevationInfoUtils.js";import{createSquare as v,createRectangle as f,createCircle as _,createEllipse as w,createPolygon as O,createPolyline as x,createMultipoint as G}from"./support/createUtils.js";import{getDrawHelpMessage as V}from"./support/helpMessageUtils.js";import{createViewAlignedCoordinateSystem as T}from"./support/surfaceCoordinateSystems.js";import{InteractiveToolBase as b}from"../interactive/InteractiveToolBase.js";import{tooltipKeys as C}from"../interactive/keybindings.js";import I from"../interactive/sketch/SketchLabelOptions.js";import j from"../interactive/sketch/SketchTooltipOptions.js";import{intersectAll as S,getDistanceConstraint as U,getOrientationConstraint as k,getElevationConstraint as M}from"../interactive/tooltip/constraintUtils.js";import{DrawPointTooltipInfo as P,DrawPolylineTooltipInfo as z,DrawPolygonTooltipInfo as D,DrawMeshTooltipInfo as E,DrawRectangleTooltipInfo as H,DrawCircleTooltipInfo as A}from"../interactive/tooltip/DrawTooltipInfos.js";import{Tooltip as R}from"../interactive/tooltip/Tooltip.js";import{orientationBetweenPoints as L}from"../support/angularMeasurementUtils.js";import{autoAreaByElevationMode as Z}from"../support/automaticAreaMeasurementUtils.js";import{autoLengthByElevationMode as F,autoDirectDistanceByElevationModeBetweenPoints as N,autoHorizontalDistanceByElevationModeBetweenPoints as q}from"../support/automaticLengthMeasurementUtils.js";import{autorun as B}from"../../core/accessorSupport/trackingUtils.js";class J{constructor(){this.regularVertices=null,this.activeVertex=null,this.full=null,this.outline=null,this.circle=null,this.rectangle=null}}let K=class extends(o.EventedMixin(b)){constructor(t){super(t),this._graphic=null,this._createOperationGeometry=null,this.defaultZ=0,this.geometryType=null,this.hasZ=!0,this.labelOptions=new I,this.geometryToPlace=null,this.mode=null,this.snappingManager=null,this.snapToScene=!1,this.tooltip=null,this.tooltipOptions=new j,this._getPointConstraint=n((t=>t)),this._getPolylineOrPolygonConstraint=n(((t,e,o)=>S([t,e,o]))),this._getDistanceConstraint=n(U),this._getOrientationConstraint=n(k),this._getElevationConstraint=n(M)}initialize(){this.internalGraphicsLayer=new y({listMode:"hide",internal:!0}),this.view.map.layers.add(this.internalGraphicsLayer),this.drawOperation=this.makeDrawOperation();const t=this.tooltipOptions,e=this.view.type;this.tooltipInfos={point:new P({tooltipOptions:t,viewType:e}),polyline:new z({tooltipOptions:t,viewType:e}),polygon:new D({tooltipOptions:t,viewType:e}),mesh:new E({tooltipOptions:t,viewType:e}),rectangle:new H({tooltipOptions:t}),circle:new A({tooltipOptions:t})},this.addHandles([this.drawOperation.on("vertex-add",(t=>this.onVertexAdd(t))),this.drawOperation.on("vertex-remove",(t=>this.onVertexRemove(t))),this.drawOperation.on("vertex-update",(t=>this.onVertexUpdate(t))),this.drawOperation.on("cursor-update",(t=>this.onCursorUpdate(t))),this.drawOperation.on("complete",(t=>this.onComplete(t))),c((()=>this.cursor),(t=>{this.drawOperation.cursor=t}),h),c((()=>this.tooltipOptions.enabled),(t=>{this.tooltip=t?new R({view:this.view,info:this._tooltipInfo}):r(this.tooltip)}),h),B((()=>this._updateTooltipInfo()))]),this.finishToolCreation()}destroy(){this.drawOperation=r(this.drawOperation),this.tooltip=r(this.tooltip),this._destroyAllVisualisations(),this.view.map.remove(this.internalGraphicsLayer),this.internalGraphicsLayer=r(this.internalGraphicsLayer),this._set("view",null)}get _defaultElevation(){return l(this.defaultZ,"meters")}get canRedo(){return this.drawOperation.canRedo}get canUndo(){return this.drawOperation.canUndo}set centered(t){this._set("centered",t),this._updateGraphic()}get cursor(){return this._get("cursor")}set cursor(t){this._set("cursor",t)}set enabled(t){this.drawOperation.interactive=t,this._set("enabled",t)}set forceUniformSize(t){this._set("forceUniformSize",t),this._updateGraphic()}get graphic(){return this._graphic}set graphicSymbol(t){this._set("graphicSymbol",t),null!=this._graphic&&(this._graphic.symbol=t)}get updating(){return this.drawOperation?.updating??!1}completeCreateOperation(){this.drawOperation.complete()}onInputEvent(t){const e=this._tooltipInfo;if("key-down"===t.type&&t.key===C.enterInputMode&&null!=e&&e.editableFields.length>0&&this.tooltipOptions.inputEnabled)return e.enterInputMode(),void t.stopPropagation();this.drawOperation.onInputEvent(t)}redo(){this.drawOperation.redo()}reset(){}undo(){this.drawOperation.undo()}_destroyAllVisualisations(){this.removeHandles(W.outline),this.removeHandles(W.regularVertices),this.removeHandles(W.activeVertex),this.removeHandles(Q)}_createOrUpdateGraphic(t){if(null!=this._graphic)return this.updateGraphicGeometry(this._graphic,t),this._graphic;const o=this._graphic=new e({...this.graphicProperties,symbol:this.graphicSymbol});return this.updateGraphicGeometry(o,t),this.internalGraphicsLayer.add(o),this.addHandles(this.initializeGraphic(o)),this.notifyChange("graphic"),this.addHandles(i((()=>{this.internalGraphicsLayer.remove(o),r(o),this._graphic===o&&(this._graphic=null)})),Q),o}updateGraphicGeometry(t,e){t.geometry=e}_getCreateOperationGeometry(t={operationComplete:!1}){const{drawOperation:e}=this;if(null==e||0===e.numVertices)return null;const{coordinateHelper:o,view:i}=e,r=e.stagedVertex,n=e.committedVertices,l=n.slice(),a=null!=r;a&&l.push(o.pointToArray(r));const s=a?o.pointToArray(r):n.splice(-1)[0],p=l.length,c=i.spatialReference,h="3d"===i.type&&"global"===i.viewingMode,u=new J;switch(this.geometryType){case"point":case"mesh":u.regularVertices=n,u.activeVertex=s,u.full=o.arrayToPoint(l[0]);break;case"multipoint":u.regularVertices=n,u.activeVertex=s,p>0&&(u.full=G(l,c));break;case"polyline":u.regularVertices=n,u.activeVertex=s,p>0&&(u.full=x([l],c,h));break;case"polygon":u.regularVertices=n,u.activeVertex=s,p>0&&(u.full=O([l],c,h,!0));break;case"circle":if(p>0){const e=T(i,l[0]);if(1===p&&t.operationComplete){const t=l[0],o=e.makeMapPoint(t[0]+Y*i.resolution,t[1]);u.circle=_([t,o],e,!0),u.full=null!=u.circle?u.circle.geometry:null}else 2===p&&(this.forceUniformSize?(u.circle=_(l,e,this.centered),u.full=null!=u.circle?u.circle.geometry:null):(u.rectangle=w(l,e,this.centered),u.full=u.rectangle.geometry))}break;case"rectangle":if(p>0){const e=T(i,l[0]);if(1===p&&t.operationComplete){const t=l[0],o=e.makeMapPoint(t[0]+Y*i.resolution,t[1]);u.rectangle=v([t,o],e,!0),u.full=u.rectangle.geometry}else 2===p&&(u.rectangle=this.forceUniformSize?v(l,e,this.centered):f(l,e,this.centered),u.full=u.rectangle.geometry)}break;default:return null}switch(this.geometryType){case"point":case"multipoint":break;case"polyline":u.outline=p>1?x([l],c,h):null;break;case"polygon":u.outline=p>1?O([l],c,h):null;break;case"circle":case"rectangle":u.outline="polygon"===u.full?.type?O(u.full.rings,c,h):null}return u}initializeGraphic(t){return i()}onComplete(t){this._updateGraphic();let e=null;if(this.drawOperation.isCompleted){const t=this._getCreateOperationGeometry({operationComplete:!0});null!=t&&(e=this._createOrUpdateGraphic(t.full).clone())}this._createOperationGeometry=null,this.emit("complete",{graphic:e,...t})}onCursorUpdate(t){this._updateGraphic(),this.emit("cursor-update",t)}onDeactivate(){this.drawOperation.isCompleted||this.drawOperation.cancel()}onVertexAdd(t){this._updateGraphic(),this._clearConstraints(),this.emit("vertex-add",t)}onVertexRemove(t){this._updateGraphic(),this._clearConstraints(),this.emit("vertex-remove",t)}onVertexUpdate(t){this._updateGraphic(),this.emit("vertex-update",t)}_updateGraphic(){const t=this._getCreateOperationGeometry();this._createOperationGeometry=t,null!=t?(null!=t.outline?this.addHandles(this.onOutlineChanged(t.outline),W.outline):this.removeHandles(W.outline),null!=t.regularVertices?this.addHandles(this.onRegularVerticesChanged(t.regularVertices),W.regularVertices):this.removeHandles(W.regularVertices),null!=t.activeVertex?this.addHandles(this.onActiveVertexChanged(t.activeVertex),W.activeVertex):this.removeHandles(W.activeVertex),null!=t.full?this._createOrUpdateGraphic(t.full):this.removeHandles(Q)):this._destroyAllVisualisations()}get _tooltipInfo(){const{drawOperation:t,graphic:e,view:o}=this;if(!t)return null;const i=this.tooltipInfos,r=e?.geometry?.type;switch(this.geometryType){case"point":return"2d"===o.type&&0===this.defaultZ?null:"point"===r?i.point:null;case"polyline":return"polyline"===r?i.polyline:null;case"polygon":return"polygon"===r?i.polygon:null;case"rectangle":return"polygon"===r?i.rectangle:null;case"circle":return"polygon"===r?i.circle:null;case"mesh":return"mesh"===r?i.mesh:null;default:return null}}_updateTooltipInfo(){const{_tooltipInfo:t,tooltip:e}=this;if(t&&e){switch(t.type){case"draw-point":this._updateDrawPointTooltipInfo(t);break;case"draw-polyline":this._updateDrawPolylineTooltipInfo(t);break;case"draw-polygon":this._updateDrawPolygonTooltipInfo(t);break;case"draw-rectangle":this._updateDrawRectangleTooltipInfo(t);break;case"draw-circle":this._updateDrawCircleTooltipInfo(t);break;case"draw-mesh":this.updateDrawMeshTooltipInfo(t)}e.info=t}}_updateDrawPointTooltipInfo(t){const{drawOperation:e,graphic:o,view:i,tooltipOptions:r}=this,{elevationInfo:n,stagedVertex:l}=e;if(t.tooltipOptions=r,t.viewType=i.type,t.helpMessage=V("point",o?.geometry),this.updateElevation(t.elevation),!l)return void(e.constraint=void 0);const a=e.coordinateHelper.spatialReference;e.constraint=this._getPointConstraint(this._getElevationConstraint(t.elevation.committed,a,i,n))}_updateDrawPolylineTooltipInfo(t){const e=this._createOperationGeometry,o=null!=e?e.full:null;if("polyline"!==o?.type)return;const{drawOperation:i,tooltipOptions:r,view:n}=this,{lastVertex:l,stagedVertex:s}=i;this._updatePolylineOrPolygonCommon(t,s);const p=F(o,this._elevationMode);t.totalLength.actual=p??a,t.totalLength.hidden=null==length||!l,t.tooltipOptions=r,t.viewType=n.type,t.helpMessage=V("polyline",o),this.updateElevation(t.elevation)}_updateDrawPolygonTooltipInfo(t){const e=this._createOperationGeometry,o=null!=e?e.full:null;if("polygon"!==o?.type)return;const{drawOperation:i,tooltipOptions:r,view:n}=this,{lastVertex:l}=i;let a=i.stagedVertex;"polygon"===o?.type&&l&&!a&&(a=o.getPoint(0,o.rings[0].length-1)),this._updatePolylineOrPolygonCommon(t,a);const p=Z(o,this._elevationMode);t.area.actual=p??s,t.area.hidden=null==p&&!l,t.tooltipOptions=r,t.viewType=n.type,t.helpMessage=V("polygon",o),this.updateElevation(t.elevation)}_updatePolylineOrPolygonCommon(t,e){const{view:o,drawOperation:i}=this,{elevationInfo:r,lastVertex:n}=i;if(!n||!e)return t.distance.hidden=!0,t.orientation.hidden=!0,void(i.constraint=void 0);const l=N(n,e,this._elevationMode);t.distance.actual=l??a,t.distance.hidden=!1;const s=L(n,e);t.orientation.actual=s??p,t.orientation.hidden=!1;const c=i.coordinateHelper.spatialReference;i.constraint=this._getPolylineOrPolygonConstraint(this._getDistanceConstraint(n,t.distance.committed,o,r),this._getOrientationConstraint(n,t.orientation.committed,o,r),this._getElevationConstraint(t.elevation.committed,c,o,r))}updateDrawMeshTooltipInfo(t){}_updateDrawRectangleTooltipInfo(t){t.tooltipOptions=this.tooltipOptions,t.xSize=this._xSize??a,t.ySize=this._ySize??a,t.area=this._fullGeometryArea??s}_updateDrawCircleTooltipInfo(t){const{forceUniformSize:e}=this;t.tooltipOptions=this.tooltipOptions,t.radius=e?this._circleRadius??a:null,t.xSize=e?null:this._xSize??a,t.ySize=e?null:this._ySize??a,t.area=this._fullGeometryArea??s}get _circleRadius(){const t=this._createOperationGeometry;return null!=t?.circle?.center&&null!=t.circle.edge?q(t.circle.center,t.circle.edge,this._elevationMode):null}get _xSize(){const t=this._createOperationGeometry?.rectangle?.midpoints;return null!=t?q(t.left,t.right,this._elevationMode):null}get _ySize(){const t=this._createOperationGeometry?.rectangle?.midpoints;return null!=t?q(t.top,t.bottom,this._elevationMode):null}get _fullGeometryArea(){const t=this._createOperationGeometry?.full;return"polygon"!==t?.type?null:Z(t,this._elevationMode)}updateElevation(t){t.actual=this._vertexTooltipElevation}get _vertexTooltipElevation(){const{tooltipOptions:t,view:e,drawOperation:o}=this;if(null==o)return this._defaultElevation;const i=o.stagedVertex??o.lastVertex;if(null==i||"2d"===e.type)return this._defaultElevation;const r={mode:t.elevation.mode,offset:0},n=(g(e,i,o.elevationInfo,r)??0)*u(i.spatialReference);return l(n,"meters")}get _elevationMode(){return this.drawOperation.isDraped?"on-the-ground":"absolute-height"}_clearConstraints(){for(const[,t]of Object.entries(this.tooltipInfos))t.unlockAllFields()}};t([d()],K.prototype,"_createOperationGeometry",void 0),t([d()],K.prototype,"_defaultElevation",null),t([d({value:!0})],K.prototype,"centered",null),t([d()],K.prototype,"cursor",null),t([d({nonNullable:!0})],K.prototype,"defaultZ",void 0),t([d()],K.prototype,"drawOperation",void 0),t([d({value:!0})],K.prototype,"enabled",null),t([d({value:!0})],K.prototype,"forceUniformSize",null),t([d({constructOnly:!0})],K.prototype,"geometryType",void 0),t([d()],K.prototype,"graphic",null),t([d({constructOnly:!0})],K.prototype,"graphicProperties",void 0),t([d()],K.prototype,"graphicSymbol",null),t([d({constructOnly:!0})],K.prototype,"hasZ",void 0),t([d({constructOnly:!0,type:I})],K.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],K.prototype,"geometryToPlace",void 0),t([d({constructOnly:!0})],K.prototype,"mode",void 0),t([d()],K.prototype,"snappingManager",void 0),t([d()],K.prototype,"snapToScene",void 0),t([d()],K.prototype,"tooltip",void 0),t([d()],K.prototype,"tooltipInfos",void 0),t([d({constructOnly:!0,type:j})],K.prototype,"tooltipOptions",void 0),t([d({readOnly:!0})],K.prototype,"type",void 0),t([d({readOnly:!0})],K.prototype,"updating",null),t([d({constructOnly:!0,nonNullable:!0})],K.prototype,"view",void 0),t([d()],K.prototype,"_tooltipInfo",null),t([d()],K.prototype,"_circleRadius",null),t([d()],K.prototype,"_xSize",null),t([d()],K.prototype,"_ySize",null),t([d()],K.prototype,"_fullGeometryArea",null),t([d()],K.prototype,"_vertexTooltipElevation",null),t([d()],K.prototype,"_elevationMode",null),K=t([m("esri.views.draw.DrawGraphicTool")],K);const Q="create-operation-graphic",W={outline:"outline-visual",regularVertices:"regular-vertices-visual",activeVertex:"active-vertex-visual"};function X(t){switch(t){case"point":case"polyline":case"polygon":case"multipoint":return t;case"circle":case"rectangle":return"segment";case"mesh":return"point"}}const Y=48;export{J as CreateOperationGeometry,K as DrawGraphicTool,X as geometryTypeToDrawOperationGeometryType};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as r}from"../../core/maybe.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as a,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as m}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as u}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as f,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as w,Component as V}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import{fromPoint as T,toDehydratedPoint as b}from"../interactive/sketch/normalizedPoint.js";import M from"../interactive/sketch/SketchLabelOptions.js";import P from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as D}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as C}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as I}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as E}from"../interactive/snapping/snappingUtils.js";let H=class extends(i.EventedMixin(t)){constructor(e){super(e),this._createOperationCompleted=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this.constraint=void 0,this.isDraped=!0,this.labelOptions=new M,this.tooltipOptions=new P,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=u(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,o="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new w(o,this.coordinateHelper)),this._snappingOperation=new I({view:t,constrainResult:e=>e?this._getEffectiveDrawSurface()?.constrainZ(e):void 0}),this.addHandles([a((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>r(e,t,m)}),a((()=>this.view.viewpoint),((e,t)=>{e&&t&&h(e,t)&&this._onViewpointChange()}))]),this._activeComponent=new V(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const c=this.segmentLabels;null!=c&&(c.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles([a((()=>this.labelOptions.enabled),(e=>{c.visible=e}),p),this.on("cursor-update",(()=>{const e=this.stagedVertex;c.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.addHandles(this._editGeometryOperations.on(["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})}const n=this._activeComponent.getLastVertex(),o=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=o&&null!=this.lastVertex&&m(this.lastVertex,o)||(this.lastVertex=o)})));const l=this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==e,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(e=>this._onImmediateClick(e))),l.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e))),a((()=>({cursor:this.cursor,loading:this.loading})),(({cursor:e,loading:t})=>{l.cursor=t?"progress":e}),p)]),E(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this._updatingHandles.addPromise(s(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){const e=this._snappingOperation.stagedPoint,{constraint:t,elevationInfo:i,view:n}=this;if(!e||!t)return e;const o=T(e,n,i),r=o?t.closestTo(o):void 0;return r?b(r,e.spatialReference):e}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this._updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return f(e,((e,t,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=C({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new D({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||o&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...r).next((e=>(o&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType;const i=this._snappingOperation,n=this._manipulator;n.dragging||this._pointerDownStates.has(e.pointerId)||n.grabbing||!n.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){const e=this._manipulator;this._stagedScreenPoint&&!e.dragging&&!e.grabbing&&e.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const o=this._screenToMap(e),r=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(null==o)return this.cursor=null,void i.abort();this.cursor="crosshair";const a=this.snappingManager;if(null==a)return this.stagedVertex=o,void i.abort();const p=this._getSnappingContext(t);this._updatingHandles.addPromise(s(i.snap({point:o,scenePoint:r},a,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&j(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new D({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function j(e,t,i){const n=e.x-t.x,o=e.y-t.y;return n*n+o*o<=i}e([l()],H.prototype,"_snappingOperation",void 0),e([l()],H.prototype,"_snappingEnabled",null),e([l()],H.prototype,"constraint",void 0),e([l()],H.prototype,"defaultZ",void 0),e([l()],H.prototype,"isDraped",void 0),e([l({value:y})],H.prototype,"drawingMode",null),e([l({constructOnly:!0})],H.prototype,"elevationDrawSurface",void 0),e([l({constructOnly:!0})],H.prototype,"elevationInfo",void 0),e([l({constructOnly:!0,type:M})],H.prototype,"labelOptions",void 0),e([l({constructOnly:!0,type:P})],H.prototype,"tooltipOptions",void 0),e([l({constructOnly:!0})],H.prototype,"geometryType",void 0),e([l({constructOnly:!0})],H.prototype,"hasM",void 0),e([l({constructOnly:!0})],H.prototype,"hasZ",void 0),e([l()],H.prototype,"cursor",void 0),e([l()],H.prototype,"loading",void 0),e([l({constructOnly:!0})],H.prototype,"manipulators",void 0),e([l({constructOnly:!0})],H.prototype,"drawSurface",void 0),e([l({constructOnly:!0})],H.prototype,"segmentLabels",void 0),e([l({constructOnly:!0})],H.prototype,"snappingManager",void 0),e([l({constructOnly:!0})],H.prototype,"snappingVisualizer",void 0),e([l()],H.prototype,"snapToSceneEnabled",void 0),e([l()],H.prototype,"stagedVertex",null),e([l()],H.prototype,"lastVertex",void 0),e([l()],H.prototype,"updating",null),e([l({constructOnly:!0})],H.prototype,"view",void 0),H=e([d("esri.views.draw.DrawOperation")],H);export{H as DrawOperation};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as r,equalsMaybe as o}from"../../core/maybe.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as a,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as m}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as f}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as x,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as w,Component as V}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import{fromPoint as T,toDehydratedPoint as b}from"../interactive/sketch/normalizedPoint.js";import M from"../interactive/sketch/SketchLabelOptions.js";import C from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as D}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as P}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as I}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as E}from"../interactive/snapping/snappingUtils.js";const H="crosshair",j="progress";let k=class extends(i.EventedMixin(t)){constructor(e){super(e),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this.constraint=void 0,this.isDraped=!0,this.labelOptions=new M,this.tooltipOptions=new C,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=m(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,r="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=f(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new w(r,this.coordinateHelper)),this._snappingOperation=new I({view:t,constrainResult:e=>e?this._getEffectiveDrawSurface()?.constrainZ(e):void 0}),this.addHandles([a((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>o(e,t,u)}),a((()=>this.view.viewpoint),((e,t)=>{e&&t&&h(e,t)&&this._onViewpointChange()}))]),this._activeComponent=new V(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const c=this.segmentLabels;null!=c&&(c.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles([a((()=>this.labelOptions.enabled),(e=>{c.visible=e}),p),this.on("cursor-update",(()=>{const e=this.stagedVertex;c.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.addHandles(this._editGeometryOperations.on(["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})}const n=this._activeComponent.getLastVertex(),r=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=r&&null!=this.lastVertex&&u(this.lastVertex,r)||(this.lastVertex=r)})));const l=this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==e,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(e=>this._onImmediateClick(e))),l.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e))),a((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:e})=>{l.cursor=e}),p)]),E(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this._updatingHandles.addPromise(s(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get effectiveCursor(){return this.loading?j:this._hideDefaultCursor?null:this.cursor||H}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){const e=this._snappingOperation.stagedPoint,{constraint:t,elevationInfo:i,view:n}=this;if(!e||!t)return e;const r=T(e,n,i),o=r?t.closestTo(r):void 0;return o?b(o,e.spatialReference):e}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this._updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return x(e,((e,t,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:o,cancelSnapping:s}=P({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new D({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||r&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...o).next((e=>(r&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType;const i=this._snappingOperation,n=this._manipulator;n.dragging||this._pointerDownStates.has(e.pointerId)||n.grabbing||!n.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){const e=this._manipulator;this._stagedScreenPoint&&!e.dragging&&!e.grabbing&&e.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const r=this._screenToMap(e),o=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(null==r)return this._hideDefaultCursor=!0,void i.abort();this._hideDefaultCursor=!1;const a=this.snappingManager;if(null==a)return this.stagedVertex=r,void i.abort();const p=this._getSnappingContext(t);this._updatingHandles.addPromise(s(i.snap({point:r,scenePoint:o},a,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&G(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new D({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function G(e,t,i){const n=e.x-t.x,r=e.y-t.y;return n*n+r*r<=i}e([l()],k.prototype,"_hideDefaultCursor",void 0),e([l()],k.prototype,"_snappingOperation",void 0),e([l()],k.prototype,"_snappingEnabled",null),e([l({constructOnly:!0})],k.prototype,"graphic",void 0),e([l()],k.prototype,"constraint",void 0),e([l()],k.prototype,"defaultZ",void 0),e([l()],k.prototype,"isDraped",void 0),e([l({value:y})],k.prototype,"drawingMode",null),e([l({constructOnly:!0})],k.prototype,"elevationDrawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"elevationInfo",void 0),e([l({constructOnly:!0,type:M})],k.prototype,"labelOptions",void 0),e([l({constructOnly:!0,type:C})],k.prototype,"tooltipOptions",void 0),e([l({constructOnly:!0})],k.prototype,"geometryType",void 0),e([l({constructOnly:!0})],k.prototype,"hasM",void 0),e([l({constructOnly:!0})],k.prototype,"hasZ",void 0),e([l()],k.prototype,"cursor",void 0),e([l()],k.prototype,"effectiveCursor",null),e([l()],k.prototype,"loading",void 0),e([l({constructOnly:!0})],k.prototype,"manipulators",void 0),e([l({constructOnly:!0})],k.prototype,"drawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"segmentLabels",void 0),e([l({constructOnly:!0})],k.prototype,"snappingManager",void 0),e([l({constructOnly:!0})],k.prototype,"snappingVisualizer",void 0),e([l()],k.prototype,"snapToSceneEnabled",void 0),e([l()],k.prototype,"stagedVertex",null),e([l()],k.prototype,"lastVertex",void 0),e([l()],k.prototype,"updating",null),e([l({constructOnly:!0})],k.prototype,"view",void 0),k=e([d("esri.views.draw.DrawOperation")],k);export{k as DrawOperation,H as defaultCursor,j as defaultLoadingCursor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import e from"../../../Graphic.js";import i from"../../../core/Evented.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{zeroMeters as o}from"../../../core/quantityUtils.js";import{when as r,watch as a,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{create as l}from"../../../geometry/support/aaBoundingRect.js";import{getRingsOrPathsBounds as p}from"../../../geometry/support/boundsUtils.js";import{geometryToCoordinates as _}from"../../../geometry/support/coordsUtils.js";import d from"../../../geometry/support/rotate.js";import u from"../../../symbols/SimpleFillSymbol.js";import g from"../../../symbols/SimpleLineSymbol.js";import m from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as v,scale as y,getScaleRatio as f,getRotationAngle as G}from"./drawUtils.js";import b from"./GraphicMover.js";import w from"./HighlightHelper.js";import{addUniqueLayer as x}from"./layerUtils.js";import{settings as S}from"./settings.js";import k from"../../interactive/sketch/SketchTooltipOptions.js";import{ExtentRotateTooltipInfo as R,ExtentScaleTooltipInfo as I}from"../../interactive/tooltip/ExtentTooltipInfos.js";import{Tooltip as M}from"../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as O}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoDistanceBetweenPoints2D as C}from"../../support/automaticLengthMeasurementUtils.js";import H from"../../../geometry/Point.js";import j from"../../../geometry/Polygon.js";import T from"../../../geometry/Polyline.js";class E{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move-start"}}class B{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move"}}class L{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move-stop"}}class z{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate-start"}}class Y{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate"}}class N{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate-stop"}}class U{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale-start"}}class A{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale"}}class P{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale-stop"}}const X=S.transformGraphics,D={centerIndicator:new m({style:"cross",size:X.center.size,color:X.center.color}),fill:{default:new u({color:X.fill.color,outline:{color:X.fill.outlineColor,join:"round",width:1}}),active:new u({color:X.fill.stagedColor,outline:{color:X.fill.outlineColor,join:"round",style:"dash",width:1}})},handles:{default:new m({style:"square",size:X.vertex.size,color:X.vertex.color,outline:{color:X.vertex.outlineColor,width:1}}),hover:new m({style:"square",size:X.vertex.hoverSize,color:X.vertex.hoverColor,outline:{color:X.vertex.hoverOutlineColor,width:1}})},rotator:{default:new m({style:"circle",size:X.vertex.size,color:X.vertex.color,outline:{color:X.vertex.outlineColor,width:1}}),hover:new m({style:"circle",size:X.vertex.hoverSize,color:X.vertex.hoverColor,outline:{color:X.vertex.hoverOutlineColor,width:1}})},rotatorLine:new g({color:X.line.color,width:1})};let V=class extends i.EventedAccessor{constructor(t){super(t),this._activeHandleGraphic=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._centerGraphic=null,this._backgroundGraphic=null,this._vertexGraphics=[],this._rotateHandleGraphic=null,this._rotateGraphicOffset=20,this._angleOfRotation=0,this._rotateLineGraphic=null,this._startInfo=null,this._tooltip=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this.type="box",this.callbacks={onMoveStart(){},onMove(){},onMoveStop(){},onScaleStart(){},onScale(){},onScaleStop(){},onRotateStart(){},onRotate(){},onRotateStop(){},onGraphicClick(){}},this.enableMovement=!0,this.enableRotation=!0,this.enableScaling=!0,this.graphics=[],this.highlightsEnabled=!0,this.layer=null,this.preserveAspectRatio=!1,this.showCenterGraphic=!0,this.symbols=D,this.tooltipOptions=new k,this.view=null,this._getBounds=(()=>{const t=l();return(e,i)=>{e[0]=Number.POSITIVE_INFINITY,e[1]=Number.POSITIVE_INFINITY,e[2]=Number.NEGATIVE_INFINITY,e[3]=Number.NEGATIVE_INFINITY;for(const s of i){if(!s)continue;let i,o,r,a;if("point"===s.type)i=r=s.x,o=a=s.y;else if("multipoint"===s.type){const e=_(s);[i,o,r,a]=p(t,[e])}else if("extent"===s.type)[i,o,r,a]=[s.xmin,s.ymin,s.xmax,s.ymax];else{const e=_(s);[i,o,r,a]=p(t,e)}e[0]=Math.min(i,e[0]),e[1]=Math.min(o,e[1]),e[2]=Math.max(r,e[2]),e[3]=Math.max(a,e[3])}return e}})()}initialize(){const t=this.view;this._highlightHelper=new w({view:t}),this._tooltip=new M({view:t}),this._setup(),this.addHandles([r((()=>t?.ready),(()=>{const{layer:t,view:e}=this;x(e,t)}),{once:!0,initial:!0}),a((()=>this.preserveAspectRatio),(()=>{this._activeHandleGraphic&&(this._scaleGraphic(this._activeHandleGraphic),this._updateGraphics(),this._updateTooltip(this._activeHandleGraphic))})),a((()=>t?.scale),(()=>{this._updateRotateGraphic(),this._updateRotateLineGraphic()})),a((()=>this.graphics),(()=>this.refresh())),a((()=>this.layer),((t,e)=>{e&&this._resetGraphics(e),this.refresh()})),a((()=>this.highlightsEnabled),(()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()})),a((()=>this.tooltipOptions.enabled),(t=>{this._tooltip=t?new M({view:this.view}):s(this._tooltip)}),h),this.on("move-start",(t=>this.callbacks?.onMoveStart?.(t))),this.on("move",(t=>this.callbacks?.onMove?.(t))),this.on("move-stop",(t=>this.callbacks?.onMoveStop?.(t))),this.on("rotate-start",(t=>this.callbacks?.onRotateStart?.(t))),this.on("rotate",(t=>this.callbacks?.onRotate?.(t))),this.on("rotate-stop",(t=>this.callbacks?.onRotateStop?.(t))),this.on("scale-start",(t=>this.callbacks?.onScaleStart?.(t))),this.on("scale",(t=>this.callbacks?.onScale?.(t))),this.on("scale-stop",(t=>this.callbacks?.onScaleStop?.(t)))])}destroy(){this._reset(),this._tooltip=s(this._tooltip)}get state(){const t=this.view?.ready??!1,e=this.graphics.length&&this.layer;return t&&e?"active":t?"ready":"disabled"}isUIGraphic(t){return this._vertexGraphics.includes(t)||t===this._backgroundGraphic||t===this._centerGraphic||t===this._rotateHandleGraphic||t===this._rotateLineGraphic}move(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=v(s,t,e,this.view);i.geometry=o}this.refresh(),this.emit("move-stop",new L(this.graphics,null,t,e))}}scale(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=y(s,t,e);i.geometry=o}this.refresh(),this.emit("scale-stop",new P(this.graphics,null,t,e))}}rotate(t,e){if(this._mover&&this.graphics.length){if(!e){const t=this._vertexGraphics[1].geometry.x,i=this._vertexGraphics[3].geometry.y;e=new H(t,i,this.view.spatialReference)}for(const i of this.graphics){const s=i.geometry,o=d(s,t,e);i.geometry=o}this.refresh(),this.emit("rotate-stop",new N(this.graphics,null,t))}}refresh(){this._reset(),this._setup()}reset(){this.graphics=[]}_setup(){"active"===this.state&&(this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._updateGraphics())}_reset(){this._highlightHelper?.removeAll(),this._resetGraphicStateVars(),this._resetGraphics(),this._updateTooltip(),this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetGraphicStateVars(){this._startInfo=null,this._activeHandleGraphic=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this._angleOfRotation=0}_resetGraphics(t){(t=t||this.layer)&&(t.removeMany(this._vertexGraphics),t.remove(this._backgroundGraphic),t.remove(this._centerGraphic),t.remove(this._rotateHandleGraphic),t.remove(this._rotateLineGraphic)),this._vertexGraphics=[],this._backgroundGraphic=null,this._centerGraphic=null,this._rotateHandleGraphic=null,this._rotateLineGraphic=null}_setupMover(){let t=[];this.enableScaling&&(t=t.concat(this._vertexGraphics)),this.enableMovement&&(t=t.concat(this.graphics,this._backgroundGraphic)),this.enableRotation&&t.push(this._rotateHandleGraphic),this.showCenterGraphic&&t.push(this._centerGraphic),this._mover=new b({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,view:this.view,graphics:t,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_getStartInfo(t){const[e,i,s,o]=this._getBoxBounds(l()),r=Math.abs(s-e),a=Math.abs(o-i),h=(s+e)/2,c=(o+i)/2,{x:n,y:p}=t.geometry;return{width:r,height:a,centerX:h,centerY:c,startX:n,startY:p,graphicInfos:this._getGraphicInfos(),box:this._backgroundGraphic.geometry,rotate:this._rotateHandleGraphic.geometry}}_getGraphicInfos(){return this.graphics.map((t=>this._getGraphicInfo(t)))}_getGraphicInfo(t){const e=t.geometry,[i,s,o,r]=this._getBounds(l(),[e]);return{width:Math.abs(o-i),height:Math.abs(r-s),centerX:(o+i)/2,centerY:(r+s)/2,geometry:e}}_onGraphicClickCallback(t){t.viewEvent.stopPropagation(),this.emit("graphic-click",t),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(t)}_onGraphicMoveStartCallback(t){const{_angleOfRotation:e,_xScale:i,_yScale:s,_backgroundGraphic:o,_vertexGraphics:r,_rotateHandleGraphic:a,symbols:h}=this,c=t.graphic;this._resetGraphicStateVars(),this._hideGraphicsBeforeUpdate(),o.symbol=h.fill.active,this._startInfo=this._getStartInfo(c),this._updateTooltip(c,t.viewEvent),c===a?(this.view.cursor="grabbing",this.emit("rotate-start",new z(this.graphics,c,e))):r.includes(c)?(this._activeHandleGraphic=c,this.emit("scale-start",new U(this.graphics,c,i,s))):this.emit("move-start",new E(this.graphics,c,t.dx,t.dy))}_onGraphicMoveCallback(t){const e=t.graphic;if(this._startInfo)if(this._vertexGraphics.includes(e))this._scaleGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("scale",new A(this.graphics,e,this._xScale,this._yScale));else if(e===this._rotateHandleGraphic)this._rotateGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("rotate",new Y(this.graphics,e,this._angleOfRotation));else{const{dx:i,dy:s}=t;this._totalDx+=i,this._totalDy+=s,this._moveGraphic(e,i,s),this._updateTooltip(e,t.viewEvent),this.emit("move",new B(this.graphics,e,i,s))}}_onGraphicMoveStopCallback(t){const e=t.graphic;if(!this._startInfo)return void this.refresh();const{_angleOfRotation:i,_totalDx:s,_totalDy:o,_xScale:r,_yScale:a,_vertexGraphics:h,_rotateHandleGraphic:c}=this;this.refresh(),e===c?(this.view.cursor="pointer",this.emit("rotate-stop",new N(this.graphics,e,i))):h.includes(e)?this.emit("scale-stop",new P(this.graphics,e,r,a)):this.emit("move-stop",new L(this.graphics,e,s,o))}_onGraphicPointerOverCallback(t){const{_backgroundGraphic:e,_vertexGraphics:i,graphics:s,_rotateHandleGraphic:o,symbols:r,view:a}=this,h=t.graphic;if(h===o)return o.symbol=r.rotator.hover,a.cursor="pointer",void this._updateTooltip(h);if(s.includes(h)||h===e)return void(a.cursor="move");if(!i.includes(h))return void(a.cursor="pointer");this._updateTooltip(h),t.graphic.symbol=r.handles.hover;const c=a.rotation;let n,l=t.index;switch(l<8&&(c>=0&&c<45?l%=8:l=c>=45&&c<90?(l+1)%8:c>=90&&c<135?(l+2)%8:c>=135&&c<180?(l+3)%8:c>=180&&c<225?(l+4)%8:c>=225&&c<270?(l+5)%8:c>=270&&c<315?(l+6)%8:(l+7)%8),l){case 0:case 4:n="nwse-resize";break;case 1:case 5:n="ns-resize";break;case 2:case 6:n="nesw-resize";break;case 3:case 7:n="ew-resize";break;default:n="pointer"}a.cursor=n}_onGraphicPointerOutCallback(t){const{_vertexGraphics:e,_rotateHandleGraphic:i,symbols:s,view:o}=this;t.graphic===i?i.symbol=s.rotator.default:e.includes(t.graphic)&&(t.graphic.symbol=s.handles.default),o.cursor="default",this._updateTooltip()}_scaleGraphic(t){const{_startInfo:e,_vertexGraphics:i,preserveAspectRatio:s,view:o}=this,{centerX:r,centerY:a,startX:h,startY:c}=e,{resolution:n,transform:l}=o.state,p=i.indexOf(t);1!==p&&5!==p||this._updateX(t,r),3!==p&&7!==p||this._updateY(t,a);const{x:_,y:d}=t.geometry,u=l[0]*_+l[2]*d+l[4],g=l[1]*_+l[3]*d+l[5],m=e.graphicInfos?.map((t=>t.geometry))??[];if(s){const t=l[0]*r+l[2]*a+l[4],e=l[1]*r+l[3]*a+l[5],i=l[0]*h+l[2]*c+l[4],s=l[1]*h+l[3]*c+l[5];this._xScale=this._yScale=f(t,e,i,s,u,g);for(const o of m){const t=m.indexOf(o);this.graphics[t].geometry=y(o,this._xScale,this._yScale,[r,a])}this._updateBackgroundGraphic()}else{const{width:t,height:i}=e;let s=_-h,l=c-d;if(1===p||5===p?s=0:3!==p&&7!==p||(l=0),0===s&&0===l)return;const u=t+(h>r?s:-1*s),g=i+(c<a?l:-1*l),f=r+s/2,G=a+l/2;this._xScale=u/t||1,this._yScale=g/i||1,1===p||5===p?this._xScale=1:3!==p&&7!==p||(this._yScale=1);const b=(f-r)/n,w=(G-a)/n,x=y(e.box,this._xScale,this._yScale);this._backgroundGraphic.geometry=v(x,b,w,o,!0);const{centerX:S,centerY:k}=this._getGraphicInfo(this._backgroundGraphic),R=(S-r)/n,I=-1*(k-a)/n;for(const e of m){const t=m.indexOf(e),i=y(e,this._xScale,this._yScale,[r,a]);this.graphics[t].geometry=v(i,R,I,o,!0)}this._centerGraphic.geometry=new H(S,k,o.spatialReference)}}_rotateGraphic(t){const{centerX:e,centerY:i,startX:s,startY:o,box:r,rotate:a}=this._startInfo,h=this.view.spatialReference,c=new H(s,o,h),n=new H(e,i,h),l=t.geometry;this._angleOfRotation=G(c,l,n);const p=this._startInfo.graphicInfos?.map((t=>t.geometry))??[];for(const _ of p){const t=p.indexOf(_),e=d(_,this._angleOfRotation,n);this.graphics[t].geometry=e}this._backgroundGraphic.geometry=d(r,this._angleOfRotation,n),this._rotateHandleGraphic.geometry=d(a,this._angleOfRotation,n)}_moveGraphic(t,e,i){if(this.graphics.includes(t)){const s=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=v(s,e,i,this.view);for(const o of this.graphics)o!==t&&(o.geometry=v(o.geometry,e,i,this.view))}else if(t===this._centerGraphic){const t=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=v(t,e,i,this.view)}if(t===this._backgroundGraphic||t===this._centerGraphic)for(const s of this.graphics)s.geometry=v(s.geometry,e,i,this.view)}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper?.add(this.graphics)}_setupGraphics(){const{_graphicAttributes:t,symbols:i}=this;this._centerGraphic=new e(null,i.centerIndicator,t),this.showCenterGraphic&&this.layer.add(this._centerGraphic),this._backgroundGraphic=new e(null,i.fill.default,t),this.layer.add(this._backgroundGraphic),this._rotateLineGraphic=new e(null,i.rotatorLine,t),this._rotateHandleGraphic=new e(null,i.rotator.default,t),this.enableRotation&&!this._hasExtentGraphic()&&this.layer.addMany([this._rotateLineGraphic,this._rotateHandleGraphic]);for(let s=0;s<8;s++)this._vertexGraphics.push(new e(null,i.handles.default,t));this.enableScaling&&this.layer.addMany(this._vertexGraphics)}_updateGraphics(){this._updateBackgroundGraphic(),this._updateHandleGraphics(),this._updateCenterGraphic(),this._updateRotateGraphic(),this._updateRotateLineGraphic()}_hideGraphicsBeforeUpdate(){this._centerGraphic.visible=!1,this._rotateHandleGraphic.visible=!1,this._rotateLineGraphic.visible=!1,this._vertexGraphics.forEach((t=>t.visible=!1))}_updateHandleGraphics(){const t=this._getCoordinates(!0);this._vertexGraphics.forEach(((e,i)=>{const[s,o]=t[i];this._updateXY(e,s,o)}))}_updateBackgroundGraphic(){const t=this._getCoordinates();this._backgroundGraphic.geometry=new j({rings:t,spatialReference:this.view.spatialReference})}_updateCenterGraphic(){const[t,e,i,s]=this._getBoxBounds(l()),o=(i+t)/2,r=(s+e)/2;this._centerGraphic.geometry=new H(o,r,this.view.spatialReference)}_updateRotateGraphic(){if(!this._vertexGraphics.length)return;const{x:t,y:e}=this._vertexGraphics[1].geometry,i=e+this.view.state.resolution*this._rotateGraphicOffset;this._rotateHandleGraphic.geometry=new H(t,i,this.view.spatialReference)}_updateRotateLineGraphic(){if(!this._vertexGraphics.length||!this._rotateHandleGraphic?.geometry)return;const t=this._vertexGraphics[1].geometry,e=this._rotateHandleGraphic.geometry;this._rotateLineGraphic.geometry=new T({paths:[[t.x,t.y],[e.x,e.y]],spatialReference:this.view.spatialReference})}_updateXY(t,e,i){t.geometry=new H(e,i,this.view.spatialReference)}_updateX(t,e){const i=t.geometry.y;t.geometry=new H(e,i,this.view.spatialReference)}_updateY(t,e){const i=t.geometry.x;t.geometry=new H(i,e,this.view.spatialReference)}_hasExtentGraphic(){return this.graphics.some((t=>null!=t?.geometry&&"extent"===t.geometry.type))}_getBoxBounds(t){const e=this.graphics.map((t=>t.geometry));return this._getBounds(t,e)}_getCoordinates(t){const[e,i,s,o]=this._getBoxBounds(l());if(t){const t=(e+s)/2,r=(o+i)/2;return[[e,o],[t,o],[s,o],[s,r],[s,i],[t,i],[e,i],[e,r]]}return[[e,o],[s,o],[s,i],[e,i]]}_updateTooltip(t,e){if(null==this._tooltip)return;if(!t)return void this._tooltip.clear();const{_backgroundGraphic:i,graphics:s,_vertexGraphics:o,_rotateHandleGraphic:r}=this;t===r?this._updateRotateTooltip():o.includes(t)?this._updateScaleTooltip():(s.includes(t)||t===i)&&this._updateMoveTooltip(e)}_updateRotateTooltip(){null!=this._tooltip&&(this._tooltip.info=new R({tooltipOptions:this.tooltipOptions,angle:-this._angleOfRotation}))}_updateScaleTooltip(){const{_tooltip:t,_xScale:e,_yScale:i,tooltipOptions:s,view:o}=this;if(null==t)return;const r=o.spatialReference,a=this._getCoordinates(),h=new H(a[0][0],a[0][1],r),c=new H(a[1][0],a[1][1],r),n=new H(a[2][0],a[2][1],r),l=C(h,c),p=C(c,n);if(null==l||null==p)return;const _=Math.abs(e),d=Math.abs(i);t.info=new I({tooltipOptions:s,xScale:_,yScale:d,xSize:l,ySize:p})}_updateMoveTooltip(t){const{_tooltip:e,tooltipOptions:i,view:s}=this;if(null==e)return;const r=new O({tooltipOptions:i});if(t){const{x:e,y:i}=t.origin,a=s.toMap(t),h=s.toMap({x:e,y:i}),c=C(h,a);r.distance=null!=c?c:o}e.info=r}};t([c()],V.prototype,"_tooltip",void 0),t([c({readOnly:!0})],V.prototype,"type",void 0),t([c()],V.prototype,"callbacks",void 0),t([c()],V.prototype,"enableMovement",void 0),t([c()],V.prototype,"enableRotation",void 0),t([c()],V.prototype,"enableScaling",void 0),t([c()],V.prototype,"graphics",void 0),t([c()],V.prototype,"highlightsEnabled",void 0),t([c()],V.prototype,"layer",void 0),t([c()],V.prototype,"preserveAspectRatio",void 0),t([c()],V.prototype,"showCenterGraphic",void 0),t([c({readOnly:!0})],V.prototype,"state",null),t([c({value:D,cast(t){const{centerIndicator:e=D.centerIndicator,fill:i=D.fill,handles:s=D.handles,rotator:o=D.rotator,rotatorLine:r=D.rotatorLine}=t||{};return{centerIndicator:e,fill:i,handles:s,rotator:o,rotatorLine:r}}})],V.prototype,"symbols",void 0),t([c({type:k})],V.prototype,"tooltipOptions",void 0),t([c({constructOnly:!0})],V.prototype,"view",void 0),V=t([n("esri.views.draw.support.Box")],V);const F=V;export{F as default};
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import e from"../../../Graphic.js";import i from"../../../core/Evented.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{zeroMeters as o}from"../../../core/quantityUtils.js";import{when as r,watch as a,syncAndInitial as h,initial as c}from"../../../core/reactiveUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{create as p}from"../../../geometry/support/aaBoundingRect.js";import{getRingsOrPathsBounds as _}from"../../../geometry/support/boundsUtils.js";import{geometryToCoordinates as d}from"../../../geometry/support/coordsUtils.js";import u from"../../../geometry/support/rotate.js";import m from"../../../symbols/SimpleFillSymbol.js";import g from"../../../symbols/SimpleLineSymbol.js";import v from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as y,scale as f,getScaleRatio as G,getRotationAngle as b}from"./drawUtils.js";import w from"./GraphicMover.js";import x from"./HighlightHelper.js";import{addUniqueLayer as S}from"./layerUtils.js";import{settings as k}from"./settings.js";import R from"../../interactive/sketch/SketchTooltipOptions.js";import{ExtentRotateTooltipInfo as I,ExtentScaleTooltipInfo as M}from"../../interactive/tooltip/ExtentTooltipInfos.js";import{Tooltip as C}from"../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as H}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoDistanceBetweenPoints2D as O}from"../../support/automaticLengthMeasurementUtils.js";import T from"../../../geometry/Point.js";import j from"../../../geometry/Polygon.js";import E from"../../../geometry/Polyline.js";class L{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move-start"}}class B{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move"}}class z{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move-stop"}}class Y{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate-start"}}class N{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate"}}class U{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate-stop"}}class A{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale-start"}}class P{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale"}}class X{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale-stop"}}const D=k.transformGraphics,F={centerIndicator:new v({style:"cross",size:D.center.size,color:D.center.color}),fill:{default:new m({color:D.fill.color,outline:{color:D.fill.outlineColor,join:"round",width:1}}),active:new m({color:D.fill.stagedColor,outline:{color:D.fill.outlineColor,join:"round",style:"dash",width:1}})},handles:{default:new v({style:"square",size:D.vertex.size,color:D.vertex.color,outline:{color:D.vertex.outlineColor,width:1}}),hover:new v({style:"square",size:D.vertex.hoverSize,color:D.vertex.hoverColor,outline:{color:D.vertex.hoverOutlineColor,width:1}})},rotator:{default:new v({style:"circle",size:D.vertex.size,color:D.vertex.color,outline:{color:D.vertex.outlineColor,width:1}}),hover:new v({style:"circle",size:D.vertex.hoverSize,color:D.vertex.hoverColor,outline:{color:D.vertex.hoverOutlineColor,width:1}})},rotatorLine:new g({color:D.line.color,width:1})};let V=class extends i.EventedAccessor{constructor(t){super(t),this._activeHandleGraphic=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._centerGraphic=null,this._backgroundGraphic=null,this._vertexGraphics=[],this._rotateHandleGraphic=null,this._rotateGraphicOffset=20,this._angleOfRotation=0,this._rotateLineGraphic=null,this._startInfo=null,this._tooltip=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this.type="box",this.callbacks={onMoveStart(){},onMove(){},onMoveStop(){},onScaleStart(){},onScale(){},onScaleStop(){},onRotateStart(){},onRotate(){},onRotateStop(){},onGraphicClick(){}},this.enableMovement=!0,this.enableRotation=!0,this.enableScaling=!0,this.graphics=[],this.highlightsEnabled=!0,this.layer=null,this.preserveAspectRatio=!1,this.showCenterGraphic=!0,this.symbols=F,this.tooltipOptions=new R,this.view=null,this._getBounds=(()=>{const t=p();return(e,i)=>{e[0]=Number.POSITIVE_INFINITY,e[1]=Number.POSITIVE_INFINITY,e[2]=Number.NEGATIVE_INFINITY,e[3]=Number.NEGATIVE_INFINITY;for(const s of i){if(!s)continue;let i,o,r,a;if("point"===s.type)i=r=s.x,o=a=s.y;else if("multipoint"===s.type){const e=d(s);[i,o,r,a]=_(t,[e])}else if("extent"===s.type)[i,o,r,a]=[s.xmin,s.ymin,s.xmax,s.ymax];else{const e=d(s);[i,o,r,a]=_(t,e)}e[0]=Math.min(i,e[0]),e[1]=Math.min(o,e[1]),e[2]=Math.max(r,e[2]),e[3]=Math.max(a,e[3])}return e}})()}initialize(){const t=this.view;this._highlightHelper=new x({view:t}),this._tooltip=new C({view:t}),this._setup(),this.addHandles([r((()=>t?.ready),(()=>{const{layer:t,view:e}=this;S(e,t)}),{once:!0,initial:!0}),a((()=>this.preserveAspectRatio),(()=>{this._activeHandleGraphic&&(this._scaleGraphic(this._activeHandleGraphic),this._updateGraphics(),this._updateTooltip(this._activeHandleGraphic))})),a((()=>t?.scale),(()=>{this._updateRotateGraphic(),this._updateRotateLineGraphic()})),a((()=>this.graphics),(()=>this.refresh())),a((()=>this.layer),((t,e)=>{e&&this._resetGraphics(e),this.refresh()})),a((()=>this.highlightsEnabled),(()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()})),a((()=>this.tooltipOptions.enabled),(t=>{this._tooltip=t?new C({view:this.view}):s(this._tooltip)}),h),a((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),c),this.on("move-start",(t=>this.callbacks?.onMoveStart?.(t))),this.on("move",(t=>this.callbacks?.onMove?.(t))),this.on("move-stop",(t=>this.callbacks?.onMoveStop?.(t))),this.on("rotate-start",(t=>this.callbacks?.onRotateStart?.(t))),this.on("rotate",(t=>this.callbacks?.onRotate?.(t))),this.on("rotate-stop",(t=>this.callbacks?.onRotateStop?.(t))),this.on("scale-start",(t=>this.callbacks?.onScaleStart?.(t))),this.on("scale",(t=>this.callbacks?.onScale?.(t))),this.on("scale-stop",(t=>this.callbacks?.onScaleStop?.(t)))])}destroy(){this._reset(),this._tooltip=s(this._tooltip)}get state(){const t=this.view?.ready??!1,e=this.graphics.length&&this.layer;return t&&e?"active":t?"ready":"disabled"}isUIGraphic(t){return this._vertexGraphics.includes(t)||t===this._backgroundGraphic||t===this._centerGraphic||t===this._rotateHandleGraphic||t===this._rotateLineGraphic}move(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=y(s,t,e,this.view);i.geometry=o}this.refresh(),this.emit("move-stop",new z(this.graphics,null,t,e))}}scale(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=f(s,t,e);i.geometry=o}this.refresh(),this.emit("scale-stop",new X(this.graphics,null,t,e))}}rotate(t,e){if(this._mover&&this.graphics.length){if(!e){const t=this._vertexGraphics[1].geometry.x,i=this._vertexGraphics[3].geometry.y;e=new T(t,i,this.view.spatialReference)}for(const i of this.graphics){const s=i.geometry,o=u(s,t,e);i.geometry=o}this.refresh(),this.emit("rotate-stop",new U(this.graphics,null,t))}}refresh(){this._reset(),this._setup()}reset(){this.graphics=[]}_setup(){"active"===this.state&&(this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._updateGraphics())}_reset(){this._highlightHelper?.removeAll(),this._resetGraphicStateVars(),this._resetGraphics(),this._updateTooltip(),this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetGraphicStateVars(){this._startInfo=null,this._activeHandleGraphic=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this._angleOfRotation=0}_resetGraphics(t){(t=t||this.layer)&&(t.removeMany(this._vertexGraphics),t.remove(this._backgroundGraphic),t.remove(this._centerGraphic),t.remove(this._rotateHandleGraphic),t.remove(this._rotateLineGraphic)),this._vertexGraphics=[],this._backgroundGraphic=null,this._centerGraphic=null,this._rotateHandleGraphic=null,this._rotateLineGraphic=null}_setupMover(){let t=[];this.enableScaling&&(t=t.concat(this._vertexGraphics)),this.enableMovement&&(t=t.concat(this.graphics,this._backgroundGraphic)),this.enableRotation&&t.push(this._rotateHandleGraphic),this.showCenterGraphic&&t.push(this._centerGraphic),this._mover=new w({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,view:this.view,graphics:t,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_getStartInfo(t){const[e,i,s,o]=this._getBoxBounds(p()),r=Math.abs(s-e),a=Math.abs(o-i),h=(s+e)/2,c=(o+i)/2,{x:l,y:n}=t.geometry;return{width:r,height:a,centerX:h,centerY:c,startX:l,startY:n,graphicInfos:this._getGraphicInfos(),box:this._backgroundGraphic.geometry,rotate:this._rotateHandleGraphic.geometry}}_getGraphicInfos(){return this.graphics.map((t=>this._getGraphicInfo(t)))}_getGraphicInfo(t){const e=t.geometry,[i,s,o,r]=this._getBounds(p(),[e]);return{width:Math.abs(o-i),height:Math.abs(r-s),centerX:(o+i)/2,centerY:(r+s)/2,geometry:e}}_onGraphicClickCallback(t){t.viewEvent.stopPropagation(),this.emit("graphic-click",t),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(t)}_onGraphicMoveStartCallback(t){const{_angleOfRotation:e,_xScale:i,_yScale:s,_backgroundGraphic:o,_vertexGraphics:r,_rotateHandleGraphic:a,symbols:h}=this,c=t.graphic;this._resetGraphicStateVars(),this._hideGraphicsBeforeUpdate(),o.symbol=h.fill.active,this._startInfo=this._getStartInfo(c),this._updateTooltip(c,t.viewEvent),c===a?(this.view.cursor="grabbing",this.emit("rotate-start",new Y(this.graphics,c,e))):r.includes(c)?(this._activeHandleGraphic=c,this.emit("scale-start",new A(this.graphics,c,i,s))):this.emit("move-start",new L(this.graphics,c,t.dx,t.dy))}_onGraphicMoveCallback(t){const e=t.graphic;if(this._startInfo)if(this._vertexGraphics.includes(e))this._scaleGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("scale",new P(this.graphics,e,this._xScale,this._yScale));else if(e===this._rotateHandleGraphic)this._rotateGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("rotate",new N(this.graphics,e,this._angleOfRotation));else{const{dx:i,dy:s}=t;this._totalDx+=i,this._totalDy+=s,this._moveGraphic(e,i,s),this._updateTooltip(e,t.viewEvent),this.emit("move",new B(this.graphics,e,i,s))}}_onGraphicMoveStopCallback(t){const e=t.graphic;if(!this._startInfo)return void this.refresh();const{_angleOfRotation:i,_totalDx:s,_totalDy:o,_xScale:r,_yScale:a,_vertexGraphics:h,_rotateHandleGraphic:c}=this;this.refresh(),e===c?(this.view.cursor="pointer",this.emit("rotate-stop",new U(this.graphics,e,i))):h.includes(e)?this.emit("scale-stop",new X(this.graphics,e,r,a)):this.emit("move-stop",new z(this.graphics,e,s,o))}_onGraphicPointerOverCallback(t){const{_backgroundGraphic:e,_vertexGraphics:i,graphics:s,_rotateHandleGraphic:o,symbols:r,view:a}=this,h=t.graphic;if(this._hoveredGraphic=h,h===o)return o.symbol=r.rotator.hover,a.cursor="pointer",void this._updateTooltip(h);if(s.includes(h)||h===e)return void(a.cursor="move");if(!i.includes(h))return void(a.cursor="pointer");this._updateTooltip(h),t.graphic.symbol=r.handles.hover;const c=a.rotation;let l,n=t.index;switch(n<8&&(c>=0&&c<45?n%=8:n=c>=45&&c<90?(n+1)%8:c>=90&&c<135?(n+2)%8:c>=135&&c<180?(n+3)%8:c>=180&&c<225?(n+4)%8:c>=225&&c<270?(n+5)%8:c>=270&&c<315?(n+6)%8:(n+7)%8),n){case 0:case 4:l="nwse-resize";break;case 1:case 5:l="ns-resize";break;case 2:case 6:l="nesw-resize";break;case 3:case 7:l="ew-resize";break;default:l="pointer"}a.cursor=l}_onGraphicPointerOutCallback(t){const{_vertexGraphics:e,_rotateHandleGraphic:i,symbols:s,view:o}=this;this._hoveredGraphic=null,t.graphic===i?i.symbol=s.rotator.default:e.includes(t.graphic)&&(t.graphic.symbol=s.handles.default),o.cursor="default",this._updateTooltip()}_scaleGraphic(t){const{_startInfo:e,_vertexGraphics:i,preserveAspectRatio:s,view:o}=this,{centerX:r,centerY:a,startX:h,startY:c}=e,{resolution:l,transform:n}=o.state,p=i.indexOf(t);1!==p&&5!==p||this._updateX(t,r),3!==p&&7!==p||this._updateY(t,a);const{x:_,y:d}=t.geometry,u=n[0]*_+n[2]*d+n[4],m=n[1]*_+n[3]*d+n[5],g=e.graphicInfos?.map((t=>t.geometry))??[];if(s){const t=n[0]*r+n[2]*a+n[4],e=n[1]*r+n[3]*a+n[5],i=n[0]*h+n[2]*c+n[4],s=n[1]*h+n[3]*c+n[5];this._xScale=this._yScale=G(t,e,i,s,u,m);for(const o of g){const t=g.indexOf(o);this.graphics[t].geometry=f(o,this._xScale,this._yScale,[r,a])}this._updateBackgroundGraphic()}else{const{width:t,height:i}=e;let s=_-h,n=c-d;if(1===p||5===p?s=0:3!==p&&7!==p||(n=0),0===s&&0===n)return;const u=t+(h>r?s:-1*s),m=i+(c<a?n:-1*n),v=r+s/2,G=a+n/2;this._xScale=u/t||1,this._yScale=m/i||1,1===p||5===p?this._xScale=1:3!==p&&7!==p||(this._yScale=1);const b=(v-r)/l,w=(G-a)/l,x=f(e.box,this._xScale,this._yScale);this._backgroundGraphic.geometry=y(x,b,w,o,!0);const{centerX:S,centerY:k}=this._getGraphicInfo(this._backgroundGraphic),R=(S-r)/l,I=-1*(k-a)/l;for(const e of g){const t=g.indexOf(e),i=f(e,this._xScale,this._yScale,[r,a]);this.graphics[t].geometry=y(i,R,I,o,!0)}this._centerGraphic.geometry=new T(S,k,o.spatialReference)}}_rotateGraphic(t){const{centerX:e,centerY:i,startX:s,startY:o,box:r,rotate:a}=this._startInfo,h=this.view.spatialReference,c=new T(s,o,h),l=new T(e,i,h),n=t.geometry;this._angleOfRotation=b(c,n,l);const p=this._startInfo.graphicInfos?.map((t=>t.geometry))??[];for(const _ of p){const t=p.indexOf(_),e=u(_,this._angleOfRotation,l);this.graphics[t].geometry=e}this._backgroundGraphic.geometry=u(r,this._angleOfRotation,l),this._rotateHandleGraphic.geometry=u(a,this._angleOfRotation,l)}_moveGraphic(t,e,i){if(this.graphics.includes(t)){const s=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=y(s,e,i,this.view);for(const o of this.graphics)o!==t&&(o.geometry=y(o.geometry,e,i,this.view))}else if(t===this._centerGraphic){const t=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=y(t,e,i,this.view)}if(t===this._backgroundGraphic||t===this._centerGraphic)for(const s of this.graphics)s.geometry=y(s.geometry,e,i,this.view)}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper?.add(this.graphics)}_setupGraphics(){const{_graphicAttributes:t,symbols:i}=this;this._centerGraphic=new e(null,i.centerIndicator,t),this.showCenterGraphic&&this.layer.add(this._centerGraphic),this._backgroundGraphic=new e(null,i.fill.default,t),this.layer.add(this._backgroundGraphic),this._rotateLineGraphic=new e(null,i.rotatorLine,t),this._rotateHandleGraphic=new e(null,i.rotator.default,t),this.enableRotation&&!this._hasExtentGraphic()&&this.layer.addMany([this._rotateLineGraphic,this._rotateHandleGraphic]);for(let s=0;s<8;s++)this._vertexGraphics.push(new e(null,i.handles.default,t));this.enableScaling&&this.layer.addMany(this._vertexGraphics)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={...this.symbols,fill:{active:this.symbols.fill.active?.clone().set("outline.color",t),default:this.symbols.fill.default?.clone().set("outline.color",t)},handles:{...this.symbols.handles,default:this.symbols.handles.default.clone().set("outline.color",t)},rotator:{...this.symbols.rotator,default:this.symbols.rotator.default.clone().set("outline.color",t)},rotatorLine:this.symbols.rotatorLine.clone().set("color",t)};for(const e of this._vertexGraphics)e.symbol=e===this._hoveredGraphic?this.symbols.handles.hover:this.symbols.handles.default;this._backgroundGraphic.symbol=this.symbols.fill.default,this._rotateHandleGraphic.symbol=this._rotateHandleGraphic===this._hoveredGraphic?this.symbols.rotator.hover:this.symbols.rotator.default,this._rotateLineGraphic.symbol=this.symbols.rotatorLine}_updateGraphics(){this._updateBackgroundGraphic(),this._updateHandleGraphics(),this._updateCenterGraphic(),this._updateRotateGraphic(),this._updateRotateLineGraphic()}_hideGraphicsBeforeUpdate(){this._centerGraphic.visible=!1,this._rotateHandleGraphic.visible=!1,this._rotateLineGraphic.visible=!1,this._vertexGraphics.forEach((t=>t.visible=!1))}_updateHandleGraphics(){const t=this._getCoordinates(!0);this._vertexGraphics.forEach(((e,i)=>{const[s,o]=t[i];this._updateXY(e,s,o)}))}_updateBackgroundGraphic(){const t=this._getCoordinates();this._backgroundGraphic.geometry=new j({rings:t,spatialReference:this.view.spatialReference})}_updateCenterGraphic(){const[t,e,i,s]=this._getBoxBounds(p()),o=(i+t)/2,r=(s+e)/2;this._centerGraphic.geometry=new T(o,r,this.view.spatialReference)}_updateRotateGraphic(){if(!this._vertexGraphics.length)return;const{x:t,y:e}=this._vertexGraphics[1].geometry,i=e+this.view.state.resolution*this._rotateGraphicOffset;this._rotateHandleGraphic.geometry=new T(t,i,this.view.spatialReference)}_updateRotateLineGraphic(){if(!this._vertexGraphics.length||!this._rotateHandleGraphic?.geometry)return;const t=this._vertexGraphics[1].geometry,e=this._rotateHandleGraphic.geometry;this._rotateLineGraphic.geometry=new E({paths:[[t.x,t.y],[e.x,e.y]],spatialReference:this.view.spatialReference})}_updateXY(t,e,i){t.geometry=new T(e,i,this.view.spatialReference)}_updateX(t,e){const i=t.geometry.y;t.geometry=new T(e,i,this.view.spatialReference)}_updateY(t,e){const i=t.geometry.x;t.geometry=new T(i,e,this.view.spatialReference)}_hasExtentGraphic(){return this.graphics.some((t=>null!=t?.geometry&&"extent"===t.geometry.type))}_getBoxBounds(t){const e=this.graphics.map((t=>t.geometry));return this._getBounds(t,e)}_getCoordinates(t){const[e,i,s,o]=this._getBoxBounds(p());if(t){const t=(e+s)/2,r=(o+i)/2;return[[e,o],[t,o],[s,o],[s,r],[s,i],[t,i],[e,i],[e,r]]}return[[e,o],[s,o],[s,i],[e,i]]}_updateTooltip(t,e){if(null==this._tooltip)return;if(!t)return void this._tooltip.clear();const{_backgroundGraphic:i,graphics:s,_vertexGraphics:o,_rotateHandleGraphic:r}=this;t===r?this._updateRotateTooltip():o.includes(t)?this._updateScaleTooltip():(s.includes(t)||t===i)&&this._updateMoveTooltip(e)}_updateRotateTooltip(){null!=this._tooltip&&(this._tooltip.info=new I({tooltipOptions:this.tooltipOptions,angle:-this._angleOfRotation}))}_updateScaleTooltip(){const{_tooltip:t,_xScale:e,_yScale:i,tooltipOptions:s,view:o}=this;if(null==t)return;const r=o.spatialReference,a=this._getCoordinates(),h=new T(a[0][0],a[0][1],r),c=new T(a[1][0],a[1][1],r),l=new T(a[2][0],a[2][1],r),n=O(h,c),p=O(c,l);if(null==n||null==p)return;const _=Math.abs(e),d=Math.abs(i);t.info=new M({tooltipOptions:s,xScale:_,yScale:d,xSize:n,ySize:p})}_updateMoveTooltip(t){const{_tooltip:e,tooltipOptions:i,view:s}=this;if(null==e)return;const r=new H({tooltipOptions:i});if(t){const{x:e,y:i}=t.origin,a=s.toMap(t),h=s.toMap({x:e,y:i}),c=O(h,a);r.distance=null!=c?c:o}e.info=r}};t([l()],V.prototype,"_tooltip",void 0),t([l({readOnly:!0})],V.prototype,"type",void 0),t([l()],V.prototype,"callbacks",void 0),t([l()],V.prototype,"enableMovement",void 0),t([l()],V.prototype,"enableRotation",void 0),t([l()],V.prototype,"enableScaling",void 0),t([l()],V.prototype,"graphics",void 0),t([l()],V.prototype,"highlightsEnabled",void 0),t([l()],V.prototype,"layer",void 0),t([l()],V.prototype,"preserveAspectRatio",void 0),t([l()],V.prototype,"showCenterGraphic",void 0),t([l({readOnly:!0})],V.prototype,"state",null),t([l()],V.prototype,"symbols",void 0),t([l({type:R})],V.prototype,"tooltipOptions",void 0),t([l({constructOnly:!0})],V.prototype,"view",void 0),V=t([n("esri.views.draw.support.Box")],V);const q=V;export{q as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as p}from"../../../core/maybe.js";import{zeroMeters as h}from"../../../core/quantityUtils.js";import{when as c,pausable as l,watch as d,syncAndInitial as m}from"../../../core/reactiveUtils.js";import{createScreenPoint as v}from"../../../core/screenUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{closeRingsAndFixWinding as g,geometryToCoordinates as u,getMidpoint as f}from"../../../geometry/support/coordsUtils.js";import x from"../../../layers/GraphicsLayer.js";import G from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as b}from"../../ViewingMode.js";import{SnappingVisualizer2D as V}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as M}from"./drawUtils.js";import w from"./GraphicMover.js";import S from"./HighlightHelper.js";import{addUniqueLayer as E}from"./layerUtils.js";import{settings as k}from"./settings.js";import{ViewEventPriorities as I}from"../../input/InputManager.js";import{sketchKeys as O}from"../../interactive/keybindings.js";import{EditGeometryOperations as T}from"../../interactive/editGeometry/EditGeometryOperations.js";import C from"../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as j}from"../../interactive/snapping/SnappingContext.js";import{Tooltip as R}from"../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as H,TranslateVertexTooltipInfo as U}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoArea2D as A}from"../../support/automaticAreaMeasurementUtils.js";import{autoDistanceBetweenPoints2D as L,autoLength2D as F}from"../../support/automaticLengthMeasurementUtils.js";import D from"../../../geometry/Polyline.js";import z from"../../../geometry/Point.js";class P{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class q{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class K{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class N{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class B{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class J{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class Q{constructor(e){this.added=e,this.type="vertex-select"}}class W{constructor(e){this.removed=e,this.type="vertex-deselect"}}class X{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class Y{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const Z=k.reshapeGraphics,$={vertices:{default:new G({style:"circle",size:Z.vertex.size,color:Z.vertex.color,outline:{color:Z.vertex.outlineColor,width:1}}),hover:new G({style:"circle",size:Z.vertex.hoverSize,color:Z.vertex.hoverColor,outline:{color:Z.vertex.hoverOutlineColor,width:1}}),selected:new G({style:"circle",size:Z.selected.size,color:Z.selected.color,outline:{color:Z.selected.outlineColor,width:1}})},midpoints:{default:new G({style:"circle",size:Z.midpoint.size,color:Z.midpoint.color,outline:{color:Z.midpoint.outlineColor,width:1}}),hover:new G({style:"circle",size:Z.midpoint.size,color:Z.midpoint.color,outline:{color:Z.midpoint.outlineColor,width:1}})}};let ee=class extends r.EventedAccessor{constructor(e){super(e),this._activeOperationInfo=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingTask=null,this._stagedVertex=null,this._tooltip=null,this._translateGraphicTooltipInfo=null,this._translateVertexTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new G({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=[],this.snappingManager=null,this.tooltipOptions=new C,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new S({view:e}),this._setup(),this.addHandles([c((()=>e?.ready),(()=>{const{layer:e,view:t}=this;E(t,e),this.addHandles(t.on("key-down",(e=>this._keyDownHandler(e)),I.TOOL))}),{once:!0,initial:!0}),l((()=>this.graphic),(()=>this.refresh())),l((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),l((()=>this.enableMidpoints),(()=>this.refresh())),d((()=>this.tooltipOptions.enabled),(e=>{this._tooltip=e?new R({view:this.view}):a(this._tooltip)}),m)])}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._tooltip=a(this._tooltip)}set highlightsEnabled(e){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",e),this._setUpHighlights()}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}set symbols(e){const{midpoints:t=$.midpoints,vertices:i=$.vertices}=e||{};this._set("symbols",{midpoints:t,vertices:i})}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&g(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new D({paths:e.points,spatialReference:e.spatialReference}):e;this._editGeometryOperations=T.fromGeometry(t,b.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new x({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer),this._snappingContext=new j({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,visualizer:new V(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._set("selectedVertices",[])}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_getCoordinatesForUI(e){const t=u(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=this._getCoordinatesForUI(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((e,a)=>{const[p,h]=e;r.push(new t({geometry:new z({x:p,y:h,spatialReference:o}),symbol:s?.vertices?.default,attributes:{...i,pathIndex:n,pointIndex:a}}))}))})),r}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((a,p)=>{const[h,c]=a,l=e[p+1]?p+1:0;if("polygon"===this.graphic.geometry?.type||0!==l){const[a,d]=e[l],[m,v]=f([h,c],[a,d]);r.push(new t({geometry:new z({x:m,y:v,spatialReference:o}),symbol:s.midpoints.default,attributes:{...i,pathIndex:n,pointIndexStart:p,pointIndexEnd:l}}))}}))})),r}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new w({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e;if(s===this.graphic){const{geometry:o}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),void(null!=o&&"point"===o.type&&this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)})))}if(!this.selectedVertices.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)}))}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)}));else if("point"===n.type)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}));else if("polyline"===n.type||"polygon"===n.type){const t=this._getCoordinatesForUI(n);this._updateVertexGraphicLocations(t),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,(()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o))),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const t=this.view.spatialReference;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes,[r,n]=e[s][o];i.geometry=new z({x:r,y:n,spatialReference:t})}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,[r,n]=e[i][s],[a,p]=e[i][o],[h,c]=f([r,n],[a,p]);t.geometry=new z({x:h,y:c,spatialReference:this.view.spatialReference})}}_getIndicesForVertexGraphic({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}_getVertexFromEditGeometry(e){const[t,i]=this._getIndicesForVertexGraphic(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,h="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new z(this._stagedVertex),t,s,h),r(),this._snappingTask=i((async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new z(this._stagedVertex),t,s,h),r())}))}else{const i=null!=this._stagedVertex?new z(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,h),r()}}async _syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations.data.geometry;if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t),e.notifyGeometryChanged();else{const{x:n,y:a}=t,[p,h]=this._getIndicesForVertexGraphic(e);let c=u(r);const l=c[p].length-1;c[p][h]=[n,a],"polygon"===r.type&&(0===h?c[p][l]=[n,a]:h===l&&(c[p][0]=[n,a])),this._isVertex(e)&&(c=this._moveRelatedCoordinates(c,e,n,a),c=this._moveSelectedHandleCoordinates(c,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(c)),this.graphic.geometry=r.clone();const d=this._getVertexFromEditGeometry(e),m=n-d.pos[0],v=a-d.pos[1];this._editGeometryOperations.moveVertices([d],m,v,0),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i,s){const{relatedGraphicIndices:o}=t.attributes;for(const r of o){const o=this.vertexGraphics.at(r),{pathIndex:n,pointIndex:a}=o.attributes;e[n][a]=[i,s],o.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,p=M(r.geometry,i,s,this.view),h=e[t].length-1;e[t][n]=[p.x,p.y],r.geometry=p,o&&(0===n?e[t][h]=[p.x,p.y]:n===h&&(e[t][0]=[p.x,p.y]));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=[p.x,p.y],t.geometry=p}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic,i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:p}=e.attributes,{x:h,y:c}=e.geometry,l=0===p?a+1:p,d=u(o);return d[n].splice(l,0,[h,c]),e.attributes={...t,pathIndex:n,pointIndex:l,relatedGraphicIndices:[]},r.push({coordinates:d[n][l],componentIndex:n,vertexIndex:l}),this.graphic.geometry=o,r}_addToSelection(e){e instanceof t&&(e=[e]);for(const t of e)t.symbol=this.symbols.vertices.selected;this._set("selectedVertices",this.selectedVertices.concat(e)),this._emitSelectEvent(e)}_removeFromSelection(e,i){const{vertices:s}=this.symbols,o=i?s.hover:s.default;e instanceof t&&(e=[e]);for(const t of e)this.selectedVertices.splice(this.selectedVertices.indexOf(t),1),this._set("selectedVertices",this.selectedVertices),t.set("symbol",o);this._emitDeselectEvent(e)}_clearSelection(){if(this.selectedVertices.length){const e=this.selectedVertices;for(const t of this.selectedVertices)t.set("symbol",this.symbols.vertices.default);this._set("selectedVertices",[]),this._emitDeselectEvent(e)}}_keyDownHandler(e){O.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const i=this.graphic.geometry;if(null==i||"polygon"!==i.type&&"polyline"!==i.type)return;if("polygon"===i.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;e instanceof t&&(e=[e]);const s=this.graphic.clone(),o=i.clone();let r=u(o);const n=[];e instanceof t&&(e=[e]);for(const t of e){const{x:e,y:i}=t.geometry;for(let t=0;t<r.length;t++){const s=r[t];for(let o=0;o<s.length;o++){const[a,p]=s[o];e===a&&i===p&&(n.push({coordinates:r[t][o],componentIndex:t,vertexIndex:o}),r[t].splice(Number(o),1))}}}if("polygon"===o.type)r=r.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)})),o.rings=r;else{for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}this.graphic.geometry=o,this.refresh(),this._emitVertexRemoveEvent(e,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){null!=this._tooltip&&(e?e===this.graphic?this._updateMoveGraphicTooltip(t):this._updateMoveVertexTooltip(t):this._tooltip.clear())}_updateMoveGraphicTooltip(e){const{_tooltip:t,tooltipOptions:i,view:s}=this;if(null==t)return;const o=this._translateGraphicTooltipInfo??=new H({tooltipOptions:i});if(o.clear(),o.tooltipOptions=i,e){const{x:t,y:i}=e.origin,r=s.toMap(e),n=s.toMap(v(t,i)),a=L(n,r);o.distance=null!=a?a:h}t.info=o}_updateMoveVertexTooltip(e){const{_tooltip:t,graphic:{geometry:i},tooltipOptions:s,view:o}=this;if(null==t)return;const r=this._translateVertexTooltipInfo??=new U({tooltipOptions:s});if(r.clear(),r.tooltipOptions=s,"polygon"===i?.type?r.area=A(i):"polyline"===i?.type&&(r.totalLength=F(i)),e){const{x:t,y:i}=e.origin,s=o.toMap(e),n=o.toMap(v(t,i)),a=L(n,s);r.distance=null!=a?a:h}t.info=r}_emitMoveStartEvent(e,t){const i=new N(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart&&this.callbacks.onMoveStart(i)}_emitMoveEvent(e,t){const i=new B(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove&&this.callbacks.onMove(i)}_emitMoveStopEvent(){const e=this._activeOperationInfo;if(!e)return;const{totalDx:t,totalDy:i}=e,s=new J(this.graphic,t,i);this.emit("move-stop",s),this.callbacks.onMoveStop&&this.callbacks.onMoveStop(s)}_emitReshapeStartEvent(e){const t=new P(this.graphic,e,this.selectedVertices);this.emit("reshape-start",t),this.callbacks.onReshapeStart&&this.callbacks.onReshapeStart(t)}_emitReshapeEvent(e){const t=new q(this.graphic,e,this.selectedVertices);this.emit("reshape",t),this.callbacks.onReshape&&this.callbacks.onReshape(t)}_emitReshapeStopEvent(e){const t=new K(this.graphic,e,this.selectedVertices);this.emit("reshape-stop",t),this.callbacks.onReshapeStop&&this.callbacks.onReshapeStop(t)}_emitSelectEvent(e){const t=new Q(e);this.emit("select",t),this.callbacks.onVertexSelect&&this.callbacks.onVertexSelect(t)}_emitDeselectEvent(e){const t=new W(e);this.emit("deselect",t),this.callbacks.onVertexDeselect&&this.callbacks.onVertexDeselect(t)}_emitVertexAddEvent(e,t,i){const s=new X(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd&&this.callbacks.onVertexAdd(s)}_emitVertexRemoveEvent(e,t,i){const s=new Y(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove&&this.callbacks.onVertexRemove(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};e([y()],ee.prototype,"_tooltip",void 0),e([y()],ee.prototype,"_translateGraphicTooltipInfo",void 0),e([y()],ee.prototype,"_translateVertexTooltipInfo",void 0),e([y()],ee.prototype,"callbacks",void 0),e([y()],ee.prototype,"enableMidpoints",void 0),e([y()],ee.prototype,"enableMovement",void 0),e([y()],ee.prototype,"enableVertices",void 0),e([y()],ee.prototype,"graphic",void 0),e([y({value:!0})],ee.prototype,"highlightsEnabled",null),e([y()],ee.prototype,"layer",void 0),e([y({readOnly:!0})],ee.prototype,"midpointGraphics",void 0),e([y()],ee.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],ee.prototype,"selectedVertices",void 0),e([y()],ee.prototype,"snappingManager",void 0),e([y({readOnly:!0})],ee.prototype,"state",null),e([y({value:$})],ee.prototype,"symbols",null),e([y({type:C})],ee.prototype,"tooltipOptions",void 0),e([y({readOnly:!0})],ee.prototype,"type",void 0),e([y({readOnly:!0})],ee.prototype,"vertexGraphics",void 0),e([y()],ee.prototype,"view",void 0),ee=e([_("esri.views.draw.support.Reshape")],ee);const te=ee;export{te as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as h}from"../../../core/maybe.js";import{zeroMeters as p}from"../../../core/quantityUtils.js";import{when as c,pausable as l,watch as d,syncAndInitial as m,initial as v}from"../../../core/reactiveUtils.js";import{createScreenPoint as y}from"../../../core/screenUtils.js";import{property as _}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as g}from"../../../core/accessorSupport/decorators/subclass.js";import{closeRingsAndFixWinding as u,geometryToCoordinates as f,getMidpoint as x}from"../../../geometry/support/coordsUtils.js";import G from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as V}from"../../ViewingMode.js";import{SnappingVisualizer2D as M}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as w}from"./drawUtils.js";import S from"./GraphicMover.js";import E from"./HighlightHelper.js";import{addUniqueLayer as k}from"./layerUtils.js";import{settings as I}from"./settings.js";import{ViewEventPriorities as T}from"../../input/InputManager.js";import{sketchKeys as O}from"../../interactive/keybindings.js";import{EditGeometryOperations as C}from"../../interactive/editGeometry/EditGeometryOperations.js";import j from"../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as R}from"../../interactive/snapping/SnappingContext.js";import{Tooltip as H}from"../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as U,TranslateVertexTooltipInfo as A}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoArea2D as F}from"../../support/automaticAreaMeasurementUtils.js";import{autoDistanceBetweenPoints2D as L,autoLength2D as D}from"../../support/automaticLengthMeasurementUtils.js";import z from"../../../geometry/Polyline.js";import P from"../../../geometry/Point.js";class q{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class K{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class N{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class B{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class J{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class Q{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class W{constructor(e){this.added=e,this.type="vertex-select"}}class X{constructor(e){this.removed=e,this.type="vertex-deselect"}}class Y{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class Z{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const $=I.reshapeGraphics,ee={vertices:{default:new b({style:"circle",size:$.vertex.size,color:$.vertex.color,outline:{color:$.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:$.vertex.hoverSize,color:$.vertex.hoverColor,outline:{color:$.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:$.selected.size,color:$.selected.color,outline:{color:$.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}})}};let te=class extends r.EventedAccessor{constructor(e){super(e),this._activeOperationInfo=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this._tooltip=null,this._translateGraphicTooltipInfo=null,this._translateVertexTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=[],this.snappingManager=null,this.symbols=ee,this.tooltipOptions=new j,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new E({view:e}),this._setup(),this.addHandles([c((()=>e?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this.addHandles(t.on("key-down",(e=>this._keyDownHandler(e)),T.TOOL))}),{once:!0,initial:!0}),l((()=>this.graphic),(()=>this.refresh())),l((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),l((()=>this.enableMidpoints),(()=>this.refresh())),d((()=>this.tooltipOptions.enabled),(e=>{this._tooltip=e?new H({view:this.view}):a(this._tooltip)}),m),d((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),v)])}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._tooltip=a(this._tooltip)}set highlightsEnabled(e){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",e),this._setUpHighlights()}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&u(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new z({paths:e.points,spatialReference:e.spatialReference}):e;this._editGeometryOperations=C.fromGeometry(t,V.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new G({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer),this._snappingContext=new R({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new M(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=h(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._set("selectedVertices",[])}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_getCoordinatesForUI(e){const t=f(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=this._getCoordinatesForUI(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((e,a)=>{const[h,p]=e;r.push(new t({geometry:new P({x:h,y:p,spatialReference:o}),symbol:s?.vertices?.default,attributes:{...i,pathIndex:n,pointIndex:a}}))}))})),r}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((a,h)=>{const[p,c]=a,l=e[h+1]?h+1:0;if("polygon"===this.graphic.geometry?.type||0!==l){const[a,d]=e[l],[m,v]=x([p,c],[a,d]);r.push(new t({geometry:new P({x:m,y:v,spatialReference:o}),symbol:s.midpoints.default,attributes:{...i,pathIndex:n,pointIndexStart:h,pointIndexEnd:l}}))}}))})),r}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new S({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e;if(s===this.graphic){const{geometry:o}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),void(null!=o&&"point"===o.type&&this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)})))}if(!this.selectedVertices.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)}))}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)}));else if("point"===n.type)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}));else if("polyline"===n.type||"polygon"===n.type){const t=this._getCoordinatesForUI(n);this._updateVertexGraphicLocations(t),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,(()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o))),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const t=this.view.spatialReference;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes,[r,n]=e[s][o];i.geometry=new P({x:r,y:n,spatialReference:t})}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,[r,n]=e[i][s],[a,h]=e[i][o],[p,c]=x([r,n],[a,h]);t.geometry=new P({x:p,y:c,spatialReference:this.view.spatialReference})}}_getIndicesForVertexGraphic({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}_getVertexFromEditGeometry(e){const[t,i]=this._getIndicesForVertexGraphic(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){h(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,p="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!p){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new P(this._stagedVertex),t,s,p),r(),this._snappingTask=i((async i=>{const h=await o.snap({point:a,context:n,signal:i});h.valid&&(this._stagedVertex=h.apply(),this._syncGeometryAfterVertexMove(e,new P(this._stagedVertex),t,s,p),r())}))}else{const i=null!=this._stagedVertex?new P(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,p),r()}}async _syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations.data.geometry;if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t),e.notifyGeometryChanged();else{const{x:n,y:a}=t,[h,p]=this._getIndicesForVertexGraphic(e);let c=f(r);const l=c[h].length-1;c[h][p]=[n,a],"polygon"===r.type&&(0===p?c[h][l]=[n,a]:p===l&&(c[h][0]=[n,a])),this._isVertex(e)&&(c=this._moveRelatedCoordinates(c,e,n,a),c=this._moveSelectedHandleCoordinates(c,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(c)),this.graphic.geometry=r.clone();const d=this._getVertexFromEditGeometry(e),m=n-d.pos[0],v=a-d.pos[1];this._editGeometryOperations.moveVertices([d],m,v,0),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i,s){const{relatedGraphicIndices:o}=t.attributes;for(const r of o){const o=this.vertexGraphics.at(r),{pathIndex:n,pointIndex:a}=o.attributes;e[n][a]=[i,s],o.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=w(r.geometry,i,s,this.view),p=e[t].length-1;e[t][n]=[h.x,h.y],r.geometry=h,o&&(0===n?e[t][p]=[h.x,h.y]:n===p&&(e[t][0]=[h.x,h.y]));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=[h.x,h.y],t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,{x:p,y:c}=e.geometry,l=0===h?a+1:h,d=f(o);return d[n].splice(l,0,[p,c]),e.attributes={...t,pathIndex:n,pointIndex:l,relatedGraphicIndices:[]},r.push({coordinates:d[n][l],componentIndex:n,vertexIndex:l}),this.graphic.geometry=o,r}_addToSelection(e){e instanceof t&&(e=[e]);for(const t of e)t.symbol=this.symbols.vertices.selected;this._set("selectedVertices",this.selectedVertices.concat(e)),this._emitSelectEvent(e)}_removeFromSelection(e,i){const{vertices:s}=this.symbols,o=i?s.hover:s.default;e instanceof t&&(e=[e]);for(const t of e)this.selectedVertices.splice(this.selectedVertices.indexOf(t),1),this._set("selectedVertices",this.selectedVertices),t.set("symbol",o);this._emitDeselectEvent(e)}_clearSelection(){if(this.selectedVertices.length){const e=this.selectedVertices;for(const t of this.selectedVertices)t.set("symbol",this.symbols.vertices.default);this._set("selectedVertices",[]),this._emitDeselectEvent(e)}}_keyDownHandler(e){O.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const i=this.graphic.geometry;if(null==i||"polygon"!==i.type&&"polyline"!==i.type)return;if("polygon"===i.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;e instanceof t&&(e=[e]);const s=this.graphic.clone(),o=i.clone();let r=f(o);const n=[];e instanceof t&&(e=[e]);for(const t of e){const{x:e,y:i}=t.geometry;for(let t=0;t<r.length;t++){const s=r[t];for(let o=0;o<s.length;o++){const[a,h]=s[o];e===a&&i===h&&(n.push({coordinates:r[t][o],componentIndex:t,vertexIndex:o}),r[t].splice(Number(o),1))}}}if("polygon"===o.type)r=r.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)})),o.rings=r;else{for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}this.graphic.geometry=o,this.refresh(),this._emitVertexRemoveEvent(e,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){null!=this._tooltip&&(e?e===this.graphic?this._updateMoveGraphicTooltip(t):this._updateMoveVertexTooltip(t):this._tooltip.clear())}_updateMoveGraphicTooltip(e){const{_tooltip:t,tooltipOptions:i,view:s}=this;if(null==t)return;const o=this._translateGraphicTooltipInfo??=new U({tooltipOptions:i});if(o.clear(),o.tooltipOptions=i,e){const{x:t,y:i}=e.origin,r=s.toMap(e),n=s.toMap(y(t,i)),a=L(n,r);o.distance=null!=a?a:p}t.info=o}_updateMoveVertexTooltip(e){const{_tooltip:t,graphic:{geometry:i},tooltipOptions:s,view:o}=this;if(null==t)return;const r=this._translateVertexTooltipInfo??=new A({tooltipOptions:s});if(r.clear(),r.tooltipOptions=s,"polygon"===i?.type?r.area=F(i):"polyline"===i?.type&&(r.totalLength=D(i)),e){const{x:t,y:i}=e.origin,s=o.toMap(e),n=o.toMap(y(t,i)),a=L(n,s);r.distance=null!=a?a:p}t.info=r}_emitMoveStartEvent(e,t){const i=new B(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart&&this.callbacks.onMoveStart(i)}_emitMoveEvent(e,t){const i=new J(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove&&this.callbacks.onMove(i)}_emitMoveStopEvent(){const e=this._activeOperationInfo;if(!e)return;const{totalDx:t,totalDy:i}=e,s=new Q(this.graphic,t,i);this.emit("move-stop",s),this.callbacks.onMoveStop&&this.callbacks.onMoveStop(s)}_emitReshapeStartEvent(e){const t=new q(this.graphic,e,this.selectedVertices);this.emit("reshape-start",t),this.callbacks.onReshapeStart&&this.callbacks.onReshapeStart(t)}_emitReshapeEvent(e){const t=new K(this.graphic,e,this.selectedVertices);this.emit("reshape",t),this.callbacks.onReshape&&this.callbacks.onReshape(t)}_emitReshapeStopEvent(e){const t=new N(this.graphic,e,this.selectedVertices);this.emit("reshape-stop",t),this.callbacks.onReshapeStop&&this.callbacks.onReshapeStop(t)}_emitSelectEvent(e){const t=new W(e);this.emit("select",t),this.callbacks.onVertexSelect&&this.callbacks.onVertexSelect(t)}_emitDeselectEvent(e){const t=new X(e);this.emit("deselect",t),this.callbacks.onVertexDeselect&&this.callbacks.onVertexDeselect(t)}_emitVertexAddEvent(e,t,i){const s=new Y(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd&&this.callbacks.onVertexAdd(s)}_emitVertexRemoveEvent(e,t,i){const s=new Z(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove&&this.callbacks.onVertexRemove(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};e([_()],te.prototype,"_tooltip",void 0),e([_()],te.prototype,"_translateGraphicTooltipInfo",void 0),e([_()],te.prototype,"_translateVertexTooltipInfo",void 0),e([_()],te.prototype,"callbacks",void 0),e([_()],te.prototype,"enableMidpoints",void 0),e([_()],te.prototype,"enableMovement",void 0),e([_()],te.prototype,"enableVertices",void 0),e([_()],te.prototype,"graphic",void 0),e([_({value:!0})],te.prototype,"highlightsEnabled",null),e([_()],te.prototype,"layer",void 0),e([_({readOnly:!0})],te.prototype,"midpointGraphics",void 0),e([_()],te.prototype,"midpointSymbol",void 0),e([_({readOnly:!0})],te.prototype,"selectedVertices",void 0),e([_()],te.prototype,"snappingManager",void 0),e([_({readOnly:!0})],te.prototype,"state",null),e([_()],te.prototype,"symbols",void 0),e([_({type:j})],te.prototype,"tooltipOptions",void 0),e([_({readOnly:!0})],te.prototype,"type",void 0),e([_({readOnly:!0})],te.prototype,"vertexGraphics",void 0),e([_()],te.prototype,"view",void 0),te=e([g("esri.views.draw.support.Reshape")],te);const ie=te;export{ie as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
function e(e){const i=()=>e("visible"===document.visibilityState);return document.addEventListener("visibilitychange",i),{remove:()=>document.addEventListener("visibilitychange",i)}}export{e as onVisibilityChange};
|