UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 5 kB
import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Accessor.js";import{HandleOwner as i}from"../../../../../core/HandleOwner.js";import{rad2deg as o,deg2rad as r}from"../../../../../core/mathUtils.js";import{isSome as n,isNone as l,unwrapOr as s}from"../../../../../core/maybe.js";import{when as a,sync as c}from"../../../../../core/reactiveUtils.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";let y=class extends i{constructor(t){super(t),this.sizeAxis=null,this._interactionState=null}initialize(){this.addHandles(a((()=>n(this._interactionState)?this._interactionState.state:null),(t=>{this._updateSymbol(t)}),c))}get angle(){return n(this._interactionState)?this._interactionState.angle:n(this._orientationReferenceSymbolLayer)?g(this._orientationReferenceSymbolLayer.heading??0):0}get scale(){return n(this._interactionState)?this._interactionState.scale:1}get relativeAngle(){return this.angle-this.initialAngle}get initialAngle(){return n(this._interactionState)?this._interactionState.initialAngle:0}get size(){const t=this._sizeReferenceSymbolLayer;if(l(t))return null;const e=this.findLayerView(),i=this._graphicSymbol;if(l(e)||l(i)||"point-3d"!==i.type)return null;const o=e.getSymbolLayerSize(i,t);if("size"in o&&n(o.size))return o.size;const r=this.sizeAxis;return"width"in o&&n(o.width)&&(l(r)||"width"===r||"all"===r||"width-and-depth"===r)?o.width:"depth"in o&&n(t.depth)&&(l(r)||"depth"===r||"all"===r||"width-and-depth"===r)?o.depth:"height"in o&&n(t.height)&&(l(r)||"height"===r||"all"===r)?o.height:null}get _sizeReferenceSymbolLayer(){const t=this._graphicSymbol;return l(t)||0===t.symbolLayers.length?null:t.symbolLayers.find((t=>"object"===t.type))}get _orientationReferenceSymbolLayer(){const t=this._graphicSymbol;return l(t)||0===t.symbolLayers.length?null:t.symbolLayers.find((t=>"object"===t.type&&n(t.heading)))}get _graphicSymbol(){return n(this.graphic)&&n(this.graphic.symbol)&&"point-3d"===this.graphic.symbol.type?this.graphic.symbol:null}set _graphicSymbol(t){this.graphic.symbol=t}startInteraction(){const t=this._graphicSymbol,e=this.findLayerView();if(n(this._interactionState)||l(t)||l(e))return m;const i=t.symbolLayers.map((i=>"object"===i.type?e.getSymbolLayerSize(t,i):null)).toArray(),o=t.clone(),r=this.angle,s=new d({originalSymbol:o,angle:r,initialSizes:i});this._interactionState=s;const a=()=>{this._interactionState=null};return{state:s,done:a,cancel:()=>{this._graphicSymbol=o,a()}}}createUndoRecord(){let t=this.graphic.symbol,e=null;return{undo:i=>{e=i.symbol,i.symbol=t},redo:i=>{t=i.symbol,i.symbol=e}}}_updateSymbol({scale:t,angle:e,originalSymbol:i,initialSizes:r}){const a=this._graphicSymbol;if(l(a)||"point-3d"!==a.type)return;const c=a.clone(),h=-o(e-this.initialAngle);let p=!1;this._forEachObjectSymbolLayerPair(i,c,((e,i,o)=>{const l=s(e.heading,0)+h;i.heading!==l&&(i.heading=l,p=!0);const a=r[o];if(n(a)&&"width"in a){a.width=this.sizeFilter(a.width),a.height=this.sizeFilter(a.height),a.depth=this.sizeFilter(a.depth);const e=a.width*t;i.width!==e&&(i.width=e,p=!0);const o=a.depth*t;i.depth!==o&&(i.depth=o,p=!0);const r=a.height*t;i.height!==r&&(i.height=r,p=!0)}})),p&&(this._graphicSymbol=c)}_forEachObjectSymbolLayerPair(t,e,i){t.symbolLayers.forEach(((t,o)=>{const r=e.symbolLayers.getItemAt(o);"object"===t.type&&"object"===r.type&&i(t,r,o)}))}};function g(t){return-r(t)}t([h()],y.prototype,"angle",null),t([h()],y.prototype,"scale",null),t([h()],y.prototype,"relativeAngle",null),t([h()],y.prototype,"initialAngle",null),t([h()],y.prototype,"size",null),t([h()],y.prototype,"sizeAxis",void 0),t([h({constructOnly:!0})],y.prototype,"graphic",void 0),t([h()],y.prototype,"_interactionState",void 0),t([h({constructOnly:!0})],y.prototype,"findLayerView",void 0),t([h({constructOnly:!0})],y.prototype,"sizeFilter",void 0),t([h()],y.prototype,"_sizeReferenceSymbolLayer",null),t([h()],y.prototype,"_orientationReferenceSymbolLayer",null),t([h()],y.prototype,"_graphicSymbol",null),y=t([p("esri.views.3d.interactive.editingTools.transformGraphic.ScaleRotateObjectSymbol3DAdapter")],y);const m={state:{angle:0,scale:0},done:()=>{},cancel:()=>{}};let d=class extends e{get state(){const{originalSymbol:t,angle:e,initialAngle:i,scale:o,initialSizes:r}=this;return{originalSymbol:t,angle:e,initialAngle:i,scale:o,initialSizes:r}}constructor(t){super(t),this.angle=0,this.initialAngle=0,this.scale=1,this.initialAngle=t.angle}};t([h()],d.prototype,"originalSymbol",void 0),t([h()],d.prototype,"angle",void 0),t([h()],d.prototype,"initialAngle",void 0),t([h()],d.prototype,"initialSizes",void 0),t([h()],d.prototype,"scale",void 0),t([h()],d.prototype,"state",null),d=t([p("InteractionState")],d);export{y as ScaleRotateObjectSymbol3DAdapter,g as headingToAngle};