@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 1.66 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{equals as t}from"../../../../core/arrayUtils.js";import{notDeepEqual as e}from"../../../../core/object.js";class i{constructor(t,e){this._editGeometry=t,this._newPositions=[],this._newSegments=[];for(const{pos:i,leftSegment:n}of e.allVertices)this._newPositions.push(i),this._newSegments.push(s(n))}apply(){const t=null==this._originalPositions?"apply":"redo";if(!this._originalPositions){const t=this._editGeometry.coordinateHelper;this._originalPositions=[],this._originalSegments=[];for(const{pos:e,leftSegment:i}of this._editGeometry.iterateVertices())this._originalPositions.push(t.clone(e)),this._originalSegments.push(s(i))}this._apply(t,this._newPositions,this._newSegments)}undo(){this._originalPositions&&this._originalSegments&&this._apply("undo",this._originalPositions,this._originalSegments)}accumulate(t){return t instanceof i&&(this._newPositions=t._newPositions,this._newSegments=t._newSegments,this._apply("apply",this._newPositions,this._newSegments),!0)}_apply(e,i,o){const r=this._editGeometry.coordinateHelper,l=this._editGeometry.allVertices,h=[];for(let a=0;a<l.length;a++){const e=l[a],p=i[a],_=o[a];t(e.pos,p)&&n(s(e.leftSegment),_)||(h.push(l[a]),r.copy(p,e.pos),e.leftSegment&&"curveDefinition"in e.leftSegment&&_&&(e.leftSegment.curveDefinition={..._}))}this._editGeometry.parts.forEach(t=>t.unnormalizeVertexPositions()),h.length&&this._editGeometry.notifyChanges({operation:e,updatedVertices:h})}}function s(t){if(t&&"line"!==t.type)return{...t.curveDefinition}}function n(t,i){return null==t&&null==i||!!t&&!!i&&!e(t,i)}export{i as SetAllVertexPositions};