@arcgis/core 4.34.0-next.53 → 4.34.0-next.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/applications/Components/formatUtils.d.ts +3 -0
- package/applications/Components/formatUtils.js +5 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{e58336aafe8c95bb6831.js → 0eb728cee6e40cb30c01.js} +1 -1
- package/assets/esri/core/workers/chunks/23f54b49742098def8ae.js +1 -0
- package/assets/esri/core/workers/chunks/435169b455fd2846799b.js +1 -0
- package/assets/esri/core/workers/chunks/69e6000044bfb03776ac.js +1 -0
- package/assets/esri/core/workers/chunks/813efde41e90e652b7db.js +1 -0
- package/assets/esri/core/workers/chunks/82404ff7c298493ff6f4.js +1 -0
- package/assets/esri/core/workers/chunks/9639a6f6fab52a501bf7.js +1 -0
- package/assets/esri/core/workers/chunks/dd120d562b63618e71c0.js +1 -0
- package/assets/esri/core/workers/chunks/{fb4950995f6780f6c22a.js → ee0286b5f5475f2d853f.js} +1 -1
- package/config.js +1 -1
- package/geometry/operators/json/graphicBufferOperator.js +5 -0
- package/geometry/support/coordinateSystem.js +1 -1
- package/interfaces.d.ts +91 -183
- package/kernel.js +1 -1
- package/networks/support/typeUtils.js +1 -1
- package/package.json +1 -1
- package/rest/networks/support/Circuit.js +5 -0
- package/rest/networks/support/CircuitSection.js +1 -1
- package/rest/networks/support/Subcircuit.js +1 -1
- package/rest/print.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMEffects.js +1 -1
- package/symbols/cim/effects/EffectOffset.js +1 -1
- package/views/2d/analysisViewModuleImportUtils.js +5 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/input/MapViewInputManager.js +1 -1
- package/views/2d/layers/LayerView2D.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
- package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
- package/views/3d/analysisViewModuleImportUtils.js +5 -0
- package/views/3d/input/SceneInputManager.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveManipulation.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/ToolViewManager.js +1 -1
- package/views/View.js +1 -1
- package/views/View2D.js +1 -1
- package/views/draw/DrawGraphicTool.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/LegacyDrawManipulator.js +1 -1
- package/views/input/InputManager.js +1 -1
- package/views/input/handlers/LatestPointer.js +1 -1
- package/views/interactive/InteractiveToolBase.js +1 -1
- package/views/interactive/ToolViewManagerManipulatorState.js +1 -1
- package/views/interactive/Tooltip.js +1 -1
- package/views/support/AnalysisViewManager.js +5 -0
- package/widgets/Feature/FeatureViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/2b75212c31145cc07d16.js +0 -1
- package/assets/esri/core/workers/chunks/4c6862ad3af947c704f7.js +0 -1
- package/assets/esri/core/workers/chunks/781b59ba0cabe78bc122.js +0 -1
- package/assets/esri/core/workers/chunks/b877142a275188a16e17.js +0 -1
- package/assets/esri/core/workers/chunks/cc0cb4906e4419f7c4a9.js +0 -1
- package/assets/esri/core/workers/chunks/f75ddd79be506423be09.js +0 -1
- package/views/3d/analysis/AnalysisViewManager3D.js +0 -5
package/views/ToolViewManager.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import o from"../core/Accessor.js";import{clock as e}from"../core/clock.js";import i from"../core/Collection.js";import"../core/has.js";import a from"../core/Logger.js";import{removeMaybe as
|
|
5
|
+
import{__decorate as t}from"tslib";import o from"../core/Accessor.js";import{clock as e}from"../core/clock.js";import i from"../core/Collection.js";import"../core/has.js";import a from"../core/Logger.js";import{removeMaybe as s}from"../core/maybe.js";import{watch as n}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/RandomLCG.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../core/support/UpdatingHandles.js";import{ViewEventPriorities as h}from"./input/InputManager.js";import{eventTypes as u}from"./input/ViewEvents.js";import{getToolCollectionHandles as p,areToolManipulatorsEditable as m,isCancelEvent as v}from"./interactive/interactiveToolUtils.js";import{ToolViewManagerManipulatorState as d}from"./interactive/ToolViewManagerManipulatorState.js";const g="attached",_="tools",T=1e3;let f=class extends o{constructor(t){super(t),this._updatingHandles=new c,this._clock=e,this._manipulatorState=new d,this.tools=new i,this._interacting=!1,this._interactingTimeout=T,this._interactingTimeoutHandle=null}initialize(){this.addHandles([this.view.on(u,t=>{this._handleInputEvent(t)},h.TOOL),...p(this.tools),this.tools.on("before-add",({item:t})=>{this._updateToolEditableFlag(t)}),this.tools.on("before-remove",({item:t})=>{this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs)}),this.tools.on("change",()=>{this._refreshToolWatchers()})])}destroy(){this.activeTool=null,this.tools.drain(t=>t.destroy()),this._clearInteractingTimeout(),this._interacting=!1,this._updatingHandles.destroy(),this._manipulatorState.destroy()}get _manipulatorStateEventArgs(){return{tools:this.tools,activeTool:this.activeTool,setActiveTool:t=>{this.activeTool=t},view:this.view}}set activeTool(t){if(null!=t&&!this.view.ready)return void a.getLogger(this).error("Cannot set active tool while view is not ready.");if(t===this.activeTool)return;const o=this.activeTool;this._set("activeTool",t),null!=o&&o.deactivate(),null!=t&&t.activate(),this._removeIncompleteTools(t);for(const e of this.tools){this._updateToolEditableFlag(e);const t=m(e);null!=this.activeTool&&t||this._manipulatorState.clearPointers(e,this._manipulatorStateEventArgs,!t)}}get cursor(){const t=this._manipulatorState.cursor;if(null!=t)return t;for(const o of this.tools)if(o.visible&&null!=o.cursor)return o.cursor;return null}get updating(){return this._updatingHandles.updating||this.tools.some(t=>t.updating)}get interacting(){return this._interacting}_clearInteractingTimeout(){this._interactingTimeoutHandle=s(this._interactingTimeoutHandle)}_startInteractingTimeout(){this._clearInteractingTimeout(),this._interactingTimeoutHandle=this._clock.setTimeout(()=>this._interacting=!1,this._interactingTimeout)}attach(){"3d"===this.view.type?this.addHandles([n(()=>{const{state:t}=this.view;return"camera"in t&&t.camera},()=>this._forEachManipulator(t=>t.onViewChange())),this.view.elevationProvider?.on("elevation-change",t=>this._forEachManipulator(o=>o.onElevationChange(t)))],g):this.addHandles(n(()=>this.view.extent,()=>this._forEachManipulator(t=>t.onViewChange())))}detach(){this.activeTool=null,this.tools.removeAll(),this.removeHandles(g),this._clearInteractingTimeout(),this._interacting=!1}_forEachManipulator(t){for(const o of this.tools)o.manipulators&&o.manipulators.forEach(({manipulator:e})=>t(e,o))}_handleInputEvent(t){let o=!1;const e={...t,stopPropagation:()=>{o=!0,t.stopPropagation()}};if(null!=this.activeTool)this.activeTool.handleInputEvent&&this.activeTool.handleInputEvent(e);else for(const i of this.tools)!o&&i.visible&&i.handleInputEvent(e);!o&&v(t)&&this.activeTool&&(t.stopPropagation(),t.preventDefault(),this.activeTool.cancel(),this.activeTool=null),this._manipulatorState.handleInputEvent(e,this._manipulatorStateEventArgs),o||null==this.activeTool||this.activeTool.handleInputEventAfter(e),this._manipulatorState.handleHoverEvent(e,this.tools),"pointer-move"===t.type&&(this._manipulatorState.hasFocusedManipulators||this.activeTool)&&(this._interacting=!0,this._startInteractingTimeout())}_refreshToolWatchers(){this.removeHandles(_);for(const t of this.tools){if(t instanceof o){const o=n(()=>[t.cursor,t.visible,t.editable],()=>{m(t)||this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs)});this.addHandles(o,_)}t.manipulators&&this.addHandles([t.manipulators.on("after-remove",o=>{this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs,!0,o.item.manipulator)}),t.manipulators.on("change",()=>{this._manipulatorState.updateHoveredStateFromKnownPointers(this.tools)})],_)}this._manipulatorState.updateHoveredStateFromKnownPointers(this.tools)}_updateToolEditableFlag(t){t.setEditableFlag?.(1,null==this.activeTool||t===this.activeTool)}_removeIncompleteTools(t){this.tools.filter(o=>(null==t||o!==t)&&!o.created&&o.removeIncompleteOnCancel).forEach(t=>{this.tools.remove(t)})}get test(){}};t([r({constructOnly:!0,nonNullable:!0})],f.prototype,"view",void 0),t([r({value:null})],f.prototype,"activeTool",null),t([r({readOnly:!0,type:i})],f.prototype,"tools",void 0),t([r()],f.prototype,"cursor",null),t([r({readOnly:!0})],f.prototype,"updating",null),t([r()],f.prototype,"_interacting",void 0),t([r({readOnly:!0})],f.prototype,"interacting",null),f=t([l("esri.views.ToolViewManager")],f);export{f as ToolViewManager,T as interactingTimeout};
|
package/views/View.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../Map.js";import{createTask as i}from"../core/asyncUtils.js";import r from"../core/Collection.js";import s from"../core/CollectionFlattener.js";import{referenceSetter as a}from"../core/collectionUtils.js";import o from"../core/Error.js";import{EventedMixin as n}from"../core/Evented.js";import l from"../core/Handles.js";import{makeHandle as p}from"../core/handleUtils.js";import has from"../core/has.js";import{isLoadable as h}from"../core/Loadable.js";import d from"../core/Logger.js";import{destroyMaybe as y,abortMaybe as u}from"../core/maybe.js";import{EsriPromise as m}from"../core/Promise.js";import{after as c}from"../core/promiseUtils.js";import{watch as g,sync as f,whenOnce as w,when as v,syncAndInitial as _}from"../core/reactiveUtils.js";import{property as V}from"../core/accessorSupport/decorators/property.js";import"../core/RandomLCG.js";import{subclass as M}from"../core/accessorSupport/decorators/subclass.js";import{owningCollectionProperty as R}from"../core/support/OwningCollection.js";import{UpdatingHandles as S}from"../core/support/UpdatingHandles.js";import T from"../geometry/Extent.js";import j from"../geometry/HeightModelInfo.js";import F from"../geometry/SpatialReference.js";import{equals as E}from"../geometry/support/spatialReferenceUtils.js";import{AnalysesCollection as k}from"../support/AnalysesCollection.js";import{GraphicsCollection as x}from"../support/GraphicsCollection.js";import{system as b}from"../time/constants.js";import{T as O}from"../chunks/TimeExtent.js";import{isTimeZoneValid as C}from"../time/timeZoneUtils.js";import L from"./BasemapView.js";import H from"./Magnifier.js";import P from"./SelectionManager.js";import Z from"./Theme.js";import{ToolViewManager as I}from"./ToolViewManager.js";import{makeDefaultHighlightOptions as W}from"./3d/support/DefaultHighlights.js";import q from"./input/Input.js";import{ViewEvents as D}from"./input/ViewEvents.js";import U from"./navigation/Navigation.js";import{DefaultsFromMap as z}from"./support/DefaultsFromMap.js";import A from"./support/HighlightOptions.js";import G from"./support/LayerViewManager.js";import N from"./support/RequiredFieldsOptions.js";var $;let B=class extends(n(m)){static{$=this}constructor(e){super(e),this._userSpatialReference=null,this.handles=new l,this.updatingHandles=new S,this.allLayerViews=new s({getCollections:()=>[this.basemapView?.baseLayerViews,this.basemapView?.groundLayerViews,this.groundView?.layerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:Q}),this.analyses=new k,this.basemapView=null,this.displayFilterEnabled=!0,this.fatalError=null,this.graphics=new x,this.groundView=null,this.typeSpecificPreconditionsReady=!0,this.layerViews=new r,this.magnifier=new H,this.padding={left:0,top:0,right:0,bottom:0},this.ready=!1,this._readyStateWaitingTask=null,this.supportsGround=!0,this.type=null,this.scale=null,this.updating=!1,this.initialExtentRequired=!0,this._lowPriorityCursorHandles=new r,this._highPriorityCursorHandles=new r,this.input=new q,this.navigation=new U,this.layerViewManager=null,this.analysisViewManager=null,this.isHeightModelInfoRequired=!1,this.width=null,this.height=null,this.resizing=!1,this.suspended=!1,this.viewEvents=new D(this),this.persistableViewModels=new r,this.requiredFieldsOptions=new N,this._isValid=!1,this._readyCycleForced=!1,this._lockedSpatialReference=null,this._userTimeZone=null,this._lockedTimeZone=null,this._userTimeExtent=null,this._lockedTimeExtent=null,this.theme=null,this.handles.add(g(()=>this.preconditionsReady,e=>{const t=this.ready;if(e?(this._lockedSpatialReference=this.spatialReference,this._lockedTimeZone=this.timeZone,this._lockedTimeExtent=this.timeExtent,$.views.add(this)):(this._lockedSpatialReference=null,$.views.remove(this)),this.notifyChange("spatialReference"),!e&&t)this.toolViewManager?.detach(),null!=this.analysisViewManager&&this.analysisViewManager.detach(),this.layerViewManager?.clear(),this._teardown();else if(e&&!t){try{this._startup()}catch(i){return void queueMicrotask(()=>{this.fatalError=new o("view:startup-error","View._startup failed",i)})}null!=this.analysisViewManager&&this.analysisViewManager.attach(),this.toolViewManager.attach()}},f))}initialize(){this.addResolvingPromise(Promise.all([this.loadAsyncDependencies(),this.validate()]).then(()=>(this._isValid=!0,w(()=>this.ready)))),this.basemapView=new L({view:this}),this.layerViewManager=new G({view:this,layerViewFilter:e=>this.layerViewFilter?.(e)??!0,layerViewImporter:{importLayerView:e=>this.importLayerView(e),hasLayerViewModule:e=>this.hasLayerViewModule(e)},supportsGround:this.supportsGround}),this.toolViewManager=new I({view:this}),this.selectionManager=new P({view:this}),this.addHandles([v(()=>"map-content-error"===this.readyState&&!this.spatialReference,()=>{d.getLogger(this).warn("#spatialReference","no spatial reference could be derived from the currently added map layers")}),g(()=>this.initialExtentRequired,e=>this.defaultsFromMap.required={...this.defaultsFromMap.required,extent:e},_),g(()=>this.ready,e=>{this.defaultsFromMap&&(this.defaultsFromMap.suspended=e,this.defaultsFromMap.userSpatialReference=e?this.spatialReference:this._userSpatialReference)},f),g(()=>this._userSpatialReference,e=>{this.defaultsFromMap&&(this.defaultsFromMap.userSpatialReference=e)},_)])}destroy(){this.destroyed||($.views.remove(this),this.viewEvents.destroy(),this.allLayerViews.destroy(),this.navigation&&(this.navigation.destroy(),this._set("navigation",null)),this.graphics=y(this.graphics),this.analyses=y(this.analyses),this.defaultsFromMap.destroy(),this._set("defaultsFromMap",null),y(this.analysisViewManager),this.toolViewManager=y(this.toolViewManager),this.layerViewManager=y(this.layerViewManager),this.selectionManager=y(this.selectionManager),this.basemapView=y(this.basemapView),this.groundView?.destroy(),this.layerViews?.forEach(e=>e.destroy()),this.layerViews.length=0,this.invalidate(),this.handles.destroy(),this.map=y(this.map),this.updatingHandles.destroy())}_startup(){this._set("ready",!0)}_teardown(){this._set("ready",!1)}whenReady(){return Promise.resolve(this)}toMap(){return d.getLogger(this).error("#toMap()","Not implemented on this instance of View"),null}get activeTool(){return this.toolViewManager?.activeTool}set activeTool(e){this.toolViewManager&&(this.toolViewManager.activeTool=e)}get animation(){return this._get("animation")}set animation(e){this._set("animation",e)}get center(){return null}get defaultsFromMapSettings(){return{}}get defaultsFromMap(){return new z({required:{tileInfo:!1,heightModelInfo:!1,extent:!1},map:()=>this.map,getSpatialReferenceSupport:(e,t)=>this.getSpatialReferenceSupport(e,t),...this.defaultsFromMapSettings})}get extent(){return this._get("extent")}set extent(e){this._set("extent",e)}get heightModelInfo(){return this.getDefaultHeightModelInfo()}get highlights(){return this._get("highlights")??W()}set highlights(e){this._set("highlights",a(e,this._get("highlights"),r.ofType(A)))}get interacting(){return this.navigating}get navigating(){return!1}get preconditionsReady(){return!this.destroying&&!this.destroyed&&!(this.fatalError||!this._isValid||this._readyCycleForced||!this.map||h(this.map)&&!this.map.loaded||0===this.width||0===this.height||!this.spatialReference||!this._validateSpatialReference(this.spatialReference)||!this._lockedSpatialReference&&!this.defaultsFromMap?.ready||!this.typeSpecificPreconditionsReady)}get resolution(){return 0}set map(e){e!==this._get("map")&&(e?.destroyed&&(d.getLogger(this).warn("#map","The provided map is already destroyed",{map:e}),e=null),h(e)&&e.load().catch(()=>{}),this.constructed&&!this.destroyed&&(this.forceReadyCycle(),this._lockedSpatialReference=null),this._set("map",e))}get readyState(){if(this.destroyed)return this._get("readyState");if(!this.map)return"missing-map";if("container"in this&&!this.container)return"missing-container";if(this.fatalError)return"rendering-error";if((this.defaultsFromMap?.ready??!1)&&!this.spatialReference){const e=!("loaded"in this.map)||this.map.loaded,t=this.map.ground.loaded,r=this.map.basemap?.loaded??!0;return e&&r&&t&&!this.map?.allLayers.length?"empty-map":(this._readyStateWaitingTask||(this._readyStateWaitingTask=i(e=>c(has("view-readyState-waiting-delay"),null,e)),this.addHandles(this._readyStateWaitingTask),this.addHandles(this._readyStateWaitingTask,"ready-state-task")),this._readyStateWaitingTask?.finished?"map-content-error":"loading")}return this._readyStateWaitingTask=u(this._readyStateWaitingTask),this.removeHandles("ready-state-task"),this.ready?"ready":"loading"}get spatialReference(){const e=this._userSpatialReference||this._lockedSpatialReference||this.getDefaultSpatialReference()||null;if(e&&this.defaultsFromMap?.required?.heightModelInfo){const t=e.clone();return t.vcsWkid=this.defaultsFromMap.vcsWkid,t.latestVcsWkid=this.defaultsFromMap.latestVcsWkid,t}return e}set spatialReference(e){const t=!E(e,this._get("spatialReference"));this._set("_userSpatialReference",e),t&&(this._set("spatialReference",e),this._spatialReferenceChanged(e))}_spatialReferenceChanged(e){}get stationary(){return!this.animation&&!this.navigating&&!this.resizing}get timeExtent(){return this._userTimeExtent??this._lockedTimeExtent??this.getDefaultTimeExtent()??null}set timeExtent(e){this._userTimeExtent=e}get timeZone(){return this._userTimeZone??this._lockedTimeZone??this.getDefaultTimeZone()??b}set timeZone(e){this._userTimeZone=e,C(e)||d.getLogger(this).warn("#timeZone",`the parsed value '${e}' may not be a valid IANA time zone`)}get tools(){return this.toolViewManager?.tools}get initialExtent(){return this.defaultsFromMap?.extent}get cursor(){return this.toolViewManager?.cursor??this._highPriorityCursorHandles.at(-1)?.cursor??this._lowPriorityCursorHandles.at(-1)?.cursor??"default"}acquireCursor(e,t="low"){const i="high"===t?this._highPriorityCursorHandles:this._lowPriorityCursorHandles,r={cursor:e},s=p(()=>i.remove(r));return i.add(r),this.addHandles(s),s}get size(){return[this.width,this.height]}get effectiveTheme(){return this.theme??new Z}whenLayerView(e){return this.layerViewManager?.whenLayerView(e)??Promise.reject()}getDefaultSpatialReference(){return this.defaultsFromMap?.spatialReference}getDefaultHeightModelInfo(){return(this.map&&"heightModelInfo"in this.map?this.map.heightModelInfo:void 0)??this.defaultsFromMap?.heightModelInfo??null}getDefaultTimeZone(){return null}getDefaultTimeExtent(){return null}importLayerView(e){throw new o("view:importLayerView-missing","importLayerView() not implemented")}hasLayerViewModule(e){return!1}async validate(){}async loadAsyncDependencies(){}invalidate(){this._isValid=!1}getSpatialReferenceSupport(){return{constraints:null}}_validateSpatialReference(e){return null!=this.getSpatialReferenceSupport(e)}when(e,t){return this.isResolved()&&!this.ready&&d.getLogger(this).warn("#when()","Calling view.when() while the view is no longer ready but was already resolved once will resolve immediately. Use reactiveUtils.whenOnce(() => view.ready).then(...) instead."),super.when(e,t)}forceReadyCycle(){this.ready&&(v(()=>this.destroyed||!1===this.preconditionsReady,()=>this._readyCycleForced=!1,{once:!0}),this._readyCycleForced=!0)}on(e,t){return super.on(e,t)}addAndActivateTool(e){this.toolViewManager.tools.add(e),this.activeTool=e}tryFatalErrorRecovery(){this.fatalError=null}static{this.views=new r}};e([V()],B.prototype,"_userSpatialReference",void 0),e([V()],B.prototype,"activeTool",null),e([V({readOnly:!0})],B.prototype,"allLayerViews",void 0),e([V(R(k,"analyses"))],B.prototype,"analyses",void 0),e([V()],B.prototype,"animation",null),e([V()],B.prototype,"basemapView",void 0),e([V()],B.prototype,"center",null),e([V()],B.prototype,"defaultsFromMapSettings",null),e([V()],B.prototype,"defaultsFromMap",null),e([V()],B.prototype,"displayFilterEnabled",void 0),e([V({type:T})],B.prototype,"extent",null),e([V()],B.prototype,"fatalError",void 0),e([V(R(x,"graphics"))],B.prototype,"graphics",void 0),e([V()],B.prototype,"groundView",void 0),e([V({readOnly:!0,type:j})],B.prototype,"heightModelInfo",null),e([V({type:r.ofType(A)})],B.prototype,"highlights",null),e([V({readOnly:!0})],B.prototype,"interacting",null),e([V({constructOnly:!0})],B.prototype,"layerViewFilter",void 0),e([V({readOnly:!0})],B.prototype,"navigating",null),e([V({readOnly:!0,dependsOn:["fatalError","_isValid","_readyCycleForced","map","map.loaded?","width","height","spatialReference","_lockedSpatialReference","defaultsFromMap.ready","typeSpecificPreconditionsReady"]})],B.prototype,"preconditionsReady",null),e([V({readOnly:!0})],B.prototype,"typeSpecificPreconditionsReady",void 0),e([V({type:r,readOnly:!0})],B.prototype,"layerViews",void 0),e([V()],B.prototype,"resolution",null),e([V({type:H})],B.prototype,"magnifier",void 0),e([V({value:null,type:t})],B.prototype,"map",null),e([V()],B.prototype,"padding",void 0),e([V({readOnly:!0})],B.prototype,"ready",void 0),e([V()],B.prototype,"_readyStateWaitingTask",void 0),e([V({readOnly:!0})],B.prototype,"readyState",null),e([V({type:F})],B.prototype,"spatialReference",null),e([V()],B.prototype,"stationary",null),e([V({readOnly:!0})],B.prototype,"supportsGround",void 0),e([V({type:O})],B.prototype,"timeExtent",null),e([V({type:String,nonNullable:!0})],B.prototype,"timeZone",null),e([V()],B.prototype,"tools",null),e([V()],B.prototype,"toolViewManager",void 0),e([V({readOnly:!0})],B.prototype,"type",void 0),e([V({type:Number})],B.prototype,"scale",void 0),e([V({readOnly:!0})],B.prototype,"updating",void 0),e([V({readOnly:!0})],B.prototype,"initialExtentRequired",void 0),e([V({readOnly:!0})],B.prototype,"initialExtent",null),e([V()],B.prototype,"cursor",null),e([V({readOnly:!0})],B.prototype,"input",void 0),e([V({type:U,nonNullable:!0})],B.prototype,"navigation",void 0),e([V()],B.prototype,"layerViewManager",void 0),e([V()],B.prototype,"analysisViewManager",void 0),e([V()],B.prototype,"selectionManager",void 0),e([V()],B.prototype,"width",void 0),e([V()],B.prototype,"height",void 0),e([V({readOnly:!0})],B.prototype,"resizing",void 0),e([V({value:null,readOnly:!0})],B.prototype,"size",null),e([V({readOnly:!0})],B.prototype,"suspended",void 0),e([V({readOnly:!0})],B.prototype,"viewEvents",void 0),e([V({readOnly:!0})],B.prototype,"persistableViewModels",void 0),e([V()],B.prototype,"_isValid",void 0),e([V()],B.prototype,"_readyCycleForced",void 0),e([V()],B.prototype,"_lockedSpatialReference",void 0),e([V()],B.prototype,"_userTimeZone",void 0),e([V()],B.prototype,"_lockedTimeZone",void 0),e([V()],B.prototype,"_userTimeExtent",void 0),e([V()],B.prototype,"_lockedTimeExtent",void 0),e([V({type:Z})],B.prototype,"theme",void 0),e([V({readOnly:!0,type:Z})],B.prototype,"effectiveTheme",null),B=$=e([M("esri.views.View")],B);const J=globalThis.$arcgis;J&&!J.views&&Object.defineProperty(J,"views",{configurable:!1,enumerable:!0,writable:!1,value:B.views});const K=B;function Q(e){return e.layerViews}export{K as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../Map.js";import{createTask as i}from"../core/asyncUtils.js";import r from"../core/Collection.js";import s from"../core/CollectionFlattener.js";import{referenceSetter as a}from"../core/collectionUtils.js";import o from"../core/Error.js";import{EventedMixin as n}from"../core/Evented.js";import l from"../core/Handles.js";import{makeHandle as p}from"../core/handleUtils.js";import has from"../core/has.js";import{isLoadable as h}from"../core/Loadable.js";import d from"../core/Logger.js";import{destroyMaybe as y,abortMaybe as u}from"../core/maybe.js";import{EsriPromise as m}from"../core/Promise.js";import{after as c}from"../core/promiseUtils.js";import{watch as g,sync as f,whenOnce as w,when as v,syncAndInitial as _}from"../core/reactiveUtils.js";import{property as V}from"../core/accessorSupport/decorators/property.js";import"../core/RandomLCG.js";import{subclass as M}from"../core/accessorSupport/decorators/subclass.js";import{owningCollectionProperty as R}from"../core/support/OwningCollection.js";import{UpdatingHandles as S}from"../core/support/UpdatingHandles.js";import T from"../geometry/Extent.js";import j from"../geometry/HeightModelInfo.js";import F from"../geometry/SpatialReference.js";import{equals as E}from"../geometry/support/spatialReferenceUtils.js";import{AnalysesCollection as k}from"../support/AnalysesCollection.js";import{GraphicsCollection as x}from"../support/GraphicsCollection.js";import{system as b}from"../time/constants.js";import{T as O}from"../chunks/TimeExtent.js";import{isTimeZoneValid as C}from"../time/timeZoneUtils.js";import L from"./BasemapView.js";import H from"./Magnifier.js";import P from"./SelectionManager.js";import Z from"./Theme.js";import{ToolViewManager as I}from"./ToolViewManager.js";import{makeDefaultHighlightOptions as W}from"./3d/support/DefaultHighlights.js";import q from"./input/Input.js";import{ViewEvents as D}from"./input/ViewEvents.js";import U from"./navigation/Navigation.js";import{DefaultsFromMap as z}from"./support/DefaultsFromMap.js";import A from"./support/HighlightOptions.js";import G from"./support/LayerViewManager.js";import N from"./support/RequiredFieldsOptions.js";var $;let B=class extends(n(m)){static{$=this}constructor(e){super(e),this._userSpatialReference=null,this.handles=new l,this.updatingHandles=new S,this.allLayerViews=new s({getCollections:()=>[this.basemapView?.baseLayerViews,this.basemapView?.groundLayerViews,this.groundView?.layerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:Q}),this.analyses=new k,this.basemapView=null,this.displayFilterEnabled=!0,this.fatalError=null,this.graphics=new x,this.groundView=null,this.typeSpecificPreconditionsReady=!0,this.layerViews=new r,this.magnifier=new H,this.padding={left:0,top:0,right:0,bottom:0},this.ready=!1,this._readyStateWaitingTask=null,this.supportsGround=!0,this.type=null,this.scale=null,this.updating=!1,this.initialExtentRequired=!0,this._lowPriorityCursorHandles=new r,this._highPriorityCursorHandles=new r,this.input=new q,this.navigation=new U,this.layerViewManager=null,this.analysisViewManager=null,this.isHeightModelInfoRequired=!1,this.width=null,this.height=null,this.resizing=!1,this.suspended=!1,this.viewEvents=new D(this),this.persistableViewModels=new r,this.requiredFieldsOptions=new N,this._isValid=!1,this._readyCycleForced=!1,this._lockedSpatialReference=null,this._userTimeZone=null,this._lockedTimeZone=null,this._userTimeExtent=null,this._lockedTimeExtent=null,this.theme=null,this.handles.add(g(()=>this.preconditionsReady,e=>{const t=this.ready;if(e?(this._lockedSpatialReference=this.spatialReference,this._lockedTimeZone=this.timeZone,this._lockedTimeExtent=this.timeExtent,$.views.add(this)):(this._lockedSpatialReference=null,$.views.remove(this)),this.notifyChange("spatialReference"),!e&&t)this.toolViewManager?.detach(),this.analysisViewManager?.detach(),this.layerViewManager?.clear(),this._teardown();else if(e&&!t){try{this._startup()}catch(i){return void queueMicrotask(()=>{this.fatalError=new o("view:startup-error","View._startup failed",i)})}this.analysisViewManager?.attach(),this.toolViewManager.attach()}},f))}initialize(){this.addResolvingPromise(Promise.all([this.loadAsyncDependencies(),this.validate()]).then(()=>(this._isValid=!0,w(()=>this.ready)))),this.basemapView=new L({view:this}),this.layerViewManager=new G({view:this,layerViewFilter:e=>this.layerViewFilter?.(e)??!0,layerViewImporter:{importLayerView:e=>this.importLayerView(e),hasLayerViewModule:e=>this.hasLayerViewModule(e)},supportsGround:this.supportsGround}),this.toolViewManager=new I({view:this}),this.selectionManager=new P({view:this}),this.addHandles([v(()=>"map-content-error"===this.readyState&&!this.spatialReference,()=>{d.getLogger(this).warn("#spatialReference","no spatial reference could be derived from the currently added map layers")}),g(()=>this.initialExtentRequired,e=>this.defaultsFromMap.required={...this.defaultsFromMap.required,extent:e},_),g(()=>this.ready,e=>{this.defaultsFromMap&&(this.defaultsFromMap.suspended=e,this.defaultsFromMap.userSpatialReference=e?this.spatialReference:this._userSpatialReference)},f),g(()=>this._userSpatialReference,e=>{this.defaultsFromMap&&(this.defaultsFromMap.userSpatialReference=e)},_)])}destroy(){this.destroyed||($.views.remove(this),this.viewEvents.destroy(),this.allLayerViews.destroy(),this.navigation&&(this.navigation.destroy(),this._set("navigation",null)),this.graphics=y(this.graphics),this.analyses=y(this.analyses),this.defaultsFromMap.destroy(),this._set("defaultsFromMap",null),this.analysisViewManager=y(this.analysisViewManager),this.toolViewManager=y(this.toolViewManager),this.layerViewManager=y(this.layerViewManager),this.selectionManager=y(this.selectionManager),this.basemapView=y(this.basemapView),this.groundView?.destroy(),this.layerViews?.forEach(e=>e.destroy()),this.layerViews.length=0,this.invalidate(),this.handles.destroy(),this.map=y(this.map),this.updatingHandles.destroy())}_startup(){this._set("ready",!0)}_teardown(){this._set("ready",!1)}whenReady(){return Promise.resolve(this)}toMap(){return d.getLogger(this).error("#toMap()","Not implemented on this instance of View"),null}get activeTool(){return this.toolViewManager?.activeTool}set activeTool(e){this.toolViewManager&&(this.toolViewManager.activeTool=e)}get animation(){return this._get("animation")}set animation(e){this._set("animation",e)}get center(){return null}get defaultsFromMapSettings(){return{}}get defaultsFromMap(){return new z({required:{tileInfo:!1,heightModelInfo:!1,extent:!1},map:()=>this.map,getSpatialReferenceSupport:(e,t)=>this.getSpatialReferenceSupport(e,t),...this.defaultsFromMapSettings})}get extent(){return this._get("extent")}set extent(e){this._set("extent",e)}get heightModelInfo(){return this.getDefaultHeightModelInfo()}get highlights(){return this._get("highlights")??W()}set highlights(e){this._set("highlights",a(e,this._get("highlights"),r.ofType(A)))}get interacting(){return this.navigating}get navigating(){return!1}get preconditionsReady(){return!this.destroying&&!this.destroyed&&!(this.fatalError||!this._isValid||this._readyCycleForced||!this.map||h(this.map)&&!this.map.loaded||0===this.width||0===this.height||!this.spatialReference||!this._validateSpatialReference(this.spatialReference)||!this._lockedSpatialReference&&!this.defaultsFromMap?.ready||!this.typeSpecificPreconditionsReady)}get resolution(){return 0}set map(e){e!==this._get("map")&&(e?.destroyed&&(d.getLogger(this).warn("#map","The provided map is already destroyed",{map:e}),e=null),h(e)&&e.load().catch(()=>{}),this.constructed&&!this.destroyed&&(this.forceReadyCycle(),this._lockedSpatialReference=null),this._set("map",e))}get readyState(){if(this.destroyed)return this._get("readyState");if(!this.map)return"missing-map";if("container"in this&&!this.container)return"missing-container";if(this.fatalError)return"rendering-error";if((this.defaultsFromMap?.ready??!1)&&!this.spatialReference){const e=!("loaded"in this.map)||this.map.loaded,t=this.map.ground.loaded,r=this.map.basemap?.loaded??!0;return e&&r&&t&&!this.map?.allLayers.length?"empty-map":(this._readyStateWaitingTask||(this._readyStateWaitingTask=i(e=>c(has("view-readyState-waiting-delay"),null,e)),this.addHandles(this._readyStateWaitingTask),this.addHandles(this._readyStateWaitingTask,"ready-state-task")),this._readyStateWaitingTask?.finished?"map-content-error":"loading")}return this._readyStateWaitingTask=u(this._readyStateWaitingTask),this.removeHandles("ready-state-task"),this.ready?"ready":"loading"}get spatialReference(){const e=this._userSpatialReference||this._lockedSpatialReference||this.getDefaultSpatialReference()||null;if(e&&this.defaultsFromMap?.required?.heightModelInfo){const t=e.clone();return t.vcsWkid=this.defaultsFromMap.vcsWkid,t.latestVcsWkid=this.defaultsFromMap.latestVcsWkid,t}return e}set spatialReference(e){const t=!E(e,this._get("spatialReference"));this._set("_userSpatialReference",e),t&&(this._set("spatialReference",e),this._spatialReferenceChanged(e))}_spatialReferenceChanged(e){}get stationary(){return!this.animation&&!this.navigating&&!this.resizing}get timeExtent(){return this._userTimeExtent??this._lockedTimeExtent??this.getDefaultTimeExtent()??null}set timeExtent(e){this._userTimeExtent=e}get timeZone(){return this._userTimeZone??this._lockedTimeZone??this.getDefaultTimeZone()??b}set timeZone(e){this._userTimeZone=e,C(e)||d.getLogger(this).warn("#timeZone",`the parsed value '${e}' may not be a valid IANA time zone`)}get tools(){return this.toolViewManager?.tools}get initialExtent(){return this.defaultsFromMap?.extent}get cursor(){return this.toolViewManager?.cursor??this._highPriorityCursorHandles.at(-1)?.cursor??this._lowPriorityCursorHandles.at(-1)?.cursor??"default"}acquireCursor(e,t="low"){const i="high"===t?this._highPriorityCursorHandles:this._lowPriorityCursorHandles,r={cursor:e},s=p(()=>i.remove(r));return i.add(r),this.addHandles(s),s}get size(){return[this.width,this.height]}get effectiveTheme(){return this.theme??new Z}whenLayerView(e){return this.layerViewManager?.whenLayerView(e)??Promise.reject()}getDefaultSpatialReference(){return this.defaultsFromMap?.spatialReference}getDefaultHeightModelInfo(){return(this.map&&"heightModelInfo"in this.map?this.map.heightModelInfo:void 0)??this.defaultsFromMap?.heightModelInfo??null}getDefaultTimeZone(){return null}getDefaultTimeExtent(){return null}importLayerView(e){throw new o("view:importLayerView-missing","importLayerView() not implemented")}hasLayerViewModule(e){return!1}async validate(){}async loadAsyncDependencies(){}invalidate(){this._isValid=!1}getSpatialReferenceSupport(){return{constraints:null}}_validateSpatialReference(e){return null!=this.getSpatialReferenceSupport(e)}when(e,t){return this.isResolved()&&!this.ready&&d.getLogger(this).warn("#when()","Calling view.when() while the view is no longer ready but was already resolved once will resolve immediately. Use reactiveUtils.whenOnce(() => view.ready).then(...) instead."),super.when(e,t)}forceReadyCycle(){this.ready&&(v(()=>this.destroyed||!1===this.preconditionsReady,()=>this._readyCycleForced=!1,{once:!0}),this._readyCycleForced=!0)}on(e,t){return super.on(e,t)}addAndActivateTool(e){this.toolViewManager.tools.add(e),this.activeTool=e}tryFatalErrorRecovery(){this.fatalError=null}static{this.views=new r}};e([V()],B.prototype,"_userSpatialReference",void 0),e([V()],B.prototype,"activeTool",null),e([V({readOnly:!0})],B.prototype,"allLayerViews",void 0),e([V(R(k,"analyses"))],B.prototype,"analyses",void 0),e([V()],B.prototype,"animation",null),e([V()],B.prototype,"basemapView",void 0),e([V()],B.prototype,"center",null),e([V()],B.prototype,"defaultsFromMapSettings",null),e([V()],B.prototype,"defaultsFromMap",null),e([V()],B.prototype,"displayFilterEnabled",void 0),e([V({type:T})],B.prototype,"extent",null),e([V()],B.prototype,"fatalError",void 0),e([V(R(x,"graphics"))],B.prototype,"graphics",void 0),e([V()],B.prototype,"groundView",void 0),e([V({readOnly:!0,type:j})],B.prototype,"heightModelInfo",null),e([V({type:r.ofType(A)})],B.prototype,"highlights",null),e([V({readOnly:!0})],B.prototype,"interacting",null),e([V({constructOnly:!0})],B.prototype,"layerViewFilter",void 0),e([V({readOnly:!0})],B.prototype,"navigating",null),e([V({readOnly:!0,dependsOn:["fatalError","_isValid","_readyCycleForced","map","map.loaded?","width","height","spatialReference","_lockedSpatialReference","defaultsFromMap.ready","typeSpecificPreconditionsReady"]})],B.prototype,"preconditionsReady",null),e([V({readOnly:!0})],B.prototype,"typeSpecificPreconditionsReady",void 0),e([V({type:r,readOnly:!0})],B.prototype,"layerViews",void 0),e([V()],B.prototype,"resolution",null),e([V({type:H})],B.prototype,"magnifier",void 0),e([V({value:null,type:t})],B.prototype,"map",null),e([V()],B.prototype,"padding",void 0),e([V({readOnly:!0})],B.prototype,"ready",void 0),e([V()],B.prototype,"_readyStateWaitingTask",void 0),e([V({readOnly:!0})],B.prototype,"readyState",null),e([V({type:F})],B.prototype,"spatialReference",null),e([V()],B.prototype,"stationary",null),e([V({readOnly:!0})],B.prototype,"supportsGround",void 0),e([V({type:O})],B.prototype,"timeExtent",null),e([V({type:String,nonNullable:!0})],B.prototype,"timeZone",null),e([V()],B.prototype,"tools",null),e([V()],B.prototype,"toolViewManager",void 0),e([V({readOnly:!0})],B.prototype,"type",void 0),e([V({type:Number})],B.prototype,"scale",void 0),e([V({readOnly:!0})],B.prototype,"updating",void 0),e([V({readOnly:!0})],B.prototype,"initialExtentRequired",void 0),e([V({readOnly:!0})],B.prototype,"initialExtent",null),e([V()],B.prototype,"cursor",null),e([V({readOnly:!0})],B.prototype,"input",void 0),e([V({type:U,nonNullable:!0})],B.prototype,"navigation",void 0),e([V()],B.prototype,"layerViewManager",void 0),e([V()],B.prototype,"analysisViewManager",void 0),e([V()],B.prototype,"selectionManager",void 0),e([V()],B.prototype,"width",void 0),e([V()],B.prototype,"height",void 0),e([V({readOnly:!0})],B.prototype,"resizing",void 0),e([V({value:null,readOnly:!0})],B.prototype,"size",null),e([V({readOnly:!0})],B.prototype,"suspended",void 0),e([V({readOnly:!0})],B.prototype,"viewEvents",void 0),e([V({readOnly:!0})],B.prototype,"persistableViewModels",void 0),e([V()],B.prototype,"_isValid",void 0),e([V()],B.prototype,"_readyCycleForced",void 0),e([V()],B.prototype,"_lockedSpatialReference",void 0),e([V()],B.prototype,"_userTimeZone",void 0),e([V()],B.prototype,"_lockedTimeZone",void 0),e([V()],B.prototype,"_userTimeExtent",void 0),e([V()],B.prototype,"_lockedTimeExtent",void 0),e([V({type:Z})],B.prototype,"theme",void 0),e([V({readOnly:!0,type:Z})],B.prototype,"effectiveTheme",null),B=$=e([M("esri.views.View")],B);const J=globalThis.$arcgis;J&&!J.views&&Object.defineProperty(J,"views",{configurable:!1,enumerable:!0,writable:!1,value:B.views});const K=B;function Q(e){return e.layerViews}export{K as default};
|
package/views/View2D.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../Viewpoint.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import has from"../core/has.js";import a from"../core/Logger.js";import{destroyMaybe as n}from"../core/maybe.js";import{watch as o,syncAndInitial as l}from"../core/reactiveUtils.js";import{initialize as p}from"../core/workers/workers.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import{cast as g}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as u}from"../core/accessorSupport/ensureType.js";import c from"../geometry/Polygon.js";import{isLoadedOrLoadFor as m}from"../geometry/projectionUtils.js";import y from"../layers/support/TileInfo.js";import{BreakpointsOwner as f}from"./BreakpointsOwner.js";import{DOMContainer as w}from"./DOMContainer.js";import{PopupView as V}from"./PopupView.js";import v from"./View.js";import{Viewport2DBaseMixin as M}from"./Viewport2DBaseMixin.js";import{Viewport2DMixin as b}from"./Viewport2DMixin.js";import _ from"./2d/AnimationManager.js";import{layerView2DImporter as j}from"./2d/layerViewModuleImportUtils.js";import R from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{extentToScale as S}from"./2d/viewpointUtils.js";import{ManagedCanvas as L}from"./2d/engine/ManagedCanvas.js";import O from"./2d/layers/features/support/TileStore.js";import{createOrReuseHighlightGradient as T}from"./2d/layers/support/util.js";import{clipContainsPoint as C}from"./2d/support/clippingUtils.js";import{getDefaultHighlightOptions as k,setDefaultHighlightOptions as x}from"./2d/support/highlightOptionsUtils.js";import{hitTest as D}from"./2d/support/hitTestUtils.js";import{takeRawScreenshot as P,takeScreenshot as E}from"./2d/support/screenshotUtils.js";import{Timeline as z}from"./2d/support/Timeline.js";import A from"./navigation/Navigation.js";import G from"./navigation/NavigationActionMap.js";import U from"./support/HighlightOptions.js";import{check as q}from"./support/WebGLRequirements.js";import I from"./ui/DefaultUI.js";import N from"./ui/2d/DefaultUI2D.js";import{RenderingContextOptions as W}from"./webgl/RenderingContextOptions.js";import{isWebMap as $}from"../webmap/utils.js";import F from"../webmap/background/ColorBackground.js";let H,B,Z,J,K,Q,X;async function Y(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,GridView2D:a,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);B=e,Z=t,J=i,K=r,Q=s,X=a,H=n}let ee=class extends(b(M(f(V(w(v)))))){get timeZone(){return super.timeZone}set timeZone(e){super.timeZone=e}constructor(e){super(e),this._magnifierView=null,this._gridView=null,this.stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.graphicsView=null,this.labelManager=null,this.navigation=new A({actionMap:new G({dragTertiary:"none"})}),this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.supersampleScreenshotsEnabled=!0,this.supportsGround=!1,this.floors=new i,this.grid=null,this.map=null,this.spatialReferenceLocked=!1,this.timeline=new z,this.type="2d",this.view2dType=null,this.ui=new N,this.test={takeScreenshot:async e=>P(this._getScreenshotView(e),e)},this.padding={top:0,right:0,bottom:0,left:0},p()}destroy(){this.layerViewManager.clear(),this._set("preconditionsReady",!1),this.frameTask=n(this.frameTask),this.goToManager.destroy(),this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new O(this.featuresTilingScheme)}get constraintsInfo(){const e=this.defaultsFromMap?.tileInfo,t=this.spatialReference;return{lods:e?.spatialReference?.equals(t)?e.lods:null,spatialReference:t}}get initialExtentRequired(){if(!this.stateManager)return!1;const{scale:e,constraints:t,center:i,viewpoint:r,extent:s}=this;let a=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!s&&(t?.effectiveLODs||(a=-1),(!i||0===e&&-1===a)&&(null==r?.targetGeometry||"extent"!==r.targetGeometry.type&&!r.scale)))}get defaultsFromMapSettings(){return{required:{extent:!1,heightModelInfo:!1,tileInfo:!0},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get scheduler(){return this.frameTask.scheduler}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=e.targetGeometry,i=this.spatialReference;return m(t.spatialReference,i)}get background(){return $(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){return this.stateManager?.center??null}set center(e){this.stateManager.center=e}get constraints(){return super.constraints}set constraints(e){super.constraints=e}get highlightOptions(){return k(this)}set highlightOptions(e){x(this,e)}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get rendering(){return this.stage?.renderRequested??!1}get resizeAlign(){return super.resizeAlign}set resizeAlign(e){super.resizeAlign=e}get resolution(){return this.stateManager.resolution??0}get rotation(){return super.rotation}set rotation(e){super.rotation=e}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get spatialReference(){return super.spatialReference}set spatialReference(e){super.spatialReference=e}get tileInfo(){return this.featuresTilingScheme?.tileInfo}get updating(){const e=!(!this.magnifier.visible||null===this.magnifier.position||!this._magnifierView?.updatingHandles.updating),t=!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some(e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)||e);if(has("esri-2d-log-updating")){const i=this.allLayerViews.reduce((e,t)=>({...e,[`${t.layer.id}(${t.layer.type})`]:!t.destroyed&&!("layerViews"in t)&&t.updating}),{});console.log(`Updating MapView: ${t}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(i)}\n-> updatingMagnifier: ${e}\n`)}return t}get viewpoint(){return super.viewpoint}set viewpoint(e){super.viewpoint=e}get visibleArea(){const e=this.stateManager.visibleArea;return e?new c({rings:[e.map(e=>[e[0],e[1]])],spatialReference:this.spatialReference}):e}get zoom(){return this.stateManager.zoom??-1}set zoom(e){this.stateManager.zoom=e}get navigating(){return this.mapViewNavigation?.interacting??!1}async hitTest(e,t){return D(this,e,t)}async takeScreenshot(e){return E(this._getScreenshotView(e),e)}toScreen(e,t){return this.stateManager.toScreen(e,t)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise(e=>{this.ready?e(this):this._resolveWhenReady.push(e)})}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties.spatialReference||this.defaultsFromMap?.spatialReference||null}getDefaultTimeZone(){return $(this.map)?this.map.initialViewProperties.timeZone:null}getDefaultTimeExtent(){return $(this.map)?this.map.initialViewProperties.timeExtent:null}hasLayerViewModule(e){return j.hasLayerViewModule(e)}importLayerView(e){return j.importLayerView(e)}pixelSizeAt(){return this.ready?this.resolution:(a.getLogger(this).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}async popupHitTest(e){const t=this.toMap(e),i=await this.hitTest(e),r=this.allLayerViews.toArray().filter(i=>i.clips.every(i=>C(this,i,e,t))).reverse(),s=new globalThis.Map(r.map(e=>[e.layer.uid,e])),a=[];let n=0,o=0;for(;n<i.results.length||o<r.length;){const e=i.results.at(n);if(e&&"graphic"!==e.type){++n;continue}const l=s.get((e?.layer??e?.graphic.layer)?.uid);if((!e||l)&&o<r.length&&r.at(o)!==l){const e=r.at(o);"fetchPopupFeaturesAtLocation"in e&&a.push({mapPoint:t,layerView:e}),++o}else e&&(a.push({graphic:e.graphic,layerView:l}),++n)}return{hits:a,location:t}}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}async validate(){let e=q(this.type);if(has("safari")&&has("safari")<9&&(e=new s("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:has("safari")})),null!=e){a.getLogger(this).warn("#validate()",e.message);const t=document.createElement("div");t.setAttribute("style","display: flex; flex-direction: column; gap: 8px; padding: 20px; height: 100%; justify-content: center; color: black; background: white; font-family: sans-serif;");const i=document.createElement("div");i.innerHTML="Unable to display map. WebGL2 support is required.",i.setAttribute("style","font-size: 24px; font-weight: bold;");const r=document.createElement("div");r.innerHTML="Ensure that your browser and hardware meet the minimum requirements.",r.setAttribute("style","font-size: 18px;");const s=document.createElement("a");throw s.innerHTML="https://esriurl.com/systemRequirements",s.target="_blank",s.setAttribute("style","font-size: 18px;"),s.href="https://esriurl.com/systemRequirements",t.appendChild(i),t.appendChild(r),t.appendChild(s),this.surface.appendChild(t),e}}loadAsyncDependencies(){return Y()}_getDefaultViewpoint(){const{constraints:e,initialExtent:i,map:r,padding:s,size:a}=this;if(!e)return null;const n=r&&"initialViewProperties"in r?r.initialViewProperties:void 0,o=this.stateManager.getUserStartupOptions(this.size),l=n?.viewpoint,p=l?.targetGeometry?.extent??i,h=p?.center,g=l?.rotation??0,d=l?.scale||p&&S(p,[a[0]-s.left-s.right,a[1]-s.top-s.bottom]),u=o.center??h,c=o.rotation??g,m=o.scale??d;return u&&m?new t({targetGeometry:u,scale:m,rotation:c}):null}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint();this.stateManager.startup(e,this.size,this.spatialReference,this.defaultsFromMap.extent?.center),this.graphics.owner=this;const t=new L(this.surface),i=new H(this.surface,{canvas:this.renderCanvas,contextOptions:new W(this.deactivatedWebGLExtensions,this.debugWebGLExtensions),renderingOptions:this.renderingOptions,timeline:this.timeline},t);this.stage=i,this._magnifierView=new Q,this._magnifierView.magnifier=this.magnifier,this._gridView=new X;const r=new J({view:this});this._set("labelManager",r);const s=new _({view:this});this._set("animationManager",s);const a=new K({view:this,animationManager:s});this._set("mapViewNavigation",a),this._setupSpatialReferenceDependentProperties(),this.addHandles([this.rootLayerViews.on("change",()=>this._updateStageChildren()),i.on("webgl-error",e=>this.fatalError=e.error),o(()=>this.stationary,e=>i.stationary=e,l),o(()=>this.background,e=>{i.backgroundColor=e?.color,this._magnifierView.backgroundColor=e?.color},l),o(()=>this.magnifier,e=>this._magnifierView.magnifier=e,l),o(()=>this.grid,e=>this._gridView.grid=e,l),o(()=>this.renderingOptions,e=>i.renderingOptions=e,l),o(()=>this.highlights.items.map(e=>({name:e.name,options:{fillColor:e.color,haloColor:e.haloColor,fillOpacity:e.fillOpacity,haloOpacity:e.haloOpacity,haloWidth:e.haloWidth,haloBlur:e.haloBlur}})),()=>{i.highlightGradient=T(i.highlightGradient,this.highlights.items)},l),o(()=>this.state.id,()=>i.state=this.state,l)],"map-view"),this._updateStageChildren();const n=this._resolveWhenReady;this._resolveWhenReady=[],n.forEach(e=>e(this)),this.timeline.end("MapView Startup"),this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.removeHandles("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animation=null,this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._gridView.destroy(),this.stage.destroy(),this.stage=null,this._set("graphicsView",null),this._magnifierView=null,this._gridView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask.stop(),this.stationaryManager.clear(),this._set("ready",!1),this.stateManager.teardown()}_updateStageChildren(){this.stage.removeAllChildren(),this.rootLayerViews.forEach(e=>{this.stage.addChild(e.container)});const e=this.graphicsView;this.stage.addChild(e.container),this.stage.addChild(this._magnifierView),this.stage.addChild(this._gridView)}_setupSpatialReferenceDependentProperties(){const e=new R(y.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new B({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new Z(e)});this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),e.destroy(),this._set("featuresTilingScheme",null)}_getScreenshotView(e){const{allLayerViews:t,padding:i,size:r,stage:s}=this;return{allLayerViews:t,backgroundColor:e?.ignoreBackground?null:this.background?.color,padding:i,size:r,stage:s}}_spatialReferenceChanged(e){if(this.ready){this.frameTask.stop();for(const e of this.allLayerViews)e.processDetach();this._destroySpatialReferenceDependentProperties(),this.stateManager.changeSpatialReference(e),this.stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const e of this.allLayerViews)e.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}}static{this.type="2d"}};e([h({constructOnly:!0})],ee.prototype,"deactivatedWebGLExtensions",void 0),e([h({constructOnly:!0})],ee.prototype,"debugWebGLExtensions",void 0),e([h({readOnly:!0})],ee.prototype,"featuresTilingScheme",void 0),e([h({readOnly:!0})],ee.prototype,"graphicsTileStore",null),e([h()],ee.prototype,"graphicsView",void 0),e([h()],ee.prototype,"constraintsInfo",null),e([h()],ee.prototype,"initialExtentRequired",null),e([h()],ee.prototype,"labelManager",void 0),e([h({type:A,nonNullable:!0})],ee.prototype,"navigation",void 0),e([h({constructOnly:!0})],ee.prototype,"renderCanvas",void 0),e([h()],ee.prototype,"renderingOptions",void 0),e([h({constructOnly:!0})],ee.prototype,"supersampleScreenshotsEnabled",void 0),e([h({readOnly:!0})],ee.prototype,"supportsGround",void 0),e([h()],ee.prototype,"defaultsFromMapSettings",null),e([h({readOnly:!0})],ee.prototype,"typeSpecificPreconditionsReady",null),e([h({type:F})],ee.prototype,"background",null),e([h()],ee.prototype,"center",null),e([h({type:i})],ee.prototype,"floors",void 0),e([h()],ee.prototype,"grid",void 0),e([h({type:U})],ee.prototype,"highlightOptions",null),e([h()],ee.prototype,"map",void 0),e([h()],ee.prototype,"padding",null),e([h({readOnly:!0})],ee.prototype,"rendering",null),e([h({readOnly:!0})],ee.prototype,"resolution",null),e([h()],ee.prototype,"scale",null),e([h({constructOnly:!0})],ee.prototype,"spatialReferenceLocked",void 0),e([h({readOnly:!0})],ee.prototype,"tileInfo",null),e([h({type:z,readOnly:!0})],ee.prototype,"timeline",void 0),e([h({readOnly:!0})],ee.prototype,"type",void 0),e([h({readOnly:!0})],ee.prototype,"updating",null),e([h({readOnly:!0})],ee.prototype,"view2dType",void 0),e([h({readOnly:!0})],ee.prototype,"visibleArea",null),e([h()],ee.prototype,"zoom",null),e([h({readOnly:!0})],ee.prototype,"navigating",null),e([h(),g(e=>e instanceof I?e:u(N,e))],ee.prototype,"ui",void 0),ee=e([d("esri.views.View2D")],ee);const te=ee;export{te as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../Viewpoint.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import has from"../core/has.js";import a from"../core/Logger.js";import{destroyMaybe as n}from"../core/maybe.js";import{watch as o,syncAndInitial as l}from"../core/reactiveUtils.js";import{initialize as p}from"../core/workers/workers.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import{cast as g}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as u}from"../core/accessorSupport/ensureType.js";import c from"../geometry/Polygon.js";import{isLoadedOrLoadFor as m}from"../geometry/projectionUtils.js";import y from"../layers/support/TileInfo.js";import{BreakpointsOwner as f}from"./BreakpointsOwner.js";import{DOMContainer as w}from"./DOMContainer.js";import{PopupView as V}from"./PopupView.js";import M from"./View.js";import{Viewport2DBaseMixin as v}from"./Viewport2DBaseMixin.js";import{Viewport2DMixin as b}from"./Viewport2DMixin.js";import{importAnalysisViewModule as _}from"./2d/analysisViewModuleImportUtils.js";import j from"./2d/AnimationManager.js";import{layerView2DImporter as R}from"./2d/layerViewModuleImportUtils.js";import S from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{extentToScale as L}from"./2d/viewpointUtils.js";import{ManagedCanvas as O}from"./2d/engine/ManagedCanvas.js";import T from"./2d/layers/features/support/TileStore.js";import{createOrReuseHighlightGradient as C}from"./2d/layers/support/util.js";import{clipContainsPoint as k}from"./2d/support/clippingUtils.js";import{getDefaultHighlightOptions as x,setDefaultHighlightOptions as D}from"./2d/support/highlightOptionsUtils.js";import{hitTest as A}from"./2d/support/hitTestUtils.js";import{takeRawScreenshot as P,takeScreenshot as E}from"./2d/support/screenshotUtils.js";import{Timeline as z}from"./2d/support/Timeline.js";import G from"./navigation/Navigation.js";import U from"./navigation/NavigationActionMap.js";import q from"./support/AnalysisViewManager.js";import I from"./support/HighlightOptions.js";import{check as N}from"./support/WebGLRequirements.js";import W from"./ui/DefaultUI.js";import $ from"./ui/2d/DefaultUI2D.js";import{RenderingContextOptions as F}from"./webgl/RenderingContextOptions.js";import{isWebMap as H}from"../webmap/utils.js";import B from"../webmap/background/ColorBackground.js";let Z,J,K,Q,X,Y,ee;async function te(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,GridView2D:a,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);J=e,K=t,Q=i,X=r,Y=s,ee=a,Z=n}let ie=class extends(b(v(f(V(w(M)))))){get timeZone(){return super.timeZone}set timeZone(e){super.timeZone=e}constructor(e){super(e),this._magnifierView=null,this._gridView=null,this.stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.graphicsView=null,this.labelManager=null,this.navigation=new G({actionMap:new U({dragTertiary:"none"})}),this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.supersampleScreenshotsEnabled=!0,this.supportsGround=!1,this.analysisViewManager=new q({importAnalysisViewModule:e=>_(e),view:this}),this.floors=new i,this.grid=null,this.map=null,this.spatialReferenceLocked=!1,this.timeline=new z,this.type="2d",this.view2dType=null,this.ui=new $,this.test={takeScreenshot:async e=>P(this._getScreenshotView(e),e)},this.padding={top:0,right:0,bottom:0,left:0},p()}destroy(){this.layerViewManager.clear(),this._set("preconditionsReady",!1),this.frameTask=n(this.frameTask),this.goToManager.destroy(),this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new T(this.featuresTilingScheme)}get constraintsInfo(){const e=this.defaultsFromMap?.tileInfo,t=this.spatialReference;return{lods:e?.spatialReference?.equals(t)?e.lods:null,spatialReference:t}}get initialExtentRequired(){if(!this.stateManager)return!1;const{scale:e,constraints:t,center:i,viewpoint:r,extent:s}=this;let a=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!s&&(t?.effectiveLODs||(a=-1),(!i||0===e&&-1===a)&&(null==r?.targetGeometry||"extent"!==r.targetGeometry.type&&!r.scale)))}get defaultsFromMapSettings(){return{required:{extent:!1,heightModelInfo:!1,tileInfo:!0},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get scheduler(){return this.frameTask.scheduler}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=e.targetGeometry,i=this.spatialReference;return m(t.spatialReference,i)}get background(){return H(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){return this.stateManager?.center??null}set center(e){this.stateManager.center=e}get constraints(){return super.constraints}set constraints(e){super.constraints=e}get highlightOptions(){return x(this)}set highlightOptions(e){D(this,e)}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get rendering(){return this.stage?.renderRequested??!1}get resizeAlign(){return super.resizeAlign}set resizeAlign(e){super.resizeAlign=e}get resolution(){return this.stateManager.resolution??0}get rotation(){return super.rotation}set rotation(e){super.rotation=e}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get spatialReference(){return super.spatialReference}set spatialReference(e){super.spatialReference=e}get tileInfo(){return this.featuresTilingScheme?.tileInfo}get updating(){const e=!(!this.magnifier.visible||null===this.magnifier.position||!this._magnifierView?.updatingHandles.updating),t=!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some(e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)||e);if(has("esri-2d-log-updating")){const i=this.allLayerViews.reduce((e,t)=>({...e,[`${t.layer.id}(${t.layer.type})`]:!t.destroyed&&!("layerViews"in t)&&t.updating}),{});console.log(`Updating MapView: ${t}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(i)}\n-> updatingMagnifier: ${e}\n`)}return t}get viewpoint(){return super.viewpoint}set viewpoint(e){super.viewpoint=e}get visibleArea(){const e=this.stateManager.visibleArea;return e?new c({rings:[e.map(e=>[e[0],e[1]])],spatialReference:this.spatialReference}):e}get zoom(){return this.stateManager.zoom??-1}set zoom(e){this.stateManager.zoom=e}get navigating(){return this.mapViewNavigation?.interacting??!1}async hitTest(e,t){return A(this,e,t)}async takeScreenshot(e){return E(this._getScreenshotView(e),e)}toScreen(e,t){return this.stateManager.toScreen(e,t)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise(e=>{this.ready?e(this):this._resolveWhenReady.push(e)})}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties.spatialReference||this.defaultsFromMap?.spatialReference||null}getDefaultTimeZone(){return H(this.map)?this.map.initialViewProperties.timeZone:null}getDefaultTimeExtent(){return H(this.map)?this.map.initialViewProperties.timeExtent:null}hasLayerViewModule(e){return R.hasLayerViewModule(e)}importLayerView(e){return R.importLayerView(e)}pixelSizeAt(){return this.ready?this.resolution:(a.getLogger(this).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}async popupHitTest(e){const t=this.toMap(e),i=await this.hitTest(e),r=this.allLayerViews.toArray().filter(i=>i.clips.every(i=>k(this,i,e,t))).reverse(),s=new globalThis.Map(r.map(e=>[e.layer.uid,e])),a=[];let n=0,o=0;for(;n<i.results.length||o<r.length;){const e=i.results.at(n);if(e&&"graphic"!==e.type){++n;continue}const l=s.get((e?.layer??e?.graphic.layer)?.uid);if((!e||l)&&o<r.length&&r.at(o)!==l){const e=r.at(o);"fetchPopupFeaturesAtLocation"in e&&a.push({mapPoint:t,layerView:e}),++o}else e&&(a.push({graphic:e.graphic,layerView:l}),++n)}return{hits:a,location:t}}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}async validate(){let e=N(this.type);if(has("safari")&&has("safari")<9&&(e=new s("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:has("safari")})),null!=e){a.getLogger(this).warn("#validate()",e.message);const t=document.createElement("div");t.setAttribute("style","display: flex; flex-direction: column; gap: 8px; padding: 20px; height: 100%; justify-content: center; color: black; background: white; font-family: sans-serif;");const i=document.createElement("div");i.innerHTML="Unable to display map. WebGL2 support is required.",i.setAttribute("style","font-size: 24px; font-weight: bold;");const r=document.createElement("div");r.innerHTML="Ensure that your browser and hardware meet the minimum requirements.",r.setAttribute("style","font-size: 18px;");const s=document.createElement("a");throw s.innerHTML="https://esriurl.com/systemRequirements",s.target="_blank",s.setAttribute("style","font-size: 18px;"),s.href="https://esriurl.com/systemRequirements",t.appendChild(i),t.appendChild(r),t.appendChild(s),this.surface.appendChild(t),e}}loadAsyncDependencies(){return te()}_getDefaultViewpoint(){const{constraints:e,initialExtent:i,map:r,padding:s,size:a}=this;if(!e)return null;const n=r&&"initialViewProperties"in r?r.initialViewProperties:void 0,o=this.stateManager.getUserStartupOptions(this.size),l=n?.viewpoint,p=l?.targetGeometry?.extent??i,h=p?.center,g=l?.rotation??0,d=l?.scale||p&&L(p,[a[0]-s.left-s.right,a[1]-s.top-s.bottom]),u=o.center??h,c=o.rotation??g,m=o.scale??d;return u&&m?new t({targetGeometry:u,scale:m,rotation:c}):null}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint();this.stateManager.startup(e,this.size,this.spatialReference,this.defaultsFromMap.extent?.center),this.graphics.owner=this;const t=new O(this.surface),i=new Z(this.surface,{canvas:this.renderCanvas,contextOptions:new F(this.deactivatedWebGLExtensions,this.debugWebGLExtensions),renderingOptions:this.renderingOptions,timeline:this.timeline},t);this.stage=i,this._magnifierView=new Y,this._magnifierView.magnifier=this.magnifier,this._gridView=new ee;const r=new Q({view:this});this._set("labelManager",r);const s=new j({view:this});this._set("animationManager",s);const a=new X({view:this,animationManager:s});this._set("mapViewNavigation",a),this._setupSpatialReferenceDependentProperties(),this.addHandles([this.rootLayerViews.on("change",()=>this._updateStageChildren()),i.on("webgl-error",e=>this.fatalError=e.error),o(()=>this.stationary,e=>i.stationary=e,l),o(()=>this.background,e=>{i.backgroundColor=e?.color,this._magnifierView.backgroundColor=e?.color},l),o(()=>this.magnifier,e=>this._magnifierView.magnifier=e,l),o(()=>this.grid,e=>this._gridView.grid=e,l),o(()=>this.renderingOptions,e=>i.renderingOptions=e,l),o(()=>this.highlights.items.map(e=>({name:e.name,options:{fillColor:e.color,haloColor:e.haloColor,fillOpacity:e.fillOpacity,haloOpacity:e.haloOpacity,haloWidth:e.haloWidth,haloBlur:e.haloBlur}})),()=>{i.highlightGradient=C(i.highlightGradient,this.highlights.items)},l),o(()=>this.state.id,()=>i.state=this.state,l)],"map-view"),this._updateStageChildren();const n=this._resolveWhenReady;this._resolveWhenReady=[],n.forEach(e=>e(this)),this.timeline.end("MapView Startup"),this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.removeHandles("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animation=null,this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._gridView.destroy(),this.stage.destroy(),this.stage=null,this._set("graphicsView",null),this._magnifierView=null,this._gridView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask.stop(),this.stationaryManager.clear(),this._set("ready",!1),this.stateManager.teardown()}_updateStageChildren(){this.stage.removeAllChildren(),this.rootLayerViews.forEach(e=>{this.stage.addChild(e.container)});const e=this.graphicsView;this.stage.addChild(e.container),this.stage.addChild(this._magnifierView),this.stage.addChild(this._gridView)}_setupSpatialReferenceDependentProperties(){const e=new S(y.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new J({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new K(e)});this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),e.destroy(),this._set("featuresTilingScheme",null)}_getScreenshotView(e){const{allLayerViews:t,padding:i,size:r,stage:s}=this;return{allLayerViews:t,backgroundColor:e?.ignoreBackground?null:this.background?.color,padding:i,size:r,stage:s}}_spatialReferenceChanged(e){if(this.ready){this.frameTask.stop();for(const e of this.allLayerViews)e.processDetach();this._destroySpatialReferenceDependentProperties(),this.stateManager.changeSpatialReference(e),this.stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const e of this.allLayerViews)e.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}}static{this.type="2d"}};e([h({constructOnly:!0})],ie.prototype,"deactivatedWebGLExtensions",void 0),e([h({constructOnly:!0})],ie.prototype,"debugWebGLExtensions",void 0),e([h({readOnly:!0})],ie.prototype,"featuresTilingScheme",void 0),e([h({readOnly:!0})],ie.prototype,"graphicsTileStore",null),e([h()],ie.prototype,"graphicsView",void 0),e([h()],ie.prototype,"constraintsInfo",null),e([h()],ie.prototype,"initialExtentRequired",null),e([h()],ie.prototype,"labelManager",void 0),e([h({type:G,nonNullable:!0})],ie.prototype,"navigation",void 0),e([h({constructOnly:!0})],ie.prototype,"renderCanvas",void 0),e([h()],ie.prototype,"renderingOptions",void 0),e([h({constructOnly:!0})],ie.prototype,"supersampleScreenshotsEnabled",void 0),e([h({readOnly:!0})],ie.prototype,"supportsGround",void 0),e([h()],ie.prototype,"defaultsFromMapSettings",null),e([h({readOnly:!0})],ie.prototype,"typeSpecificPreconditionsReady",null),e([h()],ie.prototype,"analysisViewManager",void 0),e([h({type:B})],ie.prototype,"background",null),e([h()],ie.prototype,"center",null),e([h({type:i})],ie.prototype,"floors",void 0),e([h()],ie.prototype,"grid",void 0),e([h({type:I})],ie.prototype,"highlightOptions",null),e([h()],ie.prototype,"map",void 0),e([h()],ie.prototype,"padding",null),e([h({readOnly:!0})],ie.prototype,"rendering",null),e([h({readOnly:!0})],ie.prototype,"resolution",null),e([h()],ie.prototype,"scale",null),e([h({constructOnly:!0})],ie.prototype,"spatialReferenceLocked",void 0),e([h({readOnly:!0})],ie.prototype,"tileInfo",null),e([h({type:z,readOnly:!0})],ie.prototype,"timeline",void 0),e([h({readOnly:!0})],ie.prototype,"type",void 0),e([h({readOnly:!0})],ie.prototype,"updating",null),e([h({readOnly:!0})],ie.prototype,"view2dType",void 0),e([h({readOnly:!0})],ie.prototype,"visibleArea",null),e([h()],ie.prototype,"zoom",null),e([h({readOnly:!0})],ie.prototype,"navigating",null),e([h(),g(e=>e instanceof W?e:u($,e))],ie.prototype,"ui",void 0),ie=e([d("esri.views.View2D")],ie);const re=ie;export{re 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../Graphic.js";import{UndoRedo as o}from"../../UndoRedo.js";import{createTask as r}from"../../core/asyncUtils.js";import{makeHandle as i}from"../../core/handleUtils.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as a,syncAndInitial as n,sync as l}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{load as d}from"../../geometry/coordinateFormatter.js";import h from"../../layers/GraphicsLayer.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{CreateOperationGeometry as m}from"./support/CreateOperationGeometry.js";import{createCircle as y,createEllipse as g,createSquare as v,createRectangle as f,createPolygon as O,createPolyline as _,createMultipoint as w}from"./support/createUtils.js";import{createViewAlignedCoordinateSystem as C}from"./support/surfaceCoordinateSystems.js";import{createTooltipInfos as G,initializeConstraints as x,updateTooltipInfo as V,getConstraintZ as U,unlockConstraintsOnVertexAddOrRemove as b,lockElevationOnVertexAdd as k,getActiveTooltipInfo as S}from"./support/tooltipUtils.js";import{InteractiveToolBase as T}from"../interactive/InteractiveToolBase.js";import j from"../interactive/sketch/SketchOptions.js";import{makeTooltip as L,pasteLocation as H,enterInputModeIfAvailable as R}from"../interactive/tooltip/tooltipCommonUtils.js";import{autorun as z}from"../../core/accessorSupport/trackingUtils.js";let A=class extends T{constructor(t){super(t),this._graphic=null,this._coordinateFormatterLoadTask=null,this._createOperationGeometry=null,this.defaultZ=0,this.directionOptions=null,this.elevationLockOnVertexAddDisabled=!1,this.geometryType=null,this.hasZ=!0,this.geometryToPlace=null,this.snappingManager=null,this.snapToScene=!1,this.sketchOptions=new j}initialize(){const{view:t}=this;this.internalGraphicsLayer=new h({listMode:"hide",internal:!0,title:"DrawGraphicTool layer"}),this.view.map.layers.add(this.internalGraphicsLayer);const e=this.drawOperation=this.makeDrawOperation();this.tooltipInfos=G(t.type,this.sketchOptions);const o=L(()=>({view:t,options:this.sketchOptions.tooltips}));this.tooltip=o,x(this._tooltipsContext),this._coordinateFormatterLoadTask=r(()=>d()),this.addHandles([e.on("vertex-add",t=>this.onVertexAdd(t)),e.on("vertex-remove",t=>this.onVertexRemove(t)),e.on("vertex-update",t=>this.onVertexUpdate(t)),e.on("cursor-update",t=>this.onCursorUpdate(t)),e.on("cursor-remove",()=>this._updateGraphic()),e.on("complete",t=>this.onComplete(t)),this._coordinateFormatterLoadTask,o.on("paste",t=>H(t,this.activeTooltipInfo)),a(()=>this.cursor,t=>{e.cursor=t},n),z(()=>{const{activeTooltipInfo:t,sketchOptions:e}=this;V(t,this._tooltipsContext),o.info=e.tooltips.effectiveEnabled?t:null}),z(()=>{e.constraintZ=U(this._tooltipsContext)},l)]),this.finishToolCreation()}destroy(){this.drawOperation=s(this.drawOperation),this.tooltip=s(this.tooltip),this._destroyAllVisualizations(),this.view.map.remove(this.internalGraphicsLayer),this.internalGraphicsLayer=s(this.internalGraphicsLayer),this._set("view",null)}get _drawSpatialReference(){return this.drawOperation.coordinateHelper.spatialReference}get _tooltipsContext(){const{defaultZ:t,directionOptions:e,drawOperation:o,forceUniformSize:r,geometryType:i,graphic:s,sketchOptions:a,tooltipInfos:n,view:l,automaticAreaMeasurementUtils:p,automaticLengthMeasurementUtils:c}=this;return{createOperationGeometry:this._createOperationGeometry,defaultZ:t,directionOptions:e,drawOperation:o,forceUniformSize:r,geometryType:i,graphic:s,sketchOptions:a,tooltipInfos:n,view:l,automaticAreaMeasurementUtils:p,automaticLengthMeasurementUtils:c}}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)}set mode(t){const e=this.drawOperation;e&&(e.drawingMode=t),this._set("mode",t)}get updating(){return this.drawOperation?.updating??!1}get undoRedo(){const{view:{type:t,map:e}}=this;return"2d"===t&&e&&"undoRedo"in e&&e.undoRedo instanceof o?e.undoRedo:null}set undoRedo(t){this._override("undoRedo",t)}completeCreateOperation(){this.drawOperation.complete()}onInputEvent(t){this.destroyed||R(t,this.tooltip)||this.drawOperation.onInputEvent(t)}redo(){this.drawOperation.redo()}reset(){}undo(){this.drawOperation.undo(),0===this.drawOperation.numCommittedVertices&&x(this._tooltipsContext)}_destroyAllVisualizations(){this.removeHandles(I.outline),this.removeHandles(I.regularVertices),this.removeHandles(I.activeVertex),this.removeHandles(I.activeEdge),this.removeHandles(E)}_createOrUpdateGraphic(t){if(null!=this._graphic)return this.updateGraphicGeometry(t),this._graphic;const o=new e({...this.graphicProperties,symbol:this.graphicSymbol});return this._graphic=o,this.updateGraphicGeometry(t),this.internalGraphicsLayer.add(o),this.addHandles(this.initializeGraphic(o)),this.notifyChange("graphic"),this.addHandles(i(()=>{this.internalGraphicsLayer.remove(o),this._graphic===o&&(this._graphic=null)}),E),o}updateGraphicGeometry(t){this._graphic.geometry=t}_getCreateOperationGeometry(t={operationComplete:!1}){if(null==this.drawOperation)return;const{coordinateHelper:e,view:o,visualizationCursorVertex:r,lastVertex:i,committedVertices:s,geometryIncludingUncommittedVertices:a,numCommittedVertices:n}=this.drawOperation;if(!(n>0||null!=r))return;const l=t.operationComplete?s:a,p=l.length,c=null!=r?e.pointToArray(r):null,d=this._drawSpatialReference,h="3d"===o.type&&"global"===o.viewingMode,G=new m;G.committedVertices=s,G.cursorVertex=c;const{geometryType:x}=this;switch(x){case"point":case"mesh":G.full=e.arrayToPoint(l[0]);break;case"multipoint":G.full=p>0?w(l,d):null;break;case"polyline":case"polygon":p>0&&(G.full="polygon"===x?O([l],d,h,!0):_([l],d,h),G.cursorEdge=null!=c&&i&&!u(r,i)?_([[c,e.pointToArray(i)]],d,h):null,G.outline=p>1?G.full:null);break;case"circle":case"rectangle":{if(G.committedVertices=G.cursorVertex=null,!p)break;const e=C(o,l[0]),r=l[0],i=e.makeMapPoint(r[0]+D*o.resolution,r[1]);"circle"===x?1===p&&t.operationComplete?G.circle=y([r,i],e,!0):2===p&&(this.forceUniformSize?G.circle=y(l,e,this.centered):G.rectangle=g(l,e,this.centered)):1===p&&t.operationComplete?G.rectangle=v([r,i],e,!0):2===p&&(G.rectangle=this.forceUniformSize?v(l,e,this.centered):f(l,e,this.centered)),G.full=null!=G.circle?G.circle.geometry:G.rectangle?.geometry,G.outline="polygon"===G.full?.type?G.full:null;break}default:return null}return G}initializeGraphic(t){return i()}onComplete(t){if(!this.drawOperation)return;this._updateGraphic();let e=null;if(this.drawOperation.isCompleted){const t=this._getCreateOperationGeometry({operationComplete:!0});null!=t&&(e=this._createOrUpdateGraphic(t.full))}this._createOperationGeometry=null,this.emit("complete",{graphic:e,...t})}onCursorUpdate(t){this._updateGraphic(),this.emit("cursor-update",t)}onDeactivate(){const{drawOperation:t}=this;t&&(t.isCompleted||t.cancel())}onOutlineChanged(t){return i()}onCursorEdgeChanged(t){return i()}onVertexAdd(t){b(this._tooltipsContext),this._updateGraphic(),this.elevationLockOnVertexAddDisabled||k(t.vertices.at(0)?.coordinates,this._tooltipsContext),this.emit("vertex-add",t)}onVertexRemove(t){b(this._tooltipsContext),this._updateGraphic(),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.cursorEdge?this.addHandles(this.onCursorEdgeChanged(t.cursorEdge),I.activeEdge):this.removeHandles(I.activeEdge),null!=t.outline?this.addHandles(this.onOutlineChanged(t.outline),I.outline):this.removeHandles(I.outline),null!=t.committedVertices?this.addHandles(this.onRegularVerticesChanged(t.committedVertices),I.regularVertices):this.removeHandles(I.regularVertices),null!=t.cursorVertex?this.addHandles(this.onActiveVertexChanged(t.cursorVertex),I.activeVertex):this.removeHandles(I.activeVertex),null!=t.full?this._createOrUpdateGraphic(t.full):this.removeHandles(E)):this._destroyAllVisualizations()}get activeTooltipInfo(){return this._coordinateFormatterLoadTask?.finished?S(this._tooltipsContext):null}};t([p()],A.prototype,"_coordinateFormatterLoadTask",void 0),t([p()],A.prototype,"_createOperationGeometry",void 0),t([p()],A.prototype,"_tooltipsContext",null),t([p({value:!0})],A.prototype,"centered",null),t([p()],A.prototype,"cursor",null),t([p({nonNullable:!0})],A.prototype,"defaultZ",void 0),t([p({constructOnly:!0})],A.prototype,"directionOptions",void 0),t([p()],A.prototype,"drawOperation",void 0),t([p()],A.prototype,"elevationLockOnVertexAddDisabled",void 0),t([p({value:!0})],A.prototype,"enabled",null),t([p({value:!0})],A.prototype,"forceUniformSize",null),t([p({constructOnly:!0})],A.prototype,"geometryType",void 0),t([p()],A.prototype,"graphic",null),t([p({constructOnly:!0})],A.prototype,"graphicProperties",void 0),t([p()],A.prototype,"graphicSymbol",null),t([p({constructOnly:!0})],A.prototype,"hasZ",void 0),t([p({constructOnly:!0})],A.prototype,"geometryToPlace",void 0),t([p()],A.prototype,"mode",null),t([p()],A.prototype,"snappingManager",void 0),t([p()],A.prototype,"snapToScene",void 0),t([p()],A.prototype,"tooltip",void 0),t([p()],A.prototype,"tooltipInfos",void 0),t([p({constructOnly:!0,type:j})],A.prototype,"sketchOptions",void 0),t([p()],A.prototype,"updating",null),t([p({constructOnly:!0,nonNullable:!0})],A.prototype,"view",void 0),t([p({constructOnly:!0})],A.prototype,"automaticAreaMeasurementUtils",void 0),t([p({constructOnly:!0})],A.prototype,"automaticLengthMeasurementUtils",void 0),t([p({constructOnly:!0})],A.prototype,"undoRedo",null),t([p()],A.prototype,"activeTooltipInfo",null),A=t([c("esri.views.draw.DrawGraphicTool")],A);const E=Symbol("create-operation-graphic"),I={outline:Symbol("outline-visual"),regularVertices:Symbol("regular-vertices-visual"),activeVertex:Symbol("active-vertex-visual"),activeEdge:Symbol("active-edge-visual")};function M(t){switch(t){case"point":case"polyline":case"polygon":case"multipoint":return t;case"circle":case"rectangle":return"segment";case"mesh":return"point"}}const D=48;export{A as DrawGraphicTool,M as geometryTypeToDrawOperationGeometryType};
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../Graphic.js";import{UndoRedo as o}from"../../UndoRedo.js";import{createTask as r}from"../../core/asyncUtils.js";import{makeHandle as i}from"../../core/handleUtils.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as a,syncAndInitial as n,sync as l}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{load as d}from"../../geometry/coordinateFormatter.js";import h from"../../layers/GraphicsLayer.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{CreateOperationGeometry as m}from"./support/CreateOperationGeometry.js";import{createCircle as y,createEllipse as g,createSquare as v,createRectangle as f,createPolygon as O,createPolyline as _,createMultipoint as w}from"./support/createUtils.js";import{createViewAlignedCoordinateSystem as C}from"./support/surfaceCoordinateSystems.js";import{createTooltipInfos as G,initializeConstraints as x,updateTooltipInfo as V,getConstraintZ as U,unlockConstraintsOnVertexAddOrRemove as b,lockElevationOnVertexAdd as k,getActiveTooltipInfo as S}from"./support/tooltipUtils.js";import{InteractiveToolBase as T}from"../interactive/InteractiveToolBase.js";import j from"../interactive/sketch/SketchOptions.js";import{makeTooltip as L,pasteLocation as H,enterInputModeIfAvailable as R}from"../interactive/tooltip/tooltipCommonUtils.js";import{autorun as z}from"../../core/accessorSupport/trackingUtils.js";let A=class extends T{constructor(t){super(t),this._graphic=null,this._coordinateFormatterLoadTask=null,this._createOperationGeometry=null,this.defaultZ=0,this.directionOptions=null,this.elevationLockOnVertexAddDisabled=!1,this.geometryType=null,this.hasZ=!0,this.geometryToPlace=null,this.snappingManager=null,this.snapToScene=!1,this.sketchOptions=new j}initialize(){const{view:t}=this;this.internalGraphicsLayer=new h({listMode:"hide",internal:!0,title:"DrawGraphicTool layer"}),this.view.map.layers.add(this.internalGraphicsLayer);const e=this.drawOperation=this.makeDrawOperation();this.tooltipInfos=G(t.type,this.sketchOptions);const o=L(()=>({view:t,options:this.sketchOptions.tooltips}));this.tooltip=o,x(this._tooltipsContext),this._coordinateFormatterLoadTask=r(()=>d()),this.addHandles([e.on("vertex-add",t=>this.onVertexAdd(t)),e.on("vertex-remove",t=>this.onVertexRemove(t)),e.on("vertex-update",t=>this.onVertexUpdate(t)),e.on("cursor-update",t=>this.onCursorUpdate(t)),e.on("cursor-remove",()=>this._updateGraphic()),e.on("complete",t=>this.onComplete(t)),this._coordinateFormatterLoadTask,o.on("paste",t=>H(t,this.activeTooltipInfo)),a(()=>this.cursor,t=>{e.cursor=t},n),z(()=>{const{activeTooltipInfo:t,sketchOptions:e}=this;V(t,this._tooltipsContext),o.info=e.tooltips.effectiveEnabled?t:null}),z(()=>{e.constraintZ=U(this._tooltipsContext)},l)]),this.finishToolCreation(),e.initializePointer()}destroy(){this.drawOperation=s(this.drawOperation),this.tooltip=s(this.tooltip),this._destroyAllVisualizations(),this.view.map.remove(this.internalGraphicsLayer),this.internalGraphicsLayer=s(this.internalGraphicsLayer),this._set("view",null)}get _drawSpatialReference(){return this.drawOperation.coordinateHelper.spatialReference}get _tooltipsContext(){const{defaultZ:t,directionOptions:e,drawOperation:o,forceUniformSize:r,geometryType:i,graphic:s,sketchOptions:a,tooltipInfos:n,view:l,automaticAreaMeasurementUtils:p,automaticLengthMeasurementUtils:c}=this;return{createOperationGeometry:this._createOperationGeometry,defaultZ:t,directionOptions:e,drawOperation:o,forceUniformSize:r,geometryType:i,graphic:s,sketchOptions:a,tooltipInfos:n,view:l,automaticAreaMeasurementUtils:p,automaticLengthMeasurementUtils:c}}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)}set mode(t){const e=this.drawOperation;e&&(e.drawingMode=t),this._set("mode",t)}get updating(){return this.drawOperation?.updating??!1}get undoRedo(){const{view:{type:t,map:e}}=this;return"2d"===t&&e&&"undoRedo"in e&&e.undoRedo instanceof o?e.undoRedo:null}set undoRedo(t){this._override("undoRedo",t)}completeCreateOperation(){this.drawOperation.complete()}onInputEvent(t){this.destroyed||R(t,this.tooltip)||this.drawOperation.onInputEvent(t)}redo(){this.drawOperation.redo()}reset(){}undo(){this.drawOperation.undo(),0===this.drawOperation.numCommittedVertices&&x(this._tooltipsContext)}_destroyAllVisualizations(){this.removeHandles(I.outline),this.removeHandles(I.regularVertices),this.removeHandles(I.activeVertex),this.removeHandles(I.activeEdge),this.removeHandles(E)}_createOrUpdateGraphic(t){if(null!=this._graphic)return this.updateGraphicGeometry(t),this._graphic;const o=new e({...this.graphicProperties,symbol:this.graphicSymbol});return this._graphic=o,this.updateGraphicGeometry(t),this.internalGraphicsLayer.add(o),this.addHandles(this.initializeGraphic(o)),this.notifyChange("graphic"),this.addHandles(i(()=>{this.internalGraphicsLayer.remove(o),this._graphic===o&&(this._graphic=null)}),E),o}updateGraphicGeometry(t){this._graphic.geometry=t}_getCreateOperationGeometry(t={operationComplete:!1}){if(null==this.drawOperation)return;const{coordinateHelper:e,view:o,visualizationCursorVertex:r,lastVertex:i,committedVertices:s,geometryIncludingUncommittedVertices:a,numCommittedVertices:n}=this.drawOperation;if(!(n>0||null!=r))return;const l=t.operationComplete?s:a,p=l.length,c=null!=r?e.pointToArray(r):null,d=this._drawSpatialReference,h="3d"===o.type&&"global"===o.viewingMode,G=new m;G.committedVertices=s,G.cursorVertex=c;const{geometryType:x}=this;switch(x){case"point":case"mesh":G.full=e.arrayToPoint(l[0]);break;case"multipoint":G.full=p>0?w(l,d):null;break;case"polyline":case"polygon":p>0&&(G.full="polygon"===x?O([l],d,h,!0):_([l],d,h),G.cursorEdge=null!=c&&i&&!u(r,i)?_([[c,e.pointToArray(i)]],d,h):null,G.outline=p>1?G.full:null);break;case"circle":case"rectangle":{if(G.committedVertices=G.cursorVertex=null,!p)break;const e=C(o,l[0]),r=l[0],i=e.makeMapPoint(r[0]+D*o.resolution,r[1]);"circle"===x?1===p&&t.operationComplete?G.circle=y([r,i],e,!0):2===p&&(this.forceUniformSize?G.circle=y(l,e,this.centered):G.rectangle=g(l,e,this.centered)):1===p&&t.operationComplete?G.rectangle=v([r,i],e,!0):2===p&&(G.rectangle=this.forceUniformSize?v(l,e,this.centered):f(l,e,this.centered)),G.full=null!=G.circle?G.circle.geometry:G.rectangle?.geometry,G.outline="polygon"===G.full?.type?G.full:null;break}default:return null}return G}initializeGraphic(t){return i()}onComplete(t){if(!this.drawOperation)return;this._updateGraphic();let e=null;if(this.drawOperation.isCompleted){const t=this._getCreateOperationGeometry({operationComplete:!0});null!=t&&(e=this._createOrUpdateGraphic(t.full))}this._createOperationGeometry=null,this.emit("complete",{graphic:e,...t})}onCursorUpdate(t){this._updateGraphic(),this.emit("cursor-update",t)}onDeactivate(){const{drawOperation:t}=this;t&&(t.isCompleted||t.cancel())}onOutlineChanged(t){return i()}onCursorEdgeChanged(t){return i()}onVertexAdd(t){b(this._tooltipsContext),this._updateGraphic(),this.elevationLockOnVertexAddDisabled||k(t.vertices.at(0)?.coordinates,this._tooltipsContext),this.emit("vertex-add",t)}onVertexRemove(t){b(this._tooltipsContext),this._updateGraphic(),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.cursorEdge?this.addHandles(this.onCursorEdgeChanged(t.cursorEdge),I.activeEdge):this.removeHandles(I.activeEdge),null!=t.outline?this.addHandles(this.onOutlineChanged(t.outline),I.outline):this.removeHandles(I.outline),null!=t.committedVertices?this.addHandles(this.onRegularVerticesChanged(t.committedVertices),I.regularVertices):this.removeHandles(I.regularVertices),null!=t.cursorVertex?this.addHandles(this.onActiveVertexChanged(t.cursorVertex),I.activeVertex):this.removeHandles(I.activeVertex),null!=t.full?this._createOrUpdateGraphic(t.full):this.removeHandles(E)):this._destroyAllVisualizations()}get activeTooltipInfo(){return this._coordinateFormatterLoadTask?.finished?S(this._tooltipsContext):null}};t([p()],A.prototype,"_coordinateFormatterLoadTask",void 0),t([p()],A.prototype,"_createOperationGeometry",void 0),t([p()],A.prototype,"_tooltipsContext",null),t([p({value:!0})],A.prototype,"centered",null),t([p()],A.prototype,"cursor",null),t([p({nonNullable:!0})],A.prototype,"defaultZ",void 0),t([p({constructOnly:!0})],A.prototype,"directionOptions",void 0),t([p()],A.prototype,"drawOperation",void 0),t([p()],A.prototype,"elevationLockOnVertexAddDisabled",void 0),t([p({value:!0})],A.prototype,"enabled",null),t([p({value:!0})],A.prototype,"forceUniformSize",null),t([p({constructOnly:!0})],A.prototype,"geometryType",void 0),t([p()],A.prototype,"graphic",null),t([p({constructOnly:!0})],A.prototype,"graphicProperties",void 0),t([p()],A.prototype,"graphicSymbol",null),t([p({constructOnly:!0})],A.prototype,"hasZ",void 0),t([p({constructOnly:!0})],A.prototype,"geometryToPlace",void 0),t([p()],A.prototype,"mode",null),t([p()],A.prototype,"snappingManager",void 0),t([p()],A.prototype,"snapToScene",void 0),t([p()],A.prototype,"tooltip",void 0),t([p()],A.prototype,"tooltipInfos",void 0),t([p({constructOnly:!0,type:j})],A.prototype,"sketchOptions",void 0),t([p()],A.prototype,"updating",null),t([p({constructOnly:!0,nonNullable:!0})],A.prototype,"view",void 0),t([p({constructOnly:!0})],A.prototype,"automaticAreaMeasurementUtils",void 0),t([p({constructOnly:!0})],A.prototype,"automaticLengthMeasurementUtils",void 0),t([p({constructOnly:!0})],A.prototype,"undoRedo",null),t([p()],A.prototype,"activeTooltipInfo",null),A=t([c("esri.views.draw.DrawGraphicTool")],A);const E=Symbol("create-operation-graphic"),I={outline:Symbol("outline-visual"),regularVertices:Symbol("regular-vertices-visual"),activeVertex:Symbol("active-vertex-visual"),activeEdge:Symbol("active-edge-visual")};function M(t){switch(t){case"point":case"polyline":case"polygon":case"multipoint":return t;case"circle":case"rectangle":return"segment";case"mesh":return"point"}}const D=48;export{A as DrawGraphicTool,M 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{clone as i}from"../../core/lang.js";import{equalsMaybe as n,destroyMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as o}from"../../core/promiseUtils.js";import a from"../../core/ReactiveSet.js";import{watch as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{createScreenPoint as l}from"../../core/screenUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as m,pointNear as y}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{defaultDrawingMode as v}from"./DrawingMode.js";import{LegacyDrawManipulator as f}from"./LegacyDrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as P,sceneSnappingAtLocation as b}from"../interactive/dragEventPipeline.js";import{EditGeometry as T,Part as S}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as C}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as V}from"../interactive/sketch/constraints.js";import{pointToConstraintSpace as w,constraintSpaceToPoint as O,getPointConstraint as M,getPolylineOrPolygonConstraint as D}from"../interactive/sketch/constraintUtils.js";import E from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as I}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as H}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as j}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as G}from"../interactive/snapping/snappingUtils.js";const k="crosshair",Z="progress",L=Symbol(),U=Symbol();let A=class extends e{constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new a,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this._stagedPointerId=null,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=s(M),this._getPolylineOrPolygonConstraint=s(D),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new E,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=_(!!t.hasZ))}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,r="viewingMode"in e.state?e.state.viewingMode:2,s="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new C(new T(s,this.coordinateHelper),r),this._snappingOperation=new j({view:e}),this.addHandles([p(()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint}),({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&V(e));if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))},{equals:(t,e)=>t.stagedPoint===e.stagedPoint&&n(t.constraint,e.constraint)}),p(()=>this.view.viewpoint,(t,e)=>{t&&e&&u(t,e)&&this._onKeyboardBasedChange()})]),this._activePart=new S(i,r),this._editGeometryOperations.data.parts.push(this._activePart);const a=this.segmentLabels;null!=a&&(a.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions,automaticLengthMeasurementUtils:this.automaticLengthMeasurementUtils},this.addHandles(p(()=>this.labelOptions.enabled,t=>{a.visible=t},c))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],t=>{const e=t.vertices.map(t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)})),i=e.map(t=>t.coordinates),n=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getFirstVertex()?.pos)??null;m(n,this.firstVertex)||(this.firstVertex=n);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getLastVertex()?.pos)??null;m(r,this.lastVertex)||(this.lastVertex=r);const s=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.segments.at(-1)?.leftVertex?.pos)??null;switch(m(s,this.secondToLastVertex)||(this.secondToLastVertex=s),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}}));const l=this._manipulator=new f({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==t&&"multipoint"!==t,this.addHandles([l.events.on("immediate-click",t=>this._onImmediateClick(t)),l.events.on("immediate-double-click",t=>this._onImmediateDoubleClick(t)),p(()=>this.drawingMode,()=>{this.removeHandles(L),this.addHandles(this._createManipulatorDragPipeline(l),L)},c),p(()=>({effectiveCursor:this.effectiveCursor}),({effectiveCursor:t})=>{l.cursor=t},c)]),G(this,()=>{const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);if(null!=this.snappingManager){const t=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e);this._updatingHandles.addPromise(o(t))}})}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _isDragging(){const{_stagedPointerId:t,_manipulator:e}=this;return null!=t&&this._pointerDownStates.has(t)||e.grabbing||!e.interactive}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activePart.vertices.map(t=>this.coordinateHelper.vectorToArray(t.pos))}get _constraint(){const{constraints:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":case"multipoint":return this._getPointConstraint(t);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t)}}set drawingMode(t){this._set("drawingMode",t??v)}get effectiveCursor(){return this.loading?Z:this._hideDefaultCursor?null:this.cursor||k}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activePart.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&y(t,i)||y(t,e)?null:t}get updating(){return this._updatingHandles.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,r="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!r,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t})),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=i(this.cursorVertex),n=i(t),r=n&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(n)??n),s=this._snapToClosingVertex(r),o=this._applyConstraints(s);y(e,o)||(this._set("cursorVertex",o),this.segmentLabels?.set("stagedVertex",null!=o?this.coordinateHelper.pointToVector(o):null),null==o||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activePart.vertices.length,coordinates:this.coordinateHelper.pointToArray(o)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||this._isDragging||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activePart;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return P(t,(t,e,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:s,cancelSnapping:o}=H({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next(t=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t)).next(o),e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||r&&!this.numCommittedVertices)&&this.commitStagedVertex()),t)).next(b(this.view,this.elevationInfo)).next(...s).next(t=>(r&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t)).next(t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t))})}_createManipulatorDragPipelineFreehand(t){return P(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t})})}_createManipulatorDragPipelineHybrid(t){return P(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),this.addHandles(this._editGeometryOperations.createUndoGroup(),U),this._processCursor(t.mapStart),this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),this.removeHandles(U),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t})})}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:r}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const s=this.elevationInfo?.mode;let o=this.defaultZ,a=t||"absolute-height"===s;if(null!=r&&(a=r),"on-the-ground"===s&&(a=!1),this._drawAtFixedElevation){o=(t?this.constraintZ:null)??e.getZ(this._activePart.vertices[0].pos),a=!1}return a?i:(n.defaultZ=o,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i&&"multipoint"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e&&"multipoint"!==this.geometryType||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=l(t.x,t.y);this._stagedScreenPoint=e,this._stagedPointerType=t.pointerType,this._stagedPointerId=t.pointerId,this._isDragging?this._snappingOperation.abort():(t.stopPropagation(),this._processCursorMovementRelativeToSurface(e,t.pointerType))}_onKeyboardBasedChange(){"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._isDragging?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),r=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,this._processCursor(null),void i.abort();this._hideDefaultCursor=!1;const s=this.snappingManager;if(null==s)return this._processCursor(n),void i.abort();const a=this._getSnappingContext(e);this._updatingHandles.addPromise(o(i.snap({point:n,scenePoint:r},s,a)))}_applyConstraints(t){const{_constraint:e,constraints:i}=this;if(!t||!i||!e)return t;const{context:n}=i,r=w(t,n),s=r?e.closestTo(r):void 0;if(!s)return t;const o=O(s,t,n),a="2d"===this.view.type||"absolute-height"!==n.elevationInfo.mode;return null!=o&&a&&null!=this.constraintZ&&this.hasZ&&(o.z=this.constraintZ),o}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&z(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null,drawConstraints:this.constraints})}};function z(t,e,i){const n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=i}t([d()],A.prototype,"_hideDefaultCursor",void 0),t([d()],A.prototype,"_stagedPointerId",void 0),t([d()],A.prototype,"_isDragging",null),t([d()],A.prototype,"_snappingOperation",void 0),t([d()],A.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],A.prototype,"graphic",void 0),t([d()],A.prototype,"constraintsEnabled",void 0),t([d()],A.prototype,"constraints",void 0),t([d()],A.prototype,"_constraint",null),t([d()],A.prototype,"constraintZ",void 0),t([d()],A.prototype,"defaultZ",void 0),t([d()],A.prototype,"isDraped",void 0),t([d({constructOnly:!0})],A.prototype,"automaticLengthMeasurementUtils",void 0),t([d({value:v})],A.prototype,"drawingMode",null),t([d({constructOnly:!0})],A.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],A.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:E})],A.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],A.prototype,"geometryType",void 0),t([d({constructOnly:!0})],A.prototype,"hasM",void 0),t([d({constructOnly:!0})],A.prototype,"hasZ",void 0),t([d()],A.prototype,"cursor",void 0),t([d()],A.prototype,"effectiveCursor",null),t([d()],A.prototype,"loading",void 0),t([d({constructOnly:!0})],A.prototype,"manipulators",void 0),t([d({constructOnly:!0})],A.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],A.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],A.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],A.prototype,"snappingVisualizer",void 0),t([d()],A.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],A.prototype,"cursorVertex",null),t([d({readOnly:!0})],A.prototype,"visualizationCursorVertex",null),t([d()],A.prototype,"committableVertex",null),t([d()],A.prototype,"firstVertex",void 0),t([d()],A.prototype,"lastVertex",void 0),t([d()],A.prototype,"secondToLastVertex",void 0),t([d()],A.prototype,"updating",null),t([d({constructOnly:!0})],A.prototype,"view",void 0),A=t([h("esri.views.draw.DrawOperation")],A);export{A as DrawOperation,k as defaultCursor,Z as defaultLoadingCursor};
|
|
5
|
+
import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{clone as i}from"../../core/lang.js";import{equalsMaybe as n,destroyMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as o}from"../../core/promiseUtils.js";import a from"../../core/ReactiveSet.js";import{watch as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{createScreenPoint as l}from"../../core/screenUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as m,pointNear as y}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{defaultDrawingMode as v}from"./DrawingMode.js";import{LegacyDrawManipulator as f}from"./LegacyDrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as P,sceneSnappingAtLocation as b}from"../interactive/dragEventPipeline.js";import{EditGeometry as T,Part as S}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as C}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as V}from"../interactive/sketch/constraints.js";import{pointToConstraintSpace as w,constraintSpaceToPoint as O,getPointConstraint as M,getPolylineOrPolygonConstraint as D}from"../interactive/sketch/constraintUtils.js";import E from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as I}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as H}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as j}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as G}from"../interactive/snapping/snappingUtils.js";const k="crosshair",Z="progress",L=Symbol(),U=Symbol();let A=class extends e{constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new a,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this._stagedPointerId=null,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=s(M),this._getPolylineOrPolygonConstraint=s(D),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new E,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=_(!!t.hasZ))}initializePointer(){const t=this.view.inputManager?.latestPointerInfo;null!=t&&this._updatePointer(t.location,t.id,t.type)}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,r="viewingMode"in e.state?e.state.viewingMode:2,s="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new C(new T(s,this.coordinateHelper),r),this._snappingOperation=new j({view:e}),this.addHandles([p(()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint}),({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&V(e));if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))},{equals:(t,e)=>t.stagedPoint===e.stagedPoint&&n(t.constraint,e.constraint)}),p(()=>this.view.viewpoint,(t,e)=>{t&&e&&u(t,e)&&this._onKeyboardBasedChange()})]),this._activePart=new S(i,r),this._editGeometryOperations.data.parts.push(this._activePart);const a=this.segmentLabels;null!=a&&(a.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions,automaticLengthMeasurementUtils:this.automaticLengthMeasurementUtils},this.addHandles(p(()=>this.labelOptions.enabled,t=>{a.visible=t},c))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],t=>{const e=t.vertices.map(t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)})),i=e.map(t=>t.coordinates),n=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getFirstVertex()?.pos)??null;m(n,this.firstVertex)||(this.firstVertex=n);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getLastVertex()?.pos)??null;m(r,this.lastVertex)||(this.lastVertex=r);const s=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.segments.at(-1)?.leftVertex?.pos)??null;switch(m(s,this.secondToLastVertex)||(this.secondToLastVertex=s),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}}));const l=this._manipulator=new f({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==t&&"multipoint"!==t,this.addHandles([l.events.on("immediate-click",t=>this._onImmediateClick(t)),l.events.on("immediate-double-click",t=>this._onImmediateDoubleClick(t)),p(()=>this.drawingMode,()=>{this.removeHandles(L),this.addHandles(this._createManipulatorDragPipeline(l),L)},c),p(()=>({effectiveCursor:this.effectiveCursor}),({effectiveCursor:t})=>{l.cursor=t},c)]),G(this,()=>{const t=this.view.inputManager.latestPointerInfo?.type??"mouse",e=this._getSnappingContext(t);if(null!=this.snappingManager){const t=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e);this._updatingHandles.addPromise(o(t))}})}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _isDragging(){const{_stagedPointerId:t,_manipulator:e}=this;return null!=t&&this._pointerDownStates.has(t)||e.grabbing||!e.interactive}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activePart.vertices.map(t=>this.coordinateHelper.vectorToArray(t.pos))}get _constraint(){const{constraints:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":case"multipoint":return this._getPointConstraint(t);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t)}}set drawingMode(t){this._set("drawingMode",t??v)}get effectiveCursor(){return this.loading?Z:this._hideDefaultCursor?null:this.cursor||k}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activePart.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&y(t,i)||y(t,e)?null:t}get updating(){return this._updatingHandles.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,r="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!r,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t})),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=i(this.cursorVertex),n=i(t),r=n&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(n)??n),s=this._snapToClosingVertex(r),o=this._applyConstraints(s);y(e,o)||(this._set("cursorVertex",o),this.segmentLabels?.set("stagedVertex",null!=o?this.coordinateHelper.pointToVector(o):null),null==o||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activePart.vertices.length,coordinates:this.coordinateHelper.pointToArray(o)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||this._isDragging||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activePart;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return P(t,(t,e,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:s,cancelSnapping:o}=H({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next(t=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t)).next(o),e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||r&&!this.numCommittedVertices)&&this.commitStagedVertex()),t)).next(b(this.view,this.elevationInfo)).next(...s).next(t=>(r&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t)).next(t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t))})}_createManipulatorDragPipelineFreehand(t){return P(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t})})}_createManipulatorDragPipelineHybrid(t){return P(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),this.addHandles(this._editGeometryOperations.createUndoGroup(),U),this._processCursor(t.mapStart),this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),this.removeHandles(U),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t})})}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:r}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const s=this.elevationInfo?.mode;let o=this.defaultZ,a=t||"absolute-height"===s;if(null!=r&&(a=r),"on-the-ground"===s&&(a=!1),this._drawAtFixedElevation){o=(t?this.constraintZ:null)??e.getZ(this._activePart.vertices[0].pos),a=!1}return a?i:(n.defaultZ=o,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i&&"multipoint"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e&&"multipoint"!==this.geometryType||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=l(t.x,t.y);this._updatePointer(e,t.pointerId,t.pointerType)&&t.stopPropagation()}_updatePointer(t,e,i){return this._stagedScreenPoint=t,this._stagedPointerType=i,this._stagedPointerId=e,this._isDragging?(this._snappingOperation.abort(),!1):(this._processCursorMovementRelativeToSurface(t,i),!0)}_onKeyboardBasedChange(){"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._isDragging?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),r=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,this._processCursor(null),void i.abort();this._hideDefaultCursor=!1;const s=this.snappingManager;if(null==s)return this._processCursor(n),void i.abort();const a=this._getSnappingContext(e);this._updatingHandles.addPromise(o(i.snap({point:n,scenePoint:r},s,a)))}_applyConstraints(t){const{_constraint:e,constraints:i}=this;if(!t||!i||!e)return t;const{context:n}=i,r=w(t,n),s=r?e.closestTo(r):void 0;if(!s)return t;const o=O(s,t,n),a="2d"===this.view.type||"absolute-height"!==n.elevationInfo.mode;return null!=o&&a&&null!=this.constraintZ&&this.hasZ&&(o.z=this.constraintZ),o}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&z(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null,drawConstraints:this.constraints})}};function z(t,e,i){const n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=i}t([d()],A.prototype,"_hideDefaultCursor",void 0),t([d()],A.prototype,"_stagedPointerId",void 0),t([d()],A.prototype,"_isDragging",null),t([d()],A.prototype,"_snappingOperation",void 0),t([d()],A.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],A.prototype,"graphic",void 0),t([d()],A.prototype,"constraintsEnabled",void 0),t([d()],A.prototype,"constraints",void 0),t([d()],A.prototype,"_constraint",null),t([d()],A.prototype,"constraintZ",void 0),t([d()],A.prototype,"defaultZ",void 0),t([d()],A.prototype,"isDraped",void 0),t([d({constructOnly:!0})],A.prototype,"automaticLengthMeasurementUtils",void 0),t([d({value:v})],A.prototype,"drawingMode",null),t([d({constructOnly:!0})],A.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],A.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:E})],A.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],A.prototype,"geometryType",void 0),t([d({constructOnly:!0})],A.prototype,"hasM",void 0),t([d({constructOnly:!0})],A.prototype,"hasZ",void 0),t([d()],A.prototype,"cursor",void 0),t([d()],A.prototype,"effectiveCursor",null),t([d()],A.prototype,"loading",void 0),t([d({constructOnly:!0})],A.prototype,"manipulators",void 0),t([d({constructOnly:!0})],A.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],A.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],A.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],A.prototype,"snappingVisualizer",void 0),t([d()],A.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],A.prototype,"cursorVertex",null),t([d({readOnly:!0})],A.prototype,"visualizationCursorVertex",null),t([d()],A.prototype,"committableVertex",null),t([d()],A.prototype,"firstVertex",void 0),t([d()],A.prototype,"lastVertex",void 0),t([d()],A.prototype,"secondToLastVertex",void 0),t([d()],A.prototype,"updating",null),t([d({constructOnly:!0})],A.prototype,"view",void 0),A=t([h("esri.views.draw.DrawOperation")],A);export{A as DrawOperation,k as defaultCursor,Z as defaultLoadingCursor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{EventEmitter as e}from"../../core/Evented.js";
|
|
5
|
+
import{__decorate as o}from"tslib";import r from"../../core/Accessor.js";import{EventEmitter as e}from"../../core/Evented.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";let i=class extends r{constructor(o){super(o),this.events=new e,this.interactive=!0,this.selectable=!1,this.cursor=null,this.grabbable=!0}intersectionDistance(o,r){return 0}attach(){}detach(){}onElevationChange(){}onViewChange(){}};o([t()],i.prototype,"interactive",void 0),o([t()],i.prototype,"selectable",void 0),o([t()],i.prototype,"cursor",void 0),o([t()],i.prototype,"grabbing",void 0),o([t()],i.prototype,"grabbable",void 0),o([t()],i.prototype,"consumesClicks",void 0),o([t()],i.prototype,"grabbableForEvent",void 0),o([t()],i.prototype,"dragging",void 0),o([t()],i.prototype,"hovering",void 0),o([t()],i.prototype,"selected",void 0),i=o([s("esri.views.draw.LegacyDrawManipulator")],i);export{i as LegacyDrawManipulator};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import"../../core/has.js";import i from"../../core/Logger.js";import r from"../../core/Queue.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{primaryKey as o,isSystemModifier as a}from"./keys.js";import{LatestPointer as l}from"./handlers/LatestPointer.js";import{MultiTouch as h}from"./handlers/MultiTouch.js";import{PropertiesPool as p}from"../support/PropertiesPool.js";
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import"../../core/has.js";import i from"../../core/Logger.js";import r from"../../core/Queue.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{primaryKey as o,isSystemModifier as a}from"./keys.js";import{LatestPointer as l}from"./handlers/LatestPointer.js";import{MultiTouch as h}from"./handlers/MultiTouch.js";import{PropertiesPool as p}from"../support/PropertiesPool.js";class d{constructor(){this.id=0,this.type="mouse",this.location=new g}}let c=class extends t{constructor(e){super(e),this._pointerCaptures=new Map,this._nameToGroup={},this._handlers=[],this._handlersPriority=[],this._currentPropagation=null,this._updateDependenciesAfterPropagation=!1,this._sourceEvents=new Set,this._keyModifiers=new Set,this._activeKeyModifiers=new Set,this._stoppedPropagationEventIds=new Set,this.primaryKey=o,this._propertiesPool=new p({latestPointerInfo:d},this),this._latestPointerInfo=void 0,this._paused=!1,this._testTimestamp=void 0}initialize(){this.eventSource.onEventReceived=this._onEventReceived.bind(this),this._installRecognizers()}destroy(){const e=Object.keys(this._nameToGroup);for(const t of e)this.uninstallHandlers(t);this.eventSource.destroy(),this._currentPropagation=null,this._propertiesPool.destroy()}get hasPendingInputs(){return this._handlers.some(e=>e.handler.hasPendingInputs)}get multiTouchActive(){return this._multiTouchHandler.multiTouchActive}get latestPointerInfo(){return this._latestPointerInfo}get updating(){return this.hasPendingInputs||this._paused}installHandlers(e,t,i=_.INTERNAL){if(this._nameToGroup[e])return;if(0===t.length)return;const r={name:e,handlers:t.map(e=>({handler:e,active:!0,removed:!1,priorityIndex:0,groupPriority:i,eventCallback:null,uninstallCallback:null}))};this._nameToGroup[e]=r;for(let n=r.handlers.length-1;n>=0;n--){const e=r.handlers[n];this._handlers.push(e),e.handler.onInstall({updateDependencies:()=>{this.updateDependencies()},emit:(t,i,r,n,s)=>{this._emitInputEvent(e.priorityIndex+1,t,i,r,s,n)},setPointerCapture:(t,i)=>{this._setPointerCapture(r,e,t,i)},setEventCallback:t=>{e.eventCallback=t},setUninstallCallback:t=>{e.uninstallCallback=t},refreshHasPendingInputs:()=>{this.notifyChange("hasPendingInputs")}})}this.updateDependencies()}uninstallHandlers(e){const t=this._nameToGroup[e];t?(t.handlers.forEach(e=>{e.removed=!0,e.uninstallCallback?.()}),delete this._nameToGroup[e],this._currentPropagation?this._currentPropagation.needsHandlerGarbageCollect=!0:this._garbageCollectRemovedHandlers()):i.getLogger(this).error("There is no InputHandler group registered under the name `"+e+"`")}hasHandlers(e){return void 0!==this._nameToGroup[e]}isModifierKeyDown(e){return this._activeKeyModifiers.has(e)}updateDependencies(){if(this._currentPropagation)return void(this._updateDependenciesAfterPropagation=!0);this._updateDependenciesAfterPropagation=!1;const e=new Set,t=new Set;this._handlersPriority=[];for(let i=this._handlers.length-1;i>=0;i--){const e=this._handlers[i];e.priorityIndex=i,this._handlersPriority.push(e)}this._handlersPriority=this._sortHandlersPriority(this._handlersPriority);for(let i=this._handlersPriority.length-1;i>=0;i--){const r=this._handlersPriority[i];r.priorityIndex=i;let n=r.handler.hasSideEffects;if(!n)for(const t of r.handler.outgoingEventTypes)if(e.has(t)){n=!0;break}if(n)for(const i of r.handler.incomingEventMatches){e.add(i.eventType);for(const e of i.keyModifiers)a(e)||t.add(e)}r.active=n}this._sourceEvents=e,this._keyModifiers=t,this._pointerCaptures.size>0&&this._sourceEvents.add("pointer-capture-lost"),this._keyModifiers.size>0&&(this._sourceEvents.add("key-down"),this._sourceEvents.add("key-up")),this.eventSource&&(this.eventSource.activeEvents=this._sourceEvents)}_setLatestPointer(e,t,i,r){const n=this._latestPointerInfo;if(null==n||n.id!==e||n.type!==t||n.location.x!==i||n.location.y!==r){const n=this._propertiesPool.get("latestPointerInfo");n.id=e,n.type=t,n.location.x=i,n.location.y=r,this._latestPointerInfo=n}}_onEventReceived(e,t){if("pointer-capture-lost"===e){const e=t;this._pointerCaptures.delete(e.native.pointerId)}this._updateKeyModifiers(e,t);const i=this._testTimestamp??t.native?.timestamp,r=t.native?.cancelable;this._emitInputEventFromSource(e,t,i,r)}_updateKeyModifiers(e,t){if(!t)return;let i=!1;const r=()=>{i||(this._activeKeyModifiers=new Set(this._activeKeyModifiers),i=!0)},n=(e,t)=>{t&&!this._activeKeyModifiers.has(e)?(r(),this._activeKeyModifiers.add(e)):!t&&this._activeKeyModifiers.has(e)&&(r(),this._activeKeyModifiers.delete(e))};if("key-down"===e||"key-up"===e){const i=t.key;this._keyModifiers.has(i)&&n(i,"key-down"===e)}const s=t.native;n("Alt",!!s?.altKey),n("Control",!!s?.ctrlKey),n("Ctrl",!!s?.ctrlKey),n("Shift",!!s?.shiftKey),n("Meta",!!s?.metaKey),n("Primary",this._activeKeyModifiers.has(this.primaryKey))}_installRecognizers(){this._latestPointerHandler=new l((e,t,i,r)=>this._setLatestPointer(e,t,i,r)),this._multiTouchHandler=new h,this.installHandlers("input-manager-logic",[this._latestPointerHandler,this._multiTouchHandler],_.ALWAYS),this.recognizers.length>0&&this.installHandlers("default",this.recognizers,_.INTERNAL)}_setPointerCapture(e,t,i,r){const n=e.name+"-"+t.priorityIndex,s=this._pointerCaptures.get(i.pointerId)||new Set;this._pointerCaptures.set(i.pointerId,s),r?(s.add(n),1===s.size&&this.eventSource&&this.eventSource.setPointerCapture(i,!0)):s.has(n)&&(s.delete(n),0===s.size&&(this._pointerCaptures.delete(i.pointerId),this.eventSource&&this.eventSource.setPointerCapture(i,!1)))}_garbageCollectRemovedHandlers(){this._handlers=this._handlers.filter(e=>!e.removed),this.updateDependencies()}_emitInputEventFromSource(e,t,i,r){this._emitInputEvent(0,e,t,i,r)}_emitInputEvent(e,t,i,r,n,s){const o=r??this._currentPropagation?.timestamp??performance.now(),a=n??!1,l={event:new u(t,i,o,s||this._activeKeyModifiers,a),priorityIndex:e};this._currentPropagation?this._currentPropagation.events.push(l):this._doNewPropagation(l)}_doNewPropagation(e){this._currentPropagation={events:new r,currentHandler:null,needsHandlerGarbageCollect:!1,timestamp:e.event.timestamp},this._currentPropagation.events.push(e),this._continuePropagation()}_continuePropagation(){this._paused=!1;const e=this._currentPropagation;if(e){for(;e.events.length>0;){const{event:t,priorityIndex:i}=e.events.pop(),r=t.data?.eventId;if(!(null!=r&&this._stoppedPropagationEventIds.has(r)))for(e.currentHandler=this._handlersPriority[i];e.currentHandler;){if(e.currentHandler.removed)e.needsHandlerGarbageCollect=!0;else{if(e.currentHandler.active&&!t.shouldStopPropagation()&&e.currentHandler.eventCallback?.(t),t.shouldStopPropagation()){null!=r&&this._stoppedPropagationEventIds.add(r);break}if(t.shouldPausePropagation(()=>this._continuePropagation()))return void this._pausePropagation({event:t,priorityIndex:e.currentHandler.priorityIndex+1})}e.currentHandler=this._handlersPriority[e.currentHandler.priorityIndex+1]}}e.needsHandlerGarbageCollect&&this._garbageCollectRemovedHandlers(),this.hasPendingInputs||this._stoppedPropagationEventIds.clear(),this._currentPropagation=null,this._updateDependenciesAfterPropagation&&this.updateDependencies()}}_pausePropagation(e){const t=new r;t.push(e);const i=this._currentPropagation;if(i){for(;i.events.length;)t.push(i.events.pop());i.events=t,i.currentHandler=null,this._paused=!0}}_compareHandlerPriority(e,t){if(e.handler.hasSideEffects!==t.handler.hasSideEffects)return e.handler.hasSideEffects?1:-1;if(e.groupPriority!==t.groupPriority)return e.groupPriority>t.groupPriority?-1:1;for(const i of e.handler.incomingEventMatches)for(const e of t.handler.incomingEventMatches){if(i.eventType!==e.eventType)continue;const t=i.keyModifiers.filter(t=>e.keyModifiers.includes(t));if(t.length===i.keyModifiers.length!==(t.length===e.keyModifiers.length))return i.keyModifiers.length>e.keyModifiers.length?-1:1}return e.priorityIndex>t.priorityIndex?-1:1}_sortHandlersPriority(e){const t=[];for(const i of e){let e=0;for(;e<t.length&&this._compareHandlerPriority(i,t[e])>=0;)e++;t.splice(e,0,i)}return t}get test(){}};e([n({readOnly:!0})],c.prototype,"hasPendingInputs",null),e([n({constructOnly:!0})],c.prototype,"eventSource",void 0),e([n({constructOnly:!0})],c.prototype,"recognizers",void 0),e([n()],c.prototype,"multiTouchActive",null),e([n()],c.prototype,"_latestPointerInfo",void 0),e([n()],c.prototype,"latestPointerInfo",null),e([n()],c.prototype,"_paused",void 0),e([n({readOnly:!0})],c.prototype,"updating",null),c=e([s("esri.views.input.InputManager")],c);class u{constructor(e,t,i,r,n){this.type=e,this.data=t,this.timestamp=i,this.modifiers=r,this.cancelable=n,this._propagationState=0,this._resumeCallback=null}stopPropagation(){this._propagationState|=1}shouldStopPropagation(){return!!(1&this._propagationState)}defer(e){this._propagationState|=2;const t=(e,t)=>{this._propagationState&=-3;const i=this._resumeCallback;if(this._resumeCallback=null,i&&i(),t)throw e;return e};return("function"==typeof e?e():e).then(e=>t(e,!1),e=>t(e,!0))}shouldPausePropagation(e){return!!(2&this._propagationState)&&(this._resumeCallback=e,!0)}preventDefault(){this.data.native.preventDefault()}}const _={ALWAYS:1,DEFAULT:0,TOOL:-1,WIDGET:-2,INTERNAL:-3};class f{}const g=f;export{c as InputManager,d as LatestPointerInfo,_ as ViewEventPriorities};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{InputHandler as t}from"../InputHandler.js";class
|
|
5
|
+
import{InputHandler as t}from"../InputHandler.js";class i extends t{constructor(t){super(!0),this._onChange=t,this._value="mouse",this._x=null,this._y=null,this._id=null,this.registerIncoming("pointer-move",t=>this._update(t.data))}_update(t){const i="touch"===t.native.pointerType?"touch":"mouse",{x:s,y:e,native:{pointerId:h}}=t;i===this._value&&this._x===s&&this._y===e&&this._id===h||(this._value=i,this._x=s,this._y=e,this._id=h,this._onChange(h,i,s,e))}}export{i as LatestPointer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import"../../core/has.js";import"../../core/Logger.js";import{createResolver as i}from"../../core/promiseUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{ManipulatorCollection as s}from"./ManipulatorCollection.js";let r=class extends e{constructor(t){super(t),this.manipulators=new s,this.automaticManipulatorSelection=!0,this.hasGrabbedManipulators=!1,this.hasHoveredManipulators=!1,this.firstGrabbedManipulator=null,this.created=!1,this.removeIncompleteOnCancel=!0,this._editableFlags=new Map([[1,!0],[0,!0]]),this._creationFinishedResolver=i()}get active(){return null!=this.view&&this.view.activeTool===this}set visible(t){this._get("visible")!==t&&(this._set("visible",t),this._syncVisible())}get editable(){return this.getEditableFlag(0)}set editable(t){this.setEditableFlag(0,t)}get updating(){return!1}get cursor(){return null}get hasFocusedManipulators(){return this.hasGrabbedManipulators||this.hasHoveredManipulators}destroy(){this.manipulators.destroy(),this._set("view",null)}onAdd(){this._syncVisible()}activate(){null!=this.view&&(this.view.focus(),this.onActivate())}deactivate(){this.onDeactivate()}cancel(){this.emit("cancel")}handleInputEvent(t){this.onInputEvent(t)}handleInputEventAfter(t){this.onInputEventAfter(t)}setEditableFlag(t,e){this._editableFlags.set(t,e),this.manipulators.isToolEditable=this.internallyEditable,this._updateManipulatorAttachment(),0===t&&this.notifyChange("editable"),this.onEditableChange(),this.onManipulatorSelectionChanged()}getEditableFlag(t){return this._editableFlags.get(t)??!1}endDrag(){const t=this.view.inputManager.
|
|
5
|
+
import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import"../../core/has.js";import"../../core/Logger.js";import{createResolver as i}from"../../core/promiseUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{ManipulatorCollection as s}from"./ManipulatorCollection.js";let r=class extends e{constructor(t){super(t),this.manipulators=new s,this.automaticManipulatorSelection=!0,this.hasGrabbedManipulators=!1,this.hasHoveredManipulators=!1,this.firstGrabbedManipulator=null,this.created=!1,this.removeIncompleteOnCancel=!0,this._editableFlags=new Map([[1,!0],[0,!0]]),this._creationFinishedResolver=i()}get active(){return null!=this.view&&this.view.activeTool===this}set visible(t){this._get("visible")!==t&&(this._set("visible",t),this._syncVisible())}get editable(){return this.getEditableFlag(0)}set editable(t){this.setEditableFlag(0,t)}get updating(){return!1}get cursor(){return null}get hasFocusedManipulators(){return this.hasGrabbedManipulators||this.hasHoveredManipulators}destroy(){this.manipulators.destroy(),this._set("view",null)}onAdd(){this._syncVisible()}activate(){null!=this.view&&(this.view.focus(),this.onActivate())}deactivate(){this.onDeactivate()}cancel(){this.emit("cancel")}handleInputEvent(t){this.onInputEvent(t)}handleInputEventAfter(t){this.onInputEventAfter(t)}setEditableFlag(t,e){this._editableFlags.set(t,e),this.manipulators.isToolEditable=this.internallyEditable,this._updateManipulatorAttachment(),0===t&&this.notifyChange("editable"),this.onEditableChange(),this.onManipulatorSelectionChanged()}getEditableFlag(t){return this._editableFlags.get(t)??!1}endDrag(){const t=this.view.inputManager.latestPointerInfo?.location;if(!t)return;let e=!1;this.manipulators.forEach(({manipulator:i})=>{i.dragging&&(e=!0,i.events.emit("drag",{action:"end",start:t,screenPoint:t}))}),e&&(this.view.toolViewManager.activeTool=null)}whenCreated(){return this._creationFinishedResolver.promise}onManipulatorSelectionChanged(){}onActivate(){}onDeactivate(){}onShow(){}onHide(){}onEditableChange(){}onInputEvent(t){}onInputEventAfter(t){}get internallyEditable(){return this.getEditableFlag(0)&&this.getEditableFlag(1)}finishToolCreation(){this.created||this._creationFinishedResolver.resolve(this),this._set("created",!0)}_syncVisible(){if(this.initialized)if(this.visible)this._show();else if(this._hide(),this.active)return void(this.view.activeTool=null)}_show(){this._updateManipulatorAttachment(),this.onShow()}_hide(){this._updateManipulatorAttachment(),this.onHide()}_updateManipulatorAttachment(){this.visible?this.manipulators.attach():this.manipulators.detach()}};t([a({constructOnly:!0})],r.prototype,"view",void 0),t([a({readOnly:!0})],r.prototype,"active",null),t([a({value:!0})],r.prototype,"visible",null),t([a({value:!0})],r.prototype,"editable",null),t([a({readOnly:!0})],r.prototype,"manipulators",void 0),t([a({readOnly:!0})],r.prototype,"updating",null),t([a()],r.prototype,"cursor",null),t([a({readOnly:!0})],r.prototype,"automaticManipulatorSelection",void 0),t([a()],r.prototype,"hasFocusedManipulators",null),t([a()],r.prototype,"hasGrabbedManipulators",void 0),t([a()],r.prototype,"hasHoveredManipulators",void 0),t([a()],r.prototype,"firstGrabbedManipulator",void 0),t([a({readOnly:!0})],r.prototype,"created",void 0),t([a({readOnly:!0})],r.prototype,"removeIncompleteOnCancel",void 0),r=t([o("esri.views.interactive.InteractiveToolBase")],r);export{r as InteractiveToolBase};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{find as
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{find as o}from"../../core/iteratorUtils.js";import{clamp as r}from"../../core/mathUtils.js";import a from"../../core/ReactiveMap.js";import{createScreenPoint as i}from"../../core/screenUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{areToolManipulatorsEditable as l}from"./interactiveToolUtils.js";import{createScreenPointFromEvent as p}from"../support/screenUtils.js";let u=class extends e{constructor(){super(...arguments),this._pointerLocations=new Map,this._hoveredManipulators=new a,this._grabbedManipulators=new a,this._draggedManipulators=new Map,this._stopDrag=!1,this._externallyDragging=!1,this._revertToNullActiveTool=!1}get cursor(){return this._cursorFromMap(this._grabbedManipulators,"grabbing")??this._cursorFromMap(this._hoveredManipulators,"pointer")}get hasFocusedManipulators(){return this._grabbedManipulators.size>0||this._draggedManipulators.size>0}handleInputEvent(t,e){const o=()=>t.stopPropagation();switch(t.type){case"pointer-move":d(t.pointerType)&&this._pointerLocations.set(t.pointerId,{x:t.x,y:t.y,pointerType:t.pointerType});break;case"drag":this._grabbedManipulators.size>0?this._stopDrag=!0:"start"===t.action?this._externallyDragging=!0:"end"===t.action&&(this._externallyDragging=!1),this._stopDrag&&(o(),"end"===t.action&&(this._stopDrag=!1));break;case"pointer-down":{if(!g(t))break;const r=p(t),a=c(r,t.pointerType,e.tools);if(null==a)break;const i=a.manipulator,n=a.tool;null==i||null==n||!i.interactive||i.grabbable&&i.grabbableForEvent(t)||!i.grabbing||i.dragging||this._releaseManipulatorBeforeDragging(i,t,e),null!=i&&null!=n&&i.interactive&&i.grabbable&&i.grabbableForEvent(t)&&!i.grabbing&&(this._grabbedManipulators.set(t.pointerId,{manipulator:i,tool:n,start:r,pointerType:t.pointerType}),1===this._grabbedManipulators.size&&null==e.activeTool&&(this._revertToNullActiveTool=!0,e.setActiveTool(a.tool)),i.grabbing=!0,i.events.emit("grab-changed",{action:"start",pointerType:t.pointerType,screenPoint:r}),o());break}case"pointer-up":this._draggedManipulators.has(t.pointerId)||this._handlePointerEnd(t,e);break;case"pointer-drag":{if(!g(t))break;const a=this._grabbedManipulators.get(t.pointerId),i=a?.manipulator,n=a?.tool;if(null==i||null==n)break;const s=p(t);s.x=r(s.x,0,e.view.width),s.y=r(s.y,0,e.view.height);const l=a.start,u=this._draggedManipulators.get(t.pointerId);switch(t.action){case"start":case"update":"update"!==t.action&&1!==this._grabbedManipulators.size||(i.dragging=!0,u?i.events.emit("drag",{action:"update",start:l,screenPoint:s}):i.events.emit("drag",{action:"start",start:l,screenPoint:s,pointerType:t.pointerType}),this._draggedManipulators.set(t.pointerId,{tool:n,manipulator:i,start:l}));break;case"end":i.dragging=!1,u&&i.events.emit("drag",{action:"end",start:l,screenPoint:s}),this._draggedManipulators.delete(t.pointerId),this._handlePointerEnd(t,e)}o();break}case"immediate-click":{const r=p(t),a=c(r,t.pointerType,e.tools);if(!h(t))for(const t of e.tools)if((null==a||a.tool!==t||t.automaticManipulatorSelection)&&t.manipulators){let e=!1;t.manipulators.forEach(({manipulator:t})=>{t.selected&&(t.selected=!1,e=!0)}),e&&t.onManipulatorSelectionChanged&&t.onManipulatorSelectionChanged()}if(null==a)break;const{manipulator:i,tool:n}=a;if(!i.interactive)break;i.selectable&&n.automaticManipulatorSelection&&(i.selected=!i.selected,n.onManipulatorSelectionChanged&&n.onManipulatorSelectionChanged());const s=t.native.shiftKey;i.events.emit("immediate-click",{screenPoint:r,button:t.button,pointerType:t.pointerType,shiftKey:s,stopPropagation:o}),b(i,o);break}case"click":{const r=p(t),a=c(r,t.pointerType,e.tools),i=a?.manipulator;if(null==i||!i.interactive)break;const n=t.native.shiftKey;i.events.emit(t.type,{screenPoint:r,button:t.button,pointerType:t.pointerType,shiftKey:n}),o();break}case"double-click":{const r=p(t),a=c(r,t.pointerType,e.tools),i=null!=a?a.manipulator:null;if(null==i||!i.interactive)break;const n=t.native.shiftKey;i.events.emit("double-click",{screenPoint:r,button:t.button,pointerType:t.pointerType,shiftKey:n,stopPropagation:o}),b(i,o);break}case"immediate-double-click":{const r=p(t),a=c(r,t.pointerType,e.tools),i=null!=a?a.manipulator:null;if(null==i||!i.interactive)break;const n=t.native.shiftKey;i.events.emit("immediate-double-click",{screenPoint:r,button:t.button,pointerType:t.pointerType,shiftKey:n,stopPropagation:o}),"mouse"===t.pointerType&&b(i,o);break}}this._onFocusChange(e.tools)}_releaseManipulatorBeforeDragging(t,e,o){t.grabbing=!1,t.events.emit("grab-changed",{action:"end",pointerType:e.pointerType,screenPoint:p(e)}),this._grabbedManipulators.forEach(({manipulator:e},o)=>{e===t&&this._grabbedManipulators.delete(o)}),this._afterManipulatorRelease(o.setActiveTool)}_handlePointerEnd(t,e){const o=this._grabbedManipulators.get(t.pointerId)?.manipulator;null!=o&&o.grabbing&&(o.grabbing=!1,o.events.emit("grab-changed",{action:"end",pointerType:t.pointerType,screenPoint:p(t)}),this._grabbedManipulators.delete(t.pointerId),this._afterManipulatorRelease(e.setActiveTool))}_onFocusChange(t){this._updateFocusedManipulatorTools(t)}_updateFocusedManipulatorTools(t){const e=new Set,r=new Set;this._grabbedManipulators.forEach(({tool:t})=>e.add(t)),this._hoveredManipulators.forEach(({tool:t})=>r.add(t));for(const a of t){a.hasGrabbedManipulators=e.has(a),a.hasHoveredManipulators=r.has(a);const t=this._grabbedManipulators.values(),i=o(t,({tool:t})=>t===a);a.firstGrabbedManipulator=null!=i?i.manipulator:null}}clearPointers(t,{tools:e,setActiveTool:o},r=!0,a){const i=(e,o)=>e===t&&(null==a||a===o);this._grabbedManipulators.forEach(({tool:t,manipulator:e,pointerType:o},r)=>{i(t,e)&&(this._grabbedManipulators.delete(r),e.grabbing=!1,e.events.emit("grab-changed",{action:"end",screenPoint:null,pointerType:o}))}),this._draggedManipulators.forEach(({tool:t,manipulator:e},o)=>{i(t,e)&&(this._draggedManipulators.delete(o),e.dragging=!1,e.events.emit("drag",{action:"cancel"}))}),r&&this._hoveredManipulators.forEach(({tool:t,manipulator:e},o)=>{i(t,e)&&(this._hoveredManipulators.delete(o),e.hovering=!1)}),this._afterManipulatorRelease(o),this._onFocusChange(e)}updateHoveredStateFromKnownPointers(t){this._pointerLocations.forEach((e,o)=>{this._updateHoveredStateForPointerAtScreenPosition(i(e.x,e.y),o,e.pointerType,t)})}handleHoverEvent(t,e){const o=t.type;"pointer-up"!==o&&"immediate-click"!==o&&"pointer-move"!==o||!d(t.pointerType)||("pointer-up"!==o&&this._externallyDragging?this._clearHoveredManipulatorStates(t.pointerId):this._updateHoveredStateForPointerAtScreenPosition(p(t),t.pointerId,t.pointerType,e))}_updateHoveredStateForPointerAtScreenPosition(t,e,o,r){let a=c(t,o,r);const i=this._hoveredManipulators.get(e)?.manipulator;null==a||a.manipulator.interactive||(a=null),null!=a&&i===a.manipulator||(null!=i&&(i.hovering=!1),null!=a?(a.manipulator.hovering=!0,this._hoveredManipulators.set(e,a)):this._hoveredManipulators.delete(e),this._onFocusChange(r))}_afterManipulatorRelease(t){0===this._grabbedManipulators.size&&this._revertToNullActiveTool&&(t(null),this._revertToNullActiveTool=!1)}_clearHoveredManipulatorStates(t){this._hoveredManipulators.forEach(({manipulator:e},o)=>{t===o&&(this._hoveredManipulators.delete(t),e.hovering=!1)})}_cursorFromMap(t,e){if(!t?.size)return null;for(const{manipulator:o}of t.values())if(o?.interactive){if(o.grabbing&&o.grabCursor)return o.grabCursor;if(o.cursor)return o.cursor}return e}};function c(t,e,o){for(const r of o){if(null==r.manipulators||!l(r))continue;const o=r.manipulators.intersect(t,e);if(null!=o)return{tool:r,manipulator:o}}return null}function d(t){return"mouse"===t}function g(t){return"mouse"!==t.pointerType||0===t.button}function h(t){return!!t.native.shiftKey}function b(t,e){t?.consumesClicks&&e()}t([n()],u.prototype,"cursor",null),u=t([s("esri.views.interactive.ToolViewManagerManipulatorState")],u);export{u as ToolViewManagerManipulatorState};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{on as o}from"../../core/events.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as i,when as s,syncAndInitial as r,initial as l,sync as a}from"../../core/reactiveUtils.js";import{cloneScreenPoint as c,createScreenPoint as p}from"../../core/screenUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../core/support/UpdatingHandles.js";import{setCalciteModeClass as f}from"../../support/modeUtils.js";import{base as m}from"./tooltip/css.js";import{tooltipContentFactory as g}from"./tooltip/content/tooltipContentFactory.js";import{isRTL as y}from"../../widgets/support/widgetUtils.js";const v={base:`${m}`,ltr:`${m}--ltr`,rtl:`${m}--rtl`,debug:`${m}--debug`},_=20,C=16,b="bottom-end";let P=class extends e{constructor(t){super(t),this.info=null,this.options=null,this.position=null,this.content=null,this._focused=!1,this.outerContainer=document.createElement("div"),this.debug=!1,this._updatingHandles=new h,this._lastPosition=null,this._rtl=!1,this._prevXY=[0,0]}initialize(){const{outerContainer:t}=this;this.addHandles([i(()=>this.view.overlay?.surface,e=>{t.remove(),e?.appendChild(t),this._rtl=y(e)},r),i(()=>this.info,(e,o)=>{if(null!=this.content&&null!=e&&null!=o&&e.type===o.type)this.content.info=e;else{n(this.content);const o=g(this,e);o?(this.content=o,o.container&&t.appendChild(o.container),this.exitInputMode()):this.content=null}},r),i(()=>({container:this.outerContainer,style:this._outerContainerStyle}),({container:t,style:e})=>{Object.assign(t.style,e)},l),i(()=>({outerContainer:this.outerContainer,placement:this.effectivePlacement,effectiveOffset:this._effectiveOffset,rtl:this._rtl,debug:this.debug}),({outerContainer:t,placement:e,effectiveOffset:o,rtl:n,debug:i})=>{const{classList:s}=t;s.add(v.base),s.toggle(v.rtl,n),s.toggle(v.ltr,!n),s.toggle(v.debug,i),this.outerContainer.style.setProperty("--offset",`${o}px`),f(t),x(t,e)},l),s(()=>"feedback"===this.mode,()=>{this.position=null,this._clearOverride("effectivePlacement")},a),o(this.outerContainer,"paste",t=>{this.emit("paste",t)}),o(this.outerContainer,["focusin","focusout"],()=>{this._focused=this.content?.container?.contains(document.activeElement)??!1})])}destroy(){this.info=null,this.content=n(this.content),this.outerContainer.remove()}get mode(){return this.content?.mode??"feedback"}get focused(){return this._focused}get visible(){return"none"!==this._outerContainerStyle.display}get contentContainer(){return this.content?.container}get effectivePlacement(){const t=this.options?.placement;return"auto"===t?"bottom-end":t??b}get updating(){return this._updatingHandles.updating}get _screenPoint(){const{inputManager:t}=this.view;return t?.multiTouchActive?null:t?.
|
|
5
|
+
import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{on as o}from"../../core/events.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as i,when as s,syncAndInitial as r,initial as l,sync as a}from"../../core/reactiveUtils.js";import{cloneScreenPoint as c,createScreenPoint as p}from"../../core/screenUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../core/support/UpdatingHandles.js";import{setCalciteModeClass as f}from"../../support/modeUtils.js";import{base as m}from"./tooltip/css.js";import{tooltipContentFactory as g}from"./tooltip/content/tooltipContentFactory.js";import{isRTL as y}from"../../widgets/support/widgetUtils.js";const v={base:`${m}`,ltr:`${m}--ltr`,rtl:`${m}--rtl`,debug:`${m}--debug`},_=20,C=16,b="bottom-end";let P=class extends e{constructor(t){super(t),this.info=null,this.options=null,this.position=null,this.content=null,this._focused=!1,this.outerContainer=document.createElement("div"),this.debug=!1,this._updatingHandles=new h,this._lastPosition=null,this._rtl=!1,this._prevXY=[0,0]}initialize(){const{outerContainer:t}=this;this.addHandles([i(()=>this.view.overlay?.surface,e=>{t.remove(),e?.appendChild(t),this._rtl=y(e)},r),i(()=>this.info,(e,o)=>{if(null!=this.content&&null!=e&&null!=o&&e.type===o.type)this.content.info=e;else{n(this.content);const o=g(this,e);o?(this.content=o,o.container&&t.appendChild(o.container),this.exitInputMode()):this.content=null}},r),i(()=>({container:this.outerContainer,style:this._outerContainerStyle}),({container:t,style:e})=>{Object.assign(t.style,e)},l),i(()=>({outerContainer:this.outerContainer,placement:this.effectivePlacement,effectiveOffset:this._effectiveOffset,rtl:this._rtl,debug:this.debug}),({outerContainer:t,placement:e,effectiveOffset:o,rtl:n,debug:i})=>{const{classList:s}=t;s.add(v.base),s.toggle(v.rtl,n),s.toggle(v.ltr,!n),s.toggle(v.debug,i),this.outerContainer.style.setProperty("--offset",`${o}px`),f(t),x(t,e)},l),s(()=>"feedback"===this.mode,()=>{this.position=null,this._clearOverride("effectivePlacement")},a),o(this.outerContainer,"paste",t=>{this.emit("paste",t)}),o(this.outerContainer,["focusin","focusout"],()=>{this._focused=this.content?.container?.contains(document.activeElement)??!1})])}destroy(){this.info=null,this.content=n(this.content),this.outerContainer.remove()}get mode(){return this.content?.mode??"feedback"}get focused(){return this._focused}get visible(){return"none"!==this._outerContainerStyle.display}get contentContainer(){return this.content?.container}get effectivePlacement(){const t=this.options?.placement;return"auto"===t?"bottom-end":t??b}get updating(){return this._updatingHandles.updating}get _screenPoint(){const{inputManager:t}=this.view;return t?.multiTouchActive?null:t?.latestPointerInfo?.location}get _effectiveOffset(){return this.options?.offset??_}get _outerContainerStyle(){const t=this.position??this._screenPoint;if(this._lastPosition=c(t),null!=t&&null!=this.content){return{display:"block",transform:`translate(${Math.round(t.x)}px, ${Math.round(t.y)}px)`}}return{display:"none",transform:"none"}}clear(){this.info=null}async enterInputMode(t){const e=this.position??this._lastPosition??this._screenPoint,o=this.position=c(e),{effectivePlacement:n}=this;this._override("effectivePlacement",n);const i=()=>{o&&(this.position=j(this.contentContainer,o,this._effectiveOffset,this.view),Object.assign(this.outerContainer.style,this._outerContainerStyle))};await this._updatingHandles.addPromise(this.content?.enterInputMode(t,i))}async exitInputMode(t){await this._updatingHandles.addPromise(this.content?.exitInputMode(t))}onDragStart(t,e){this._prevXY=[t,e]}onDrag(t,e){const o=t-this._prevXY[0],n=e-this._prevXY[1];this._prevXY=[t,e];const{position:i}=this;if(i){const{view:s}=this,r=t-s.position[0],l=e-s.position[1];if(r<0||r>s.width||l<0||l>s.height-C)return;this.position=p(i.x+o,i.y+n)}}onDragEnd(){this._prevXY=[0,0]}};function j(t,e,o,n){if(!t||!n.container)return e;const i=t.getBoundingClientRect(),{left:s,top:r}=n.container.getBoundingClientRect();let{x:l,y:a}=e;const c=i.left-s-o;c<0&&(l-=c);const u=i.right-s+o-n.width;u>0&&(l-=u);const d=i.top-r-o;d<0&&(a-=d);const h=i.bottom-r+o-n.height;return h>0&&(a-=h),p(l,a)}t([u({nonNullable:!0})],P.prototype,"view",void 0),t([u()],P.prototype,"info",void 0),t([u()],P.prototype,"options",void 0),t([u()],P.prototype,"position",void 0),t([u()],P.prototype,"content",void 0),t([u({readOnly:!0})],P.prototype,"mode",null),t([u()],P.prototype,"_focused",void 0),t([u({readOnly:!0})],P.prototype,"focused",null),t([u({readOnly:!0})],P.prototype,"outerContainer",void 0),t([u({readOnly:!0})],P.prototype,"contentContainer",null),t([u({readOnly:!0})],P.prototype,"effectivePlacement",null),t([u()],P.prototype,"debug",void 0),t([u()],P.prototype,"updating",null),t([u()],P.prototype,"_lastPosition",void 0),t([u()],P.prototype,"_screenPoint",null),t([u()],P.prototype,"_rtl",void 0),t([u()],P.prototype,"_effectiveOffset",null),t([u()],P.prototype,"_outerContainerStyle",null),P=t([d("esri.views.interactive.Tooltip")],P);const O=["top","bottom","leading","trailing"].flatMap(t=>[w(`${t}-start`),w(t),w(`${t}-end`)]);function w(t){return`${v.base}--${t}`}function x({classList:t},e){O.forEach(e=>t.remove(e)),t.add(w(e))}export{P as default};
|