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-crossTailoring', name: 'crossTailoring', flag: false, startup: function () { var that = this; topic.subscribe("begincrossTailoring", lang.hitch(this, this.begincrossTailoring)); topic.subscribe("closescrossTailoring", lang.hitch(this, this.closescrossTailoring)); // topic.publish('getbeginSlope', that.beginSlope); $(`.${that.baseClass}`).find('.closeOUR').click(() => { $(`.${that.baseClass}`).hide(); that.closescrossTailoring(); }) that.defaultSlider(); // that.begincrossTailoring(); }, defaultSlider: function () { var that = this; that.promise = ''; layui.use(function () { var slider = layui.slider //滑块 //滑块 var sliderInst1 = slider.render({ elem: '#widthcrossTailoring' , value: that.Owidth , disabled: true }); var sliderInst2 = slider.render({ elem: '#heightcrossTailoring' , value: that.Oheight , disabled: true }); var sliderInst3 = slider.render({ elem: '#pitchcrossTailoring' , value: that.Opitch , max: 360 , disabled: true }); var sliderInst4 = slider.render({ elem: '#rollcrossTailoring' , value: that.Oroll , max: 360 , disabled: true }); var sliderInst4 = slider.render({ elem: '#headingcrossTailoring' , value: that.Oheading , max: 360 , disabled: true }); var sliderInst4 = slider.render({ elem: '#extrudecrossTailoring' , value: that.OextrudeDistance , max: 30 , disabled: true }); }) $('#clip-width-label').val(that.Owidth); $('#clip-height-label').val(that.Oheight); $('#clip-heading-label').val(that.Oheading); $('#clip-pitch-label').val(that.Opitch); $('#clip-roll-label').val(that.Oroll); $('#clip-extrude-label').val(that.OextrudeDistance); }, Owidth: 5, Oheight: 5, Oheading: 0, Opitch: 0, Oroll: 0, OextrudeDistance: 1.0, begincrossTailoring: function (pro) { // console.log(`${this.name}--kaishi`); var that = this; // console.log(pro.src) // return var heardsname = $('#namebarcrossTailoring'); heardsname.empty(); heardsname.append(pro.ZName); heardsname = $('#heardbarcrossTailoring'); heardsname.attr("title", pro.ZName);; var viewer = that.map; var scene = viewer.scene; scene.globe.depthTestAgainstTerrain = false; that.promise = window.mySanweiShujuOpens[pro.id]; // console.log(pro.id) // console.log(that.promise) // that.promise = scene.open(window.MYURL_CONFIG.SCENE_BIMBUILDING); that.promise.then(function (layers) { // 精准定位 // scene.camera.setView({ // destination: new Cesium.Cartesian3(-2180765.6717242915, 4379147.755349731, 4092644.516292509), // orientation: { // heading: 1.5751279310014885, // pitch: -1.493948327772495, // roll: 3.1415926535996626 // } // }); // var actives = function(){ var boxPosition, position, dim, width = that.Owidth, height = that.Oheight, heading = that.Oheading, pitch = that.Opitch, roll = that.Oroll, extrudeDistance = that.OextrudeDistance, hasClipped = false; that.startClip = false; that.box = viewer.entities.add({ // 标识盒 position: Cesium.Cartesian3.fromDegrees(0, 0, 0), show: false, box: { dimensions: new Cesium.Cartesian3(5, 5, 0.1), fill: false, outline: true, outlineColor: Cesium.Color.WHITE, outlineWidth: 5.0 } }); $("#choose-clip-poscrossTailoring").on("click", function () { if (that.handler) { that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE); that.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); that.handler = ''; } that.handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); that.handler.setInputAction(function (movement) { if (that.startClip) { boxPosition = scene.pickPosition(movement.endPosition); if (!boxPosition) { return; } that.box.position = boxPosition; } }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); that.handler.setInputAction(function (evt) { if (that.startClip) { position = scene.pickPosition(evt.position); if (!position) { return; } var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(heading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll)); var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr); that.box.orientation = orientation; dim = new Cesium.Cartesian3(width, height, extrudeDistance); updateClip(); that.startClip = false; hasClipped = true; that.box.show = false; viewer.enableCursorStyle = true; $('body').removeClass('drawCurshizi'); that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE); that.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); } }, Cesium.ScreenSpaceEventType.LEFT_CLICK); // $("#choose-clip-poscrossTailoring").on("click", function () { layui.use(function () { var slider = layui.slider //滑块 //滑块 var sliderInst1 = slider.render({ elem: '#widthcrossTailoring' // , input: true //输入框 , value: that.Owidth , disabled: false , change: function (value) { width = Number(value); that.Owidth = Number(value); $('#clip-width-label').val(value); that.box.box.dimensions = new Cesium.Cartesian3(width, height, 0.1); dim = new Cesium.Cartesian3(width, height, extrudeDistance); if (!position) { return; } if (hasClipped) { updateClip(); } } }); var sliderInst2 = slider.render({ elem: '#heightcrossTailoring' // , input: true //输入框 , value: that.Oheight , disabled: false , change: function (value) { height = Number(value); that.Oheight = Number(value); $('#clip-height-label').val(value); that.box.box.dimensions = new Cesium.Cartesian3(width, height, 0.1); dim = new Cesium.Cartesian3(width, height, extrudeDistance); if (!position) { return; } if (hasClipped) { updateClip(); } } }); var sliderInst3 = slider.render({ elem: '#headingcrossTailoring' // , input: true //输入框 , value: that.Oheading , max: 360 , disabled: false , change: function (value) { heading = Number(value); that.Oheading = Number(value); $('#clip-heading-label').val(value); var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(heading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll)); var orientation = Cesium.Transforms.headingPitchRollQuaternion(boxPosition, hpr); that.box.orientation = orientation; if (!position) { return; } if (hasClipped) { updateClip(); } } }); var sliderInst4 = slider.render({ elem: '#pitchcrossTailoring' // , input: true //输入框 , value: that.Opitch , max: 360 , disabled: false , change: function (value) { pitch = Number(value); that.Opitch = Number(value); $('#clip-pitch-label').val(value); var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(heading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll)); var orientation = Cesium.Transforms.headingPitchRollQuaternion(boxPosition, hpr); that.box.orientation = orientation; if (!position) { return; } if (hasClipped) { updateClip(); } } }); var sliderInst5 = slider.render({ elem: '#rollcrossTailoring' // , input: true //输入框 , value: that.Oroll , max: 360 , disabled: false , change: function (value) { roll = Number(value); that.Oroll = Number(value); $('#clip-roll-label').val(value); var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(heading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll)); var orientation = Cesium.Transforms.headingPitchRollQuaternion(boxPosition, hpr); that.box.orientation = orientation; if (!position) { return; } if (hasClipped) { updateClip(); } } }); var sliderInst6 = slider.render({ elem: '#extrudecrossTailoring' // , input: true //输入框 , value: that.OextrudeDistance , max: 30 , step: 0.1 , disabled: false , change: function (value) { extrudeDistance = Number(value); that.OextrudeDistance = Number(value); $('#clip-extrude-label').val(value); if (hasClipped) { updateClip(); } } }); }) // } // $("#choose-clip-poscrossTailoring").on("click", function () { that.startClip = true; that.box.show = true; // actives(); viewer.enableCursorStyle = false; viewer._element.style.cursor = ''; $('body').removeClass('drawCurshizi').addClass('drawCurshizi'); }); $("#clearcrossTailoring").on("click", function () { // that.startClip = false; // that.box.show = false; // for (var i = 0, j = layers.length; i < j; i++) { // layers[i].clearCustomClipBox(); // }; // viewer.entities.removeAll(); that.closescrossTailoring(); }); // 折叠参数面板 $(".params-setting-anchor").click(function () { $(".params-setting").toggleClass("params-setting-hide"); }); function updateClip() { for (var i = 0, j = layers.length; i < j; i++) { layers[i].setCustomClipCross({ position: position, dimensions: dim, heading: heading, pitch: pitch, roll: roll, extrudeDistance: extrudeDistance }); } } }); }, handler: '', box: '', startClip: false, promise: 'null', closescrossTailoring: function (froms) { // console.log(`${this.name}--guanbi`); var that = this; // console.log(that.promise, 45343463) that.startClip = false; that.box.show = false; if (that.promise != 'null') { that.promise.then(function (layers) { for (var i = 0, j = layers.length; i < j; i++) { layers[i].clearCustomClipBox(); }; }); that.map.entities.removeAll(); } that.defaultSlider(); }, 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); } }); });