@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 4.19 kB
JavaScript
import"../../../geometry.js";import e from"../../../Graphic.js";import"../../../symbols.js";import{makeHandle as r}from"../../../core/handleUtils.js";import{px2pt as i}from"../../../core/screenUtils.js";import{a as t,g as n}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{c as a}from"../../../chunks/vec3f64.js";import{LineCapStyle as l,LineJoinStyle as s}from"../../../symbols/cim/enums.js";import{colors as m}from"../../draw/support/settings.js";import{defaults as p}from"../../interactive/snapping/Settings.js";import{SnappingVisualizer as y}from"../../interactive/snapping/SnappingVisualizer.js";import c from"../../../symbols/SimpleMarkerSymbol.js";import b from"../../../symbols/SimpleLineSymbol.js";import S from"../../../symbols/CIMSymbol.js";import h from"../../../geometry/Point.js";import g from"../../../geometry/Polyline.js";class u extends y{constructor(e){super(),this._graphicsLayer=e}visualizeIntersectionPoint(e,r){return this._visualizeSnappingIndicator(new h({x:e.intersectionPoint[0],y:e.intersectionPoint[1],spatialReference:r.spatialReference}),f)}visualizePoint(e,r){return this._visualizeSnappingIndicator(new h({x:e.point[0],y:e.point[1],spatialReference:r.spatialReference}),I)}visualizeLine(e,r){return this._visualizeSnappingIndicator(new g({paths:[[e.lineStart,e.lineEnd]],spatialReference:r.spatialReference}),P)}visualizeParallelSign(e,r){return this._visualizeSnappingIndicator(new g({paths:[[e.lineStart,e.lineEnd]],spatialReference:r.spatialReference}),x)}visualizeRightAngleQuad(e,r){return this._visualizeSnappingIndicator(new g({paths:[[e.previousVertex,e.centerVertex,e.nextVertex]],spatialReference:r.spatialReference}),z(e))}_visualizeSnappingIndicator(i,t){const n=new e({geometry:i,symbol:t});return this._graphicsLayer.add(n),r((()=>{this._graphicsLayer.remove(n)}))}}const M=m.main.toArray(),d=[...m.main.toRgb(),100],f=new c({outline:new b({width:1.5,color:M}),size:15,color:[0,0,0,0]}),I=new c({outline:{width:.5,color:[0,0,0,1]},size:10,color:M}),P=new S({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,capStyle:l.Butt,joinStyle:s.Round,miterLimit:10,width:i(p.lineHintWidthTarget),color:M}]}}}),x=new S({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,anchorPoint:{x:0,y:-1,z:0},anchorPointUnits:"Relative",size:5,markerPlacement:{type:"CIMMarkerPlacementOnLine",placePerPart:!0,angleToLine:!0,relativeTo:"LineMiddle"},frame:{xmin:-5,ymin:-1.5,xmax:5,ymax:1.5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{rings:[[[7,0],[-7,0],[-7,1.5],[7,1.5]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:M}]}}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMVectorMarker",enable:!0,anchorPoint:{x:0,y:1,z:0},anchorPointUnits:"Relative",size:5,markerPlacement:{type:"CIMMarkerPlacementOnLine",placePerPart:!0,angleToLine:!0,relativeTo:"LineMiddle"},frame:{xmin:-5,ymin:-1.5,xmax:5,ymax:1.5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{rings:[[[7,0],[-7,0],[-7,-1.5],[7,-1.5]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:M}]}}],scaleSymbolsProportionally:!0,respectFrame:!0}]}}}),v=e=>new S({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,anchorPoint:{x:.5,y:.5,z:0},anchorPointUnits:"Relative",size:i(p.rightAngleHintSize),rotation:e,markerPlacement:{type:"CIMMarkerPlacementOnVertices",placePerPart:!0,angleToLine:!0,placeOnEndPoints:!1},frame:{xmin:-5,ymin:-5,xmax:5,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{paths:[[[5,-5],[-5,-5],[-5,5],[5,5],[5,-5]]]},symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",miterLimit:10,width:i(p.rightAngleHintOutlineSize),color:M},{type:"CIMSolidFill",enable:!0,color:d}]}}],scaleSymbolsProportionally:!0,respectFrame:!0}]}}}),C=v(45),L=v(225),z=(()=>{const e=o(),r=o(),i=a();return o=>(t(e,o.centerVertex,o.previousVertex),t(r,o.nextVertex,o.previousVertex),n(i,e,r),i[2]<0?C:L)})();export{u as SnappingVisualizer2D};