shuishen
2021-06-18 d12e030d8a7690d79c5786bc2a786b6c21a24433
widgets/spatialAnalysis/Widget.js
New file
@@ -0,0 +1,213 @@
///////////////////////////////////////////////////////////////////////////
// Copyright © 2019 zhongsong. All Rights Reserved.
// 模块描述:显示坐标
///////////////////////////////////////////////////////////////////////////
define([
   'dojo/_base/declare',
   'dojo/_base/lang',
   'dojo/_base/array',
   'dojo/_base/html',
   'dojo/topic',
   'jimu/BaseWidget',
   'jimu/utils',
   'jimu/css!libs/zTree_v3/css/zTreeStyle/zTreeStyle.css',
   'libs/zTree_v3/js/jquery.ztree.all'
],
   function (declare,
      lang,
      array,
      html,
      topic,
      BaseWidget,
      aspect,
      string,
      utils
   ) {
      return declare([BaseWidget], {
         baseClass: 'jimu-widget-spatialAnalysis',
         name: 'spatialAnalysis',
         layers: {},
         startup: function () {
            var that = this;
            // 暴露在外的接口
            var domHtmls = [
               {
                  name: '可视分析',
                  classs: 'visibleArea-tool'
               }, {
                  name: '剖面分析',
                  classs: 'profileAnalysis-tool'
               }, {
                  name: '坡度分析',
                  classs: 'slope-tool'
               }
            ];
            var dom = $('#spatialAnalysis-main');
            var str = '';
            for (var k in domHtmls) {
               str += `<li class="${domHtmls[k].classs}">
                <i></i>
                <span>${domHtmls[k].name}</span>
                </li>`
            }
            dom.replaceWith(str);
            $('.closesspatialAnalysis').click(() => {
               $('.jimu-widget-spatialAnalysis').hide();
               // 关闭可视
               topic.publish('closev', '');
               // 关闭剖面
               topic.publish('closep', '');
               // 关闭坡度
               topic.publish('closes', '');
               $(".jimu-widget-visibleArea").hide();
               $(".jimu-widget-profileAnalysis").hide();
               $(".jimu-widget-slope").hide();
            })
            // topic.subscribe("closeTool", lang.hitch(this, this.closeToolBox));
            // this.inherited(arguments);
            // $('.tool-bar .tool-btn span').click(function () {
            //    topic.publish('closeMap', this.name);
            //    topic.publish('closeZtree', this.name);
            //    $('.tool-y-box').toggle();
            // })
            // 可视分析
            $('.visibleArea-tool').click(function () {
               that.map.scene.globe.depthTestAgainstTerrain = true;
               // 关闭量算
               topic.publish('closeMeasurement', 'Measurement');
               // 关闭卷帘
               topic.publish('closeRolling', 'Rolling');
               // 关闭分屏
               topic.publish('closeSplitScreen', 'SplitScreen');
               // 关闭标记
               topic.publish('closeSign', 'Sign');
               topic.publish('closeFlyRoute', 'FlyRoute');
               $('.jimu-widget-CoorPosition').hide();
               $('.jimu-widget-MapPrinting').hide();
               // 关闭可视
               // topic.publish('closev', '');
               // 关闭剖面
               topic.publish('closep', '');
               // 关闭坡度
               topic.publish('closes', '');
               $(".jimu-widget-profileAnalysis").hide();
               $(".jimu-widget-slope").hide();
               $('.tool-y-box').stop().hide();
               $(".jimu-widget-visibleArea").show();
            })
            // 剖面分析
            $('.profileAnalysis-tool').click(function () {
               that.map.scene.globe.depthTestAgainstTerrain = true;
               // 关闭量算
               topic.publish('closeMeasurement', 'Measurement');
               // 关闭卷帘
               topic.publish('closeRolling', 'Rolling');
               // 关闭分屏
               topic.publish('closeSplitScreen', 'SplitScreen');
               // 关闭标记
               topic.publish('closeSign', 'Sign');
               topic.publish('closeFlyRoute', 'FlyRoute');
               $('.jimu-widget-CoorPosition').hide();
               $('.jimu-widget-MapPrinting').hide();
               // 关闭可视
               topic.publish('closev', '');
               // 关闭剖面
               // topic.publish('closep', '');
               // 关闭坡度
               topic.publish('closes', '');
               $(".jimu-widget-visibleArea").hide();
               $(".jimu-widget-slope").hide();
               $('.tool-y-box').stop().hide();
               $(".jimu-widget-profileAnalysis").show();
            })
            //坡度分析
            $('.slope-tool').click(function () {
               that.map.scene.globe.depthTestAgainstTerrain = true;
               // 关闭量算
               topic.publish('closeMeasurement', 'Measurement');
               // 关闭卷帘
               topic.publish('closeRolling', 'Rolling');
               // 关闭分屏
               topic.publish('closeSplitScreen', 'SplitScreen');
               // 关闭标记
               topic.publish('closeSign', 'Sign');
               topic.publish('closeFlyRoute', 'FlyRoute');
               $('.jimu-widget-CoorPosition').hide();
               $('.jimu-widget-MapPrinting').hide();
               // 关闭可视
               topic.publish('closev', '');
               // 关闭剖面
               topic.publish ('closep', '');
               // 关闭坡度
               // topic.publish('closes', '');
               $(".jimu-widget-visibleArea").hide();
               $(".jimu-widget-profileAnalysis").hide();
               $('.tool-y-box').stop().hide();
               $(".jimu-widget-slope").show();
               topic.publish('getbeginSlope', this.beginSlope);
            })
         },
         closeToolBox: function (item) {
            if (item != this.name) {
               $('.tool-y-box').hide();
            }
         },
         onOpen: function () {
            //面板打开的时候触发 (when open this panel trigger)
            // var domHtmls = [
            //    {
            //       name: '可视分析',
            //       classs: 'visibleArea-tool'
            //    }, {
            //       name: '剖面分析',
            //       classs: 'profileAnalysis-tool'
            //    }, {
            //       name: '坡度分析',
            //       classs: 'slope-tool'
            //    },
            // ];
            // var dom = $('#spatialAnalysis-main');
            // var str = '';
            // for (var k in domHtmls) {
            //    str += `<li class="${domHtmls[k].classs}"><i></i> <span>${domHtmls[k].name}</span></li>`
            // }
            // dom.replaceWith(str);
         },
         onClose: function () {
            //面板关闭的时候触发 (when this panel is closed trigger)
         },
         onMinimize: function () {
            this.resize();
         },
         onMaximize: function () {
            this.resize();
         },
         resize: function () {
         },
         destroy: function () {
            //销毁的时候触发
            //todo
            //do something before this func
            this.inherited(arguments);
         }
      });
   });