From f7578f792d716d1aa4e6131c35bc325faba1488c Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Wed, 30 Jun 2021 14:27:49 +0800
Subject: [PATCH] 空间分析裁剪bug

---
 widgets/BOXTailoring/Widget.js |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/widgets/BOXTailoring/Widget.js b/widgets/BOXTailoring/Widget.js
index 32d0a1f..90b8d48 100644
--- a/widgets/BOXTailoring/Widget.js
+++ b/widgets/BOXTailoring/Widget.js
@@ -135,7 +135,7 @@
                         , Nowheight = that.Nowheight
                         , Nowrotate = that.Nowrotate;
                     var tooltip = window.MYcreateTooltip(document.body);
-                    var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
+                    that.handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
                     var isBegin = false;//设置不重复添加盒子
 
                     $('#beginBOXTailoringG').click(() => {
@@ -229,11 +229,11 @@
 
 
 
-                        handler.setInputAction(function (evt) {
+                        that.handler.setInputAction(function (evt) {
                             tooltip.showAt(evt.endPosition, '<p>点击模型,添加裁剪盒子</p>');
                         }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
 
-                        handler.setInputAction(function (evt) {
+                        that.handler.setInputAction(function (evt) {
                             var clipMode = $clipMode.val();
                             var length = Number(Nowlength);
                             var width = Number(Nowwidth);
@@ -261,8 +261,8 @@
                             });
                             setAllLayersClipOptions(boxOption);
                             tooltip.setVisible(false);
-                            handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
-                            handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
+                            that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
+                            that.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
                         }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
 
                     })
@@ -277,15 +277,15 @@
                             });
                             return false;
                         }
-                        handler.setInputAction(
+                        that.handler.setInputAction(
                             function (movement) {
                                 tooltip.showAt(movement.endPosition, '<p>点击模型,移动裁剪盒子</p>');
                                 var cartesian = viewer.scene.pickPosition(movement.startPosition);
                                 boxEntity.position = cartesian;
-                                handler.setInputAction(function (evt) {
+                                that.handler.setInputAction(function (evt) {
                                     setClipBox();
                                     tooltip.setVisible(false);
-                                    handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
+                                    that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
                                 }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
                             }, Cesium.ScreenSpaceEventType.MOUSE_MOVE
                         );
@@ -306,9 +306,10 @@
                         that.closesBOXTailoring();
                     });
 
-                    handler.setInputAction(function () {
+                    that.handler.setInputAction(function () {
                         setClipBox();
-                        handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
+                        that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
+                        that.handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK);
                     }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
                     $clipMode.change(function () {
                         setClipBox();
@@ -350,6 +351,7 @@
 
             },
             promise: 'null',
+            handler: 'null',
             closesBOXTailoring: function (froms) {
                 // console.log(`${this.name}--guanbi`);
                 var that = this;
@@ -362,6 +364,11 @@
                         that.defaultLayui();
                     })
                 }
+                if (that.handler != 'null') {
+                    that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
+                    that.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
+                    that.handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK);
+                }
 
             },
             onOpen: function () {

--
Gitblit v1.9.3