liuyg
2021-06-30 2c0e880709982dfbcb64b4bf983cbea1b66c3d1d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
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);
            }
 
        });
    });