xzw hace 1 día
padre
commit
2778bbc60f
Se han modificado 1 ficheros con 41 adiciones y 39 borrados
  1. 41 39
      src/sdk/cover/index.js

+ 41 - 39
src/sdk/cover/index.js

@@ -470,7 +470,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                         modelId: measure.points_datasets[i] == void 0 ? Id_noIntersect : measure.points_datasets[i], 
                         name: measure.markerLabels[i].originText
                     }}))
-                    updatePathHideLine(measure)
+                    updatePathFakeLines(measure)
                 }else{
                     bus.emit('update', [
                         measure.dataset_points.map(p => p.clone()),
@@ -1935,15 +1935,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
         
             let path
             let info = {type : 'Path', minMarkers : 2, title:props.name, lineHeight : props.line.altitudeAboveGround }
-           
-            if(props.points.length == 0){
-                path = viewer.measuringTool.startInsertion( info, () => { 
-                    bus.emit("drawed" ); //完成   
-                })
-                path.pointHideList = []
-                path.fakeLines = []
-                viewer.dispatchEvent({ type: 'cancel_insertions', dontRemove: true, measure:path }) //要等进入编辑才能继续编辑
-            }else{ 
+            let createFromData = ()=>{
                 let originPointCount = props.points.length
                  
                 
@@ -1969,8 +1961,17 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                 if(props.points.length < originPointCount ) {
                     path.dispatchEvent('createDone')
                     //console.log('path点因模型被删减少', info.title, originPointCount,'->',props.points.length)
-                }
-                
+                } 
+            }
+            if(props.points.length == 0){
+                path = viewer.measuringTool.startInsertion( info, () => { 
+                    bus.emit("drawed" ); //完成   
+                })
+                path.pointHideList = []
+                path.fakeLines = []
+                viewer.dispatchEvent({ type: 'cancel_insertions', dontRemove: true, measure:path }) //要等进入编辑才能继续编辑
+            }else{  
+                createFromData()
             }
             {
                 let curSelectMarker 
@@ -2002,7 +2003,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                     bus.emit('changeLineHeight', path.lineHeight) 
                 })
                 path.addEventListener('updated',(e)=>{ 
-                    updatePathHideLine(path)
+                    updatePathFakeLines(path)
                 })
                   
                  
@@ -2060,14 +2061,15 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                     path.setMarkerTitle(index, name)
                 },
                 changePathPoints(points){
-                    console.log('changePathPoints??????????',points)
+                    console.log('changePathPoints??????????',points) 
+                    /* functions.destroy()
+                    props.points = points
+                    createFromData() */
                 },
                 deletePoint(index){
-                    path.removePoint(index)
-                    /* hideMarkers.forEach(e=>{
-                        if(e.index>index) e.index -= 1 //向前移动
-                    }) */
                     path.pointHideList.splice(index, 1)
+                    path.removePoint(index) 
+                     
                 },
                 
                 changeHide(){},
@@ -2078,7 +2080,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                         name: path.markerLabels[index].originText
                     }}) */
                     path.pointHideList[index] = !show
-                    updatePathHideLine(path)
+                    updatePathFakeLines(path)
                     path.updateEdge(true)
                     path.updateEndCaps()
                     viewer.dispatchEvent('content_changed')
@@ -2780,16 +2782,15 @@ function load4dkkMedias(model){//加载四维看看的一些媒体物品
  
 
  
-function updatePathHideLine(path){
+function updatePathFakeLines(path){//更新path隐藏点的线条
     
     function removeLine(i){
         if(path.fakeLines[i]){
-            line.parent.removeChild(path.fakeLines[i])
+            path.remove(path.fakeLines[i])
             path.fakeLines[i] = null
         }
     }
-    function addLine(index){
-        if(index<0)return
+    function addLine(index){ 
         let line = Potree.LineDraw.createFatLine([],{
             //color: ,
             opacity:0.8,            
@@ -2800,27 +2801,28 @@ function updatePathHideLine(path){
         }) 
         path.fakeLines[index] = line
         path.add(line)
+        path.editEnable || Potree.Utils.updateVisible(line,'editEnable', false)
     }
-    path.pointHideList.forEach((e,i)=>{
-        if(e){
-            if(!path.fakeLines[i-1]) addLine(i-1)
-            if(!path.fakeLines[i]) addLine(i) 
+    
+    let hasLines = new Array(path.points.length - 1)
+     
+    path.pointHideList.forEach((e,i)=>{ //隐藏点列表
+        if(e){//隐藏点的两边都有虚线
+            i-1 >= 0 && (hasLines[i-1] = true)
+            i < hasLines.length && (hasLines[i] = true) 
         }
+        Potree.Utils.updateVisible(path.markerLabels[i],'hidePoint', !e)      
     }) 
-
-    for(let i=path.points.length; i<path.fakeLines.length; i++ ){
-        removeLine(i)
+ 
+    let max = Math.max(path.fakeLines.length, hasLines.length)
+    for(let i=0;i<max;i++){
+        if(hasLines[i] && !path.fakeLines[i])addLine(i)
+        else if(!hasLines[i] && path.fakeLines[i])removeLine(i)
+        
+        hasLines[i] && Potree.LineDraw.updateLine(path.fakeLines[i], [path.points[i], path.points[i+1]])     
     }
-    path.fakeLines.length = path.points.length - 1
-     
-    
-    
-    path.fakeLines.forEach((line,index)=>{
-        if(line){
-            Potree.LineDraw.updateLine(line, [path.points[index], path.points[index+1]]) 
-        }
-    })
     
+    path.fakeLines.length = path.points.length - 1 
 }