From 0b0ba7a298364d60567d1c2fbe30c2f2a9000def Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 25 Jun 2021 17:23:16 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/pyhmap

---
 config.json                                 |    4 
 widgets/clippingPlanes/manifest.json        |   17 +
 widgets/null/css/style.css                  |    2 
 widgets/null/Widget.js                      |    1 
 widgets/clippingPlanes/nls/zh-cn/strings.js |    5 
 widgets/clippingPlanes/Widget.js            |  242 ++++++++++++++++++++++++
 widgets/throughSee/css/style.css            |    2 
 widgets/LeftNavigationBar/Widget.js         |    8 
 widgets/digTheEarth/Widget.js               |    4 
 widgets/clippingPlanes/Widget.html          |   29 ++
 widgets/spatialAnalysis/Widget.js           |  106 +++++++++
 widgets/clippingPlanes/nls/strings.js       |    7 
 widgets/clippingPlanes/nls/es/strings.js    |    5 
 widgets/throughSee/Widget.js                |  123 +++++++-----
 widgets/clippingPlanes/css/style.css        |   45 ++++
 15 files changed, 531 insertions(+), 69 deletions(-)

diff --git a/config.json b/config.json
index a3095ac..656296b 100644
--- a/config.json
+++ b/config.json
@@ -272,6 +272,10 @@
       {
         "name": "通视分析",
         "uri": "widgets/throughSee/Widget"
+      },
+      {
+        "name": "平面裁剪",
+        "uri": "widgets/clippingPlanes/Widget"
       }
     ],
     "groups": [],
diff --git a/widgets/LeftNavigationBar/Widget.js b/widgets/LeftNavigationBar/Widget.js
index 7f15f4f..8380776 100644
--- a/widgets/LeftNavigationBar/Widget.js
+++ b/widgets/LeftNavigationBar/Widget.js
@@ -388,7 +388,7 @@
                                             that[item.id] = scene.open(host + partOfUrl, undefined, {
                                                 autoSetView: false //不自动定位
                                             });
-                                            console.log(222)
+                                            // console.log(222)
                                             topic.publish('appendTilt', 'Layermanagement', item);
                                             topic.publish('appendTiltS', 'spatialAnalysis', item);
                                             topic.publish('addLayersLegends', 'legends', item);
@@ -432,7 +432,7 @@
                                                         destination: rectangle
                                                     });
                                                 });
-                                                console.log(444)
+                                                // console.log(444)
                                                 topic.publish('appendItem', 'Layermanagement', item, that[item.id]);
                                                 topic.publish('appendItemS', 'spatialAnalysis', item, that[item.id]);
                                                 topic.publish('addLayersLegends', 'legends', item);
@@ -513,7 +513,7 @@
                                         that[obj.data.id] = scene.open(host + partOfUrl, undefined, {
                                             autoSetView: false //不自动定位
                                         });
-                                        console.log(333)
+                                        // console.log(333)
                                         topic.publish('appendTilt', 'Layermanagement', obj.data);
                                         topic.publish('appendTiltS', 'spatialAnalysis', obj.data);
                                         topic.publish('addLayersLegends', 'legends', obj.data);
@@ -552,7 +552,7 @@
                                                     destination: rectangle
                                                 });
                                             });
-                                            console.log(555)
+                                            // console.log(555)
                                             topic.publish('appendItem', 'Layermanagement', obj.data, that[obj.data.id]);
                                             topic.publish('appendItemS', 'spatialAnalysis', obj.data, that[obj.data.id]);
                                             topic.publish('addLayersLegends', 'legends', obj.data);
diff --git a/widgets/clippingPlanes/Widget.html b/widgets/clippingPlanes/Widget.html
new file mode 100644
index 0000000..532cbda
--- /dev/null
+++ b/widgets/clippingPlanes/Widget.html
@@ -0,0 +1,29 @@
+<div>
+    <div id='loadingbar' class="spinner">
+        <div class="spinner-container container1">
+            <div class="circle1"></div>
+            <div class="circle2"></div>
+            <div class="circle3"></div>
+            <div class="circle4"></div>
+        </div>
+        <div class="spinner-container container2">
+            <div class="circle1"></div>
+            <div class="circle2"></div>
+            <div class="circle3"></div>
+            <div class="circle4"></div>
+        </div>
+        <div class="spinner-container container3">
+            <div class="circle1"></div>
+            <div class="circle2"></div>
+            <div class="circle3"></div>
+            <div class="circle4"></div>
+        </div>
+    </div>
+    <div id="toolbarclippingPlanes" class="param-container tool-bar">
+        <button type="button" id="polygonclippingPlanes" class="button black">绘制裁剪面</button>
+        <button type="button" id="clearclippingPlanes" class="button black">清除</button>
+    </div>
+    <i class="layui-icon closeOUR">
+        &#x1006;
+    </i></span>
+</div>
\ No newline at end of file
diff --git a/widgets/clippingPlanes/Widget.js b/widgets/clippingPlanes/Widget.js
new file mode 100644
index 0000000..0bafdcc
--- /dev/null
+++ b/widgets/clippingPlanes/Widget.js
@@ -0,0 +1,242 @@
+define([
+    'dojo/_base/declare',
+    'dojo/_base/lang',
+    'dojo/_base/array',
+    'dojo/_base/html',
+    'dojo/topic',
+    'jimu/BaseWidget',
+],
+    function (declare,
+        lang,
+        array,
+        html,
+        topic,
+        BaseWidget
+    ) {
+        return declare([BaseWidget], {
+            baseClass: 'jimu-widget-clippingPlanes',
+            name: 'clippingPlanes',
+            flag: false,
+            startup: function () {
+                var that = this;
+                topic.subscribe("beginclippingPlanes", lang.hitch(this, this.beginclippingPlanes));
+                topic.subscribe("closesclippingPlanes", lang.hitch(this, this.closesclippingPlanes));
+                // topic.publish('getbeginSlope', that.beginSlope);
+                $(`.${that.baseClass}`).find('.closeOUR').click(() => {
+                    $(`.${that.baseClass}`).hide();
+                    that.closesclippingPlanes();
+                })
+
+
+                // that.beginclippingPlanes();
+
+            },
+            beginclippingPlanes: function (promise) {
+                console.log(`${this.name}--kaishi`);
+                var that = this;
+                var viewer = that.map;
+                // viewer.imageryLayers.addImageryProvider(new Cesium.BingMapsImageryProvider({
+                //     url : 'https://dev.virtualearth.net',
+                //     mapStyle : Cesium.BingMapsStyle.AERIAL,
+                //     key : URL_CONFIG.BING_MAP_KEY
+                // }));
+                var scene = viewer.scene;
+                // try{
+                //场景添加S3M图层服务
+                that.isClearBut = true;
+                // that.promise = scene.open(window.MYURL_CONFIG.SCENE_BIMBUILDING);
+                // console.log(promise, 444444444444444)
+                that.promise = promise.src;
+                Cesium.when(that.promise, function (layers) {
+                    //     // 精准定位
+                    //     scene.camera.setView({
+                    //         destination: new Cesium.Cartesian3(-2180753.065987198, 4379023.266141494, 4092583.575045952),
+                    //         orientation: {
+                    //             heading: 4.0392222751147955,
+                    //             pitch: 0.010279641987852584,
+                    //             roll: 1.240962888005015e-11
+                    //         }
+                    //     });
+                    // var name = scene.layers._layers._hash;
+                    // for (var a in name) {
+                    //     name = a;
+                    // }
+                    // console.log(name)
+                    var layer = scene.layers.find(promise.name);
+                    // console.log(layer, 55555555555555)
+                    if (layer == undefined) {
+                        console.log('不支持')
+                        window.layer.tips('该图层不支持平面裁剪!', '.SelectLayerTool', {
+                        tips: [3, 'red']
+                        });
+                        if ($(".jimu-widget-clippingPlanes").is(":visible")) {//判断是否隐藏
+                            $(".jimu-widget-clippingPlanes").hide();
+                            topic.publish('closesclippingPlanes');
+                        }
+                        return;
+                    }
+
+                    layer.selectEnabled = false;
+                    // //设置被裁剪对象的颜色
+                    layer.clipLineColor = new Cesium.Color(1, 1, 1, 0);
+                    that.BIMLayer = layer;
+                    // if (!scene.pickPositionSupported) {
+                    //     alert('不支持深度纹理,无法拾取位置!');
+                    // }
+                    // }, function (e) {
+                    //     if (widget._showRenderLoopErrors) {
+                    //         var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
+                    //         widget.showErrorPanel(title, undefined, e);
+                    //     }
+                });
+                // }
+                // catch(e){
+                //     if (widget._showRenderLoopErrors) {
+                //         var title = '渲染时发生错误,已停止渲染。';
+                //         widget.showErrorPanel(title, undefined, e);
+                //     }
+                // }
+
+
+                var clampMode = Cesium.ClampMode.Space;
+                that.tooltip = window.MYcreateTooltip(document.body);
+                that.handlerPolygon = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Polygon, clampMode);
+                var i = 0;
+                that.handlerPolygon.activeEvt.addEventListener(function (isActive) {
+                    if (isActive == true) {
+                        viewer.enableCursorStyle = false;
+                        viewer._element.style.cursor = '';
+                        $('body').removeClass('drawCur').addClass('drawCur');
+                        that.isClearBut = false;
+                        Usebody();
+                        i = 0;
+                    }
+                    else {
+                        viewer.enableCursorStyle = true;
+                        $('body').removeClass('drawCur');
+                        if (that.isClearBut == false) {
+                            if (i < 3) {
+                                that.tooltip.setVisible(false);
+                                layer.tips('不足三个点请重新绘画!', '#polygonclippingPlanes', {
+                                    tips: [3, 'red']
+                                });
+                            }
+                        }
+                        Endbody();
+                    }
+                });
+                that.handlerPolygon.movingEvt.addEventListener(function (windowPosition) {
+                    // console.log(i)
+                    if (that.handlerPolygon.isDrawing) {
+                        that.tooltip.showAt(windowPosition, '<p>只需要设置三个点!</p>');
+                    }
+                    else {
+                        that.tooltip.showAt(windowPosition, '<p>点击绘制第一个点</p>');
+                    }
+                    if (i == 3) {
+                        that.tooltip.showAt(windowPosition, '<p>请点击右键!</p>');
+                    }
+                    if (i > 3) {
+                        that.tooltip.showAt(windowPosition, '<p>超过3个的点不生效!</p>');
+                    }
+                });
+                that.handlerPolygon.drawEvt.addEventListener(function (result) {
+
+                    var positions = result.object.positions;
+                    // console.log(that.handlerPolygon.polygon, 12434)
+                    that.tooltip.setVisible(false);
+                    that.handlerPolygon.polygon.show = false;
+                    // 通过多边形的顶点设置裁剪面,裁剪方向为裁剪面的法线方向
+                    that.BIMLayer.setCustomClipPlane(positions[0], positions[1], positions[2]);
+
+                });
+                var Usebody = () => {
+                    i = 0;
+                    $('.cesium-widget').click(() => {
+                        i++;
+                    })
+                }
+                var Endbody = () => {
+                    i = 0;
+                    $(".cesium-widget").unbind()
+                }
+
+                $('#polygonclippingPlanes').click(function () {
+                    that.handlerPolygon.activate();
+                });
+
+                $('#clearclippingPlanes').click(function () {
+                    that.isClearBut = true;
+                    that.handlerPolygon.clear();
+                    that.isClearBut = false;
+                    //清除裁剪结果
+                    that.BIMLayer.clearCustomClipBox();
+                    Endbody();
+                    // if ()
+
+                });
+                $('#toolbarclippingPlanes').show();
+                $('#loadingbar').remove();
+                if (!scene.pickPositionSupported) {
+                    alert('不支持深度拾取,无法进行鼠标交互绘制!');
+                }
+
+            },
+            tooltip: '',
+            handlerPolygon: '',
+            BIMLayer: '',
+            isClearBut: '',
+            promise: '',
+            closesclippingPlanes: function (froms) {
+                console.log(`${this.name}--guanbi`);
+                var that = this;
+
+                that.isClearBut = true;
+                if (that.handlerPolygon) {
+                    that.handlerPolygon.clear();
+                }
+                that.isClearBut = false;
+                //清除裁剪结果
+                if (that.BIMLayer != '') {
+                    that.BIMLayer.clearCustomClipBox();
+                }
+                $(".cesium-widget").unbind();
+
+                // if (that.promise != '') {
+                //     Cesium.when(that.promise, function (layer) {
+                //         for (var i = 0; i < layer.length; i++) {
+                //             that.map.scene.layers.remove(layer[i].name)
+                //         }
+                //     })
+                // }
+            },
+            onOpen: function () {
+
+            },
+
+            onClose: function () {
+                //面板关闭的时候触发 (when this panel is closed trigger)
+                console.log('jies')
+            },
+
+            onMinimize: function () {
+                this.resize();
+            },
+
+            onMaximize: function () {
+                this.resize();
+            },
+
+            resize: function () {
+
+            },
+
+            destroy: function () {
+                //销毁的时候触发
+                //todo
+                //do something before this func
+                this.inherited(arguments);
+            }
+
+        });
+    });
diff --git a/widgets/clippingPlanes/css/style.css b/widgets/clippingPlanes/css/style.css
new file mode 100644
index 0000000..08b01bb
--- /dev/null
+++ b/widgets/clippingPlanes/css/style.css
@@ -0,0 +1,45 @@
+.jimu-widget-clippingPlanes {
+  position: fixed !important;
+  top: 72px !important;
+  right: 388px !important;
+  width: 160px !important;
+  height: 40px !important;
+  background-color: rgb(255, 255, 255);
+  font-size: 14px;
+  color: rgb(0, 0, 0);
+  z-index: 12 !important;
+  border-radius: 10px;
+  display: none;
+  box-shadow: 0 0 8px #fff;
+  padding: 0px 5px !important;
+  line-height: 42.5px;
+}
+
+.jimu-widget-clippingPlanes .closeOUR {
+  position: absolute;
+  right: 5px;
+  top: 0px;
+  font-size: 18px;
+  cursor: pointer;
+}
+
+.jimu-widget-clippingPlanes .closeOUR:hover {
+  color: red;
+}
+
+.jimu-widget-clippingPlanes button {
+  line-height: 30px;
+  /* width: 80px; */
+  height: 30px;
+  font-size: 14px;
+  border-radius: 5px;
+  box-shadow: 2px 2px 15px -5px #378ef1;
+  border: 1px solid transparent;
+  background-color: #fff;
+  padding: 0 5px;
+  cursor: pointer;
+}
+
+.jimu-widget-clippingPlanes button:hover {
+  box-shadow: 2px 2px 25px -5px #1679eb;
+}
\ No newline at end of file
diff --git a/widgets/clippingPlanes/manifest.json b/widgets/clippingPlanes/manifest.json
new file mode 100644
index 0000000..75370fa
--- /dev/null
+++ b/widgets/clippingPlanes/manifest.json
@@ -0,0 +1,17 @@
+{
+  "name": "clippingPlanes",
+  "2D": true,
+  "3D": true,
+  "platform": "HTML",
+  "version": "2.10",
+  "wabVersion": "2.10",
+  "author": "liuyg",
+  "description": "",
+  "copyright": "",
+  "license": "",
+  "properties": {
+    "hasConfig": false,
+    "inPanel": false,
+    "hasVersionManager": false
+  }
+}
\ No newline at end of file
diff --git a/widgets/clippingPlanes/nls/es/strings.js b/widgets/clippingPlanes/nls/es/strings.js
new file mode 100644
index 0000000..7b72db7
--- /dev/null
+++ b/widgets/clippingPlanes/nls/es/strings.js
@@ -0,0 +1,5 @@
+define(
+   ({
+    _widgetLabel: "clippingPlanes"
+  })
+);
\ No newline at end of file
diff --git a/widgets/clippingPlanes/nls/strings.js b/widgets/clippingPlanes/nls/strings.js
new file mode 100644
index 0000000..e714329
--- /dev/null
+++ b/widgets/clippingPlanes/nls/strings.js
@@ -0,0 +1,7 @@
+define({
+  root: ({
+    _widgetLabel: "clippingPlanes"
+  }),
+  "es": 1,
+  "zh-cn": 1
+});
\ No newline at end of file
diff --git a/widgets/clippingPlanes/nls/zh-cn/strings.js b/widgets/clippingPlanes/nls/zh-cn/strings.js
new file mode 100644
index 0000000..2b6199c
--- /dev/null
+++ b/widgets/clippingPlanes/nls/zh-cn/strings.js
@@ -0,0 +1,5 @@
+define(
+   ({
+    _widgetLabel: "平面裁剪"
+  })
+);
\ No newline at end of file
diff --git a/widgets/digTheEarth/Widget.js b/widgets/digTheEarth/Widget.js
index 9c56eda..0288d8d 100644
--- a/widgets/digTheEarth/Widget.js
+++ b/widgets/digTheEarth/Widget.js
@@ -154,7 +154,9 @@
                 if (that.handlerPolygon.polyline) {
                     that.handlerPolygon.polyline.show = false;
                 }
-                that.handlerPolygon.deactivate();
+                if (that.handlerPolygon.deactivate) {
+                    that.handlerPolygon.deactivate();
+                }
                 that.tooltip.setVisible(false);
             },
             onOpen: function () {
diff --git a/widgets/null/Widget.js b/widgets/null/Widget.js
index f6122a2..a797c94 100644
--- a/widgets/null/Widget.js
+++ b/widgets/null/Widget.js
@@ -38,6 +38,7 @@
             },
             closesNull: function (froms) {
                 console.log(`${this.name}--guanbi`);
+                var that = this;
             },
             onOpen: function () {
 
diff --git a/widgets/null/css/style.css b/widgets/null/css/style.css
index ce85f40..196b0b5 100644
--- a/widgets/null/css/style.css
+++ b/widgets/null/css/style.css
@@ -30,7 +30,7 @@
   line-height: 30px;
   width: 80px;
   height: 30px;
-  font-size: 16px;
+  font-size: 14px;
   border-radius: 5px;
   box-shadow: 2px 2px 15px -5px #378ef1;
    border: 1px solid transparent;
diff --git a/widgets/spatialAnalysis/Widget.js b/widgets/spatialAnalysis/Widget.js
index 1ac956e..e3673aa 100644
--- a/widgets/spatialAnalysis/Widget.js
+++ b/widgets/spatialAnalysis/Widget.js
@@ -75,6 +75,11 @@
 						name: '通视分析',
 						classs: 'throughSee-tool',
 						img: './images/addL/pdpx.png'
+					},
+					{//平面裁剪
+						name: '平面裁剪',
+						classs: 'clippingPlanes-tool',
+						img: './images/addL/pdpx.png'
 					}
 				];
 
@@ -135,6 +140,11 @@
 								name: '通视分析',
 								classs: 'throughSee-tool',
 								img: './images/addL/pdpx.png'
+							},
+							{//平面裁剪
+								name: '平面裁剪',
+								classs: 'clippingPlanes-tool',
+								img: './images/addL/pdpx.png'
 							}
 							,
 							{//建造模型
@@ -173,6 +183,7 @@
 				})
 
 			},
+			promise: 'NODATA',
 			beginSpatialAnalysis: function (domHtmls) {
 				var that = this;
 				var domHtmls = domHtmls;
@@ -264,6 +275,19 @@
 					topic.publish('beginthroughSee', 'beginthroughSee');
 				})
 
+				//平面裁剪
+				$('.clippingPlanes-tool').click(function () {
+					that.closeOnceUse();
+					// console.log(that.promise, 22222222222)
+					if (that.promise == 'NODATA') {
+						layer.tips('请选择三维倾斜数据中的图层支持!', '.SelectLayerTool', {
+							tips: [3, 'red']
+						});
+					} else {
+						$(".jimu-widget-clippingPlanes").show();
+						topic.publish('beginclippingPlanes', that.promise);
+					}
+				})
 
 				$('.SelectLayerTool').click(() => {
 					$('#SelectLayerToolItem').toggle();
@@ -277,7 +301,21 @@
 				this.liClick('默认:天地图影像', '默认:天地图影像');
 
 			},
-			liClick: function (itemid, name) {//点击事件
+			morenliClick: (itemid, name) => {
+				var dom = $('.SelectLayerTool');
+				dom.empty();
+				var str = `${name} <i class="layui-icon layui-icon-down layui-font-12"></i>`
+				dom.append(str);
+				// console.log('数据错误默认')
+				this.promise = 'NODATA';
+				//关闭平面裁剪
+				if ($(".jimu-widget-clippingPlanes").is(":visible")) {//判断是否隐藏
+					$(".jimu-widget-clippingPlanes").hide();
+					topic.publish('closesclippingPlanes');
+				}
+			},
+			liClick: function (itemid, name, ourdata = 1) {//点击事件
+				var that = this;
 				var liList = $(`[itemid='${itemid}s']`);
 				// console.log(liList);
 				liList.click(() => {
@@ -289,6 +327,47 @@
 					dom.append(str);
 					dom.attr("title", name);
 					$('#SelectLayerToolItem').hide();
+					// console.log(ourdata);
+					// 定位
+					// console.log(name)
+					if (ourdata != 1) {
+						// 	console.log('data')
+						if (ourdata.lon) {
+							that.map.camera.flyTo({
+								destination: Cesium.Cartesian3.fromDegrees(Number(ourdata.lon), Number(ourdata.lat), Number(ourdata.height * 50))
+							});
+						}
+						if (ourdata.src.indexOf('.openrealspace') != -1) {
+							// console.log('数据正确');
+							//关闭平面裁剪
+							if ($(".jimu-widget-clippingPlanes").is(":visible")) {//判断是否隐藏
+								$(".jimu-widget-clippingPlanes").hide();
+								topic.publish('closesclippingPlanes');
+							}
+							that.promise = {
+								src: ourdata.src,
+								name: ourdata.serviceName
+							};
+
+						} else {
+							// console.log('数据错误');
+							that.promise = 'NODATA';
+							//关闭平面裁剪
+							if ($(".jimu-widget-clippingPlanes").is(":visible")) {//判断是否隐藏
+								$(".jimu-widget-clippingPlanes").hide();
+								topic.publish('closesclippingPlanes');
+							}
+						}
+					} else {
+						// console.log('数据错误没有data');
+						that.promise = 'NODATA';
+						//关闭平面裁剪
+						if ($(".jimu-widget-clippingPlanes").is(":visible")) {//判断是否隐藏
+							$(".jimu-widget-clippingPlanes").hide();
+							topic.publish('closesclippingPlanes');
+						}
+					}
+
 				})
 			},
 			appendItemS: function (item, obj, layer) {
@@ -318,20 +397,22 @@
 
 						$("#SelectLayerToolItemTitle").append(liItem);
 					}
-					that.liClick(obj.id, obj.title);
+					that.liClick(obj.id, obj.title, obj);
 				}
 			},
 			removeItemS: function (item, obj) {
-				console.log(obj, 'r1')
+				// console.log(obj, 'r1')
+				var that = this;
 				if (item == this.name) {
 					var liList = $("#SelectLayerToolItemTitle li");
 					for (var i = 0; i < liList.length; i++) {
 						if ($(liList[i]).attr('itemid') && $(liList[i]).attr('itemid') == obj.id + 's') {
 							$(liList[i]).remove();
 							var dom = $('.SelectLayerTool').attr("title");
-							console.log(dom == obj.title, this.liClick)
+							// console.log(dom == obj.title, this.liClick)
 							if (dom == obj.title) {
-								this.liClick('默认:天地图影像', '默认:天地图影像');
+								that.morenliClick('默认:天地图影像', '默认:天地图影像');
+								that.promise = 'NODATA';
 							}
 						}
 					}
@@ -372,12 +453,13 @@
 
 						$("#SelectLayerToolItemTitle").append(liItem);
 					}
-					that.liClick(obj.id, obj.title);
+					that.liClick(obj.id, obj.title, obj);
 				}
 			},
 			removeTiltS: function (item, obj) {
-				console.log(obj, 'r2')
+				// console.log(obj, 'r2')
 				// console.log('r2')
+				var that = this;
 				if (item == this.name) {
 					var liList = $("#SelectLayerToolItemTitle li");
 					for (var i = 0; i < liList.length; i++) {
@@ -385,7 +467,8 @@
 							$(liList[i]).remove();
 							var dom = $('.SelectLayerTool').attr("title");
 							if (dom == obj.title) {
-								this.liClick('默认:天地图影像', '默认:天地图影像');
+								that.morenliClick('默认:天地图影像', '默认:天地图影像');
+								that.promise = 'NODATA';
 							}
 						}
 					}
@@ -476,7 +559,12 @@
 				//关闭通视分析
 				if ($(".jimu-widget-throughSee").is(":visible")) {//判断是否隐藏
 					$(".jimu-widget-throughSee").hide();
-					// topic.publish('closesthroughSee');
+					topic.publish('closesthroughSee');
+				}
+				//关闭平面裁剪
+				if ($(".jimu-widget-clippingPlanes").is(":visible")) {//判断是否隐藏
+					$(".jimu-widget-clippingPlanes").hide();
+					topic.publish('closesclippingPlanes');
 				}
 
 			},
diff --git a/widgets/throughSee/Widget.js b/widgets/throughSee/Widget.js
index 68f6772..102a49a 100644
--- a/widgets/throughSee/Widget.js
+++ b/widgets/throughSee/Widget.js
@@ -67,27 +67,27 @@
                 var widget = viewer.cesiumWidget;
                 // try {
 
-                var promise = scene.open(window.MYURL_CONFIG.SCENE_CBD);
-                Cesium.when.all(promise, function (layer) {
-                    scene.camera.setView({
-                        destination: new Cesium.Cartesian3.fromDegrees(116.44621857300415, 39.899281526734555, 216.7793905027196),
-                        orientation: {
-                            heading: 0.41348036210986194,
-                            pitch: -0.13636490404291735,
-                            roll: 6.283185307179563
-                        }
-                    });
-                    for (var i = 0; i < layer.length; i++) {
-                        layer[i].selectEnabled = false;
-                    }
+                // var promise = scene.open(window.MYURL_CONFIG.SCENE_CBD);
+                // Cesium.when.all(promise, function (layer) {
+                // scene.camera.setView({
+                //     destination: new Cesium.Cartesian3.fromDegrees(116.44621857300415, 39.899281526734555, 216.7793905027196),
+                //     orientation: {
+                //         heading: 0.41348036210986194,
+                //         pitch: -0.13636490404291735,
+                //         roll: 6.283185307179563
+                //     }
+                // });
+                // for (var i = 0; i < layer.length; i++) {
+                //     layer[i].selectEnabled = false;
+                // }
 
-                    sightline.build();
-                }, function (e) {
-                    if (widget._showRenderLoopErrors) {
-                        var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
-                        widget.showErrorPanel(title, undefined, e);
-                    }
-                });
+                sightline.build();
+                // }, function (e) {
+                //     if (widget._showRenderLoopErrors) {
+                //         var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
+                //         widget.showErrorPanel(title, undefined, e);
+                //     }
+                // });
                 // } catch (e) {
                 //     if (widget._showRenderLoopErrors) {
                 //         var title = '渲染时发生错误,已停止渲染。';
@@ -102,8 +102,8 @@
                 var tf = false;//当前点击状态是否是 添加目标点
 
                 var num = 0;//添加的目标点的点号
-                var couldRemove = false;//是否能移除目标点
-                var tooltip = window.MYcreateTooltip(viewer._element)
+                that.couldRemove = false;//是否能移除目标点
+                that.tooltip = window.MYcreateTooltip(viewer._element)
                 var handlerPoint = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Point);
                 handlerPoint.drawEvt.addEventListener(function (result) {
                     //添加观察点
@@ -125,7 +125,7 @@
 
 
 
-                var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
+                that.handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
 
                 document.getElementById("addViewPointthroughSee").onclick = function () {
                     if (tf == false) {
@@ -135,11 +135,11 @@
                             return;
                         }
                         viewer.entities.removeAll();
-                        if (couldRemove) {
+                        if (that.couldRemove) {
                             sightline.removeAllTargetPoint();
                         }
                         handlerPoint.activate();
-                        handler.setInputAction(function (evt) {
+                        that.handler.setInputAction(function (evt) {
 
                             //鼠标移动,更新最后一次添加的目标点的位置
                             var position = scene.pickPosition(evt.endPosition);
@@ -152,16 +152,16 @@
                             $('body').removeClass('drawCur').addClass('drawCur');
                         }
                         //鼠标移动事件,更新点
-                        handler.setInputAction(function (evt) {
-                            tooltip.showAt(evt.endPosition, '<p>点击确定观察点</p>');
+                        that.handler.setInputAction(function (evt) {
+                            that.tooltip.showAt(evt.endPosition, '<p>点击确定观察点</p>');
                         }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
                         //鼠标点击事件,添加点
-                        handler.setInputAction(function (e) {
+                        that.handler.setInputAction(function (e) {
                             $('body').removeClass('drawCur');
                             mv = true;
-                            tooltip.setVisible(false);
-                            handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
-                            handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
+                            that.tooltip.setVisible(false);
+                            that.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
+                            that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
                         }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
                     } else {
                         layer.tips('正在添加目标点,请先右键关闭', $('#addViewPointthroughSee'), { tips: [1, 'red'] });
@@ -181,13 +181,13 @@
                         }
 
                         //鼠标点击事件,添加点
-                        handler.setInputAction(function (e) {
+                        that.handler.setInputAction(function (e) {
                             var position = scene.pickPosition(e.position);
                             addTarget(position);
                         }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
 
                         //鼠标移动事件,更新点
-                        handler.setInputAction(function (evt) {
+                        that.handler.setInputAction(function (evt) {
 
                             //鼠标移动,更新最后一次添加的目标点的位置
                             var position = scene.pickPosition(evt.endPosition);
@@ -202,16 +202,16 @@
                                     name: "point0"
                                 });
                             }
-                            tooltip.showAt(evt.endPosition, '<p>点击确定目标点右键结束</p>');
+                            that.tooltip.showAt(evt.endPosition, '<p>点击确定目标点右键结束</p>');
                         }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
 
                         //鼠标右键事件,结束
-                        handler.setInputAction(function () {
+                        that.handler.setInputAction(function () {
                             viewer.enableCursorStyle = true;
                             $('body').removeClass('drawCur');
-                            tooltip.setVisible(false);
-                            handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
-                            handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
+                            that.tooltip.setVisible(false);
+                            that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
+                            that.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
                             tf = false;
                         }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
                     } else {
@@ -226,15 +226,17 @@
                         mv = false;
                         tf = false;
                         handlerPoint.clear();
+                        that.tooltip.setVisible(false);
                         viewer.entities.removeAll();
-                        if (couldRemove) {
+                        that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
+                        if (that.couldRemove) {
                             sightline.removeAllTargetPoint();
-                            couldRemove = false;
+                            that.couldRemove = false;
                         }
                         viewer.enableCursorStyle = true;
                         $('body').removeClass('drawCur');
                     } else {
-                        layer.tips('正在添加目标点,请先右键关闭', $('#addViewPointthroughSee'), { tips: [1, 'red'] });
+                        layer.tips('正在添加目标点,请先右键关闭', $('#clearthroughSee'), { tips: [1, 'red'] });
 
                     }
                 }
@@ -254,7 +256,7 @@
                             position: cartographic,
                             name: name
                         });
-                        couldRemove = true;
+                        that.couldRemove = true;
                     }
                 }
 
@@ -268,32 +270,47 @@
                     return [longitude, latitude, height];
                 }
 
-                that.promise = promise;
+                // that.promise = promise;
                 that.addViewFlag = addViewFlag;
                 that.addTargetFlag = addTargetFlag;
                 that.handlerPoint = handlerPoint;
+                that.sightline = sightline;
 
             },
-            promise: '',
+            // promise: '',
             addViewFlag: '',
             addTargetFlag: '',
+            couldRemove: '',
+            sightline: '',
+            tooltip: '',
+            handler: '',
             handlerPoint: '',
             closesthroughSee: function (froms) {
                 console.log(`${this.name}--guanbi`);
                 that = this;
 
-                Cesium.when.all(that.promise, function (layer) {
-                    for (var i = 0; i < layer.length; i++) {
-                        that.map.scene.layers.remove(layer[i].name)
-                    }
-                })
+                // Cesium.when.all(that.promise, function (layer) {
+                //     for (var i = 0; i < layer.length; i++) {
+                //         that.map.scene.layers.remove(layer[i].name)
+                //     }
+                // })
+                if (that.handler.removeInputAction) {
+                    that.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
+                    that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
+                }
+                if (that.tooltip.setVisible) {
+                    that.tooltip.setVisible(false);
+                }
+                if (that.handlerPoint.clear) {
+                    that.handlerPoint.clear();
+                }
                 that.addViewFlag = false;
                 that.addTargetFlag = false;
-                that.handlerPoint.clear();
+
                 that.map.entities.removeAll();
-                if (couldRemove) {
-                    sightline.removeAllTargetPoint();
-                    couldRemove = false;
+                if (that.couldRemove) {
+                    that.sightline.removeAllTargetPoint();
+                    that.couldRemove = false;
                 }
                 that.map.enableCursorStyle = true;
                 $('body').removeClass('drawCur');
diff --git a/widgets/throughSee/css/style.css b/widgets/throughSee/css/style.css
index 2193504..22edad5 100644
--- a/widgets/throughSee/css/style.css
+++ b/widgets/throughSee/css/style.css
@@ -9,7 +9,7 @@
   color: rgb(0, 0, 0);
   z-index: 12 !important;
   border-radius: 10px;
-  /* display: none; */
+  display: none;
   box-shadow: 0 0 8px #fff;
   padding: 0px 5px !important;
   line-height: 41px;

--
Gitblit v1.9.3