@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 4.29 kB
JavaScript
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Handles.js";import{someMap as i}from"../../../../core/MapUtils.js";import{isSome as s}from"../../../../core/maybe.js";import{watch as r,initial as a}from"../../../../core/reactiveUtils.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/Error.js";import"../../../../core/has.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{t as n}from"../../../../chunks/boundedPlane.js";import{Deconflictor as c,DeconflictorViewState as h,DeconflictorGraphic as l}from"./Deconflictor.js";import{VisibilityGroup as p,VisibilityFlag as d}from"./enums.js";import{LabelDeconflictor as u}from"./LabelDeconflictor.js";import{TaskPriority as m}from"../../../support/Scheduler.js";let _=class extends c{constructor(){super(...arguments),this._handles=new t,this._contexts=new Map,this._viewState=new h,this.visibilityGroup=p.GRAPHIC,this._iconMarginFactor=-.1}get labels(){return this._labels}get viewState(){return this._viewState}initialize(){this._handles.add([r((()=>this.view?.state?.camera),(()=>{this._updateViewState(),this.setDirty()})),r((()=>this.view?.map?.ground?.opacity),((e,t)=>{1!==e&&1!==t||this.setDirty()})),r((()=>this.view?.slicePlane),(()=>{this._updateSlicePlane(),this._slicePlaneChanged()}),a)]),this._frameTask=this.view.resourceController.scheduler.registerTask(m.GRAPHICS_DECONFLICTOR,this),this._labels=new u({view:this.view,parent:this})}destroy(){this._labels.destroy(),this._labels=null,this._handles.destroy(),this._handles=null,this._frameTask&&(this._frameTask.remove(),this._frameTask=null)}get iconMarginFactor(){return this._iconMarginFactor}set iconMarginFactor(e){this._iconMarginFactor=e,this.setDirty()}setDirty(){this._contexts.size>0&&(super.setDirty(),this._labels.setDirty())}runTask(e){super.runTask(e),this.running||this._labels.setDirty()}setInitialIconVisibilityFlag(e,t){const i=!(this._graphicSupportsDeconfliction(t)&&g(e));t.setVisibilityFlag(d.DECONFLICTION,i,p.GRAPHIC)}_updateViewState(){this.view&&this.view.state&&(this._viewState.camera.copyFrom(this.view.state.camera),this._updateSlicePlane())}_updateSlicePlane(){const e=this.view?this.view.slicePlane:null;s(e)&&n(e,this._viewState.camera.viewMatrix,this._viewState.slicePlane),this._viewState.slicePlaneEnabled=s(e)}_slicePlaneChanged(){i(this._contexts,((e,t)=>t.symbolCreationContext.slicePlaneEnabled))&&this.setDirty()}addGraphicsOwner(e){const t=this._getGraphicsContext(e);return{addGraphic:i=>this._addGraphic(e,t,i),removeGraphic:e=>this._removeGraphic(t,e),labelingInfoChange:()=>this._labels.enabledChanged(e,t),featureReductionChange:()=>this.enabledChanged(e,t),slicePlaneEnabledChange:()=>this._slicePlaneEnabledChanged(e,t),clear:()=>t.forEach((e=>this._removeGraphic(t,e.graphics3DGraphic)))}}removeGraphicsOwner(e){const t=this._contexts.get(e);t&&(t.forEach((e=>this._removeGraphic(t,e.graphics3DGraphic))),this._contexts.delete(e),this.setDirty())}_addGraphic(e,t,i){const s=i.graphic.uid,r=new l(i,e.symbolCreationContext.slicePlaneEnabled);t.set(s,r),g(e)&&this.addToActiveGraphics(r),e.labelsEnabled&&this._labels.addToActiveGraphics(r)}_removeGraphic(e,t){const i=t.graphic.uid,s=e.get(i);s&&(this.removeFromActiveGraphics(s),this._labels.removeFromActiveGraphics(s),e.delete(i),this.setDirty())}enabledChanged(e,t){const i=g(e);i||f(e),this.modifyGraphics(t,i)}_slicePlaneEnabledChanged(e,t){const i=e.symbolCreationContext.slicePlaneEnabled;t.forEach((e=>e.slicePlaneEnabled=i)),this.setDirty()}getGraphicsLayers(e){return e.layers}_graphicSupportsDeconfliction(e){if(e.isDraped)return!1;const t=e.layers;if(!t||!t.length)return!1;for(const i of t)if(this.layerSupportsDeconfliction(i))return!0;return!1}_getGraphicsContext(e){const t=this._contexts.get(e);if(t)return t;const i=new Map;return this._contexts.set(e,i),this.setDirty(),i}};function g(e){const t=e.layer;return!(!t||!t.featureReduction||"selection"!==t.featureReduction.type)}function f(e){const t=e.graphics3DGraphics;t&&t.forEach((e=>e.clearVisibilityFlag(d.DECONFLICTION)))}_=e([o("esri.views.3d.layers.graphics.GraphicsDeconflictor")],_);export{_ as GraphicsDeconflictor};