2023西安数博会CIM演示-【前端】-Web
AdaKing88
2023-08-21 bc03b832caa49bbcd2674fe4cae3701b5059bf95
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
<template>
  <div class="main3dviewer" @mouseleave="removeEventListener()" @mouseover="addEventListener()"
    style="position: relative; width: 100%">
    <div class="rightbuttongroup" style="
                                  position: absolute;
                                  z-index: 990;
                                  top: 305px;
                                  right: 22px;
                                  width: 40px;
                                ">
      <div id="funcZone" style="display: flex; width:55px" @mouseleave="hidesubbutton()" @mouseover="showsubbutton()">
        <div class="divbtn" id="btnLD" style="display: none" @click="showPanel(3)">
          联动
        </div>
        <div id="btn2D" class="divbtn" style="display: none" @click="showPanel(2)">
          2D
        </div>
        <div class="divbtn" id="btn3D" style="display: inline-block; " @click="showPanel(1)">
          3D
        </div>
      </div>
      <div>
        <div class="divbtn" @click="showPanel(5)">交互</div>
      </div>
      <!-- <div>
        <div class="divbtn" @click="showPanel(6)">图层</div>
      </div> -->
      <div>
        <div class="divbtn" @click="showPanel(7)">场景</div>
      </div>
      <div>
        <div class="divbtn" @click="showPanel(8)">工具</div>
      </div>
      <div>
        <div class="divbtn" @click="showPanel(9)">分析</div>
      </div>
      <div>
        <div class="divbtn" @click="identifyInfo">属性</div>
      </div>
    </div>
 
 
    <sdkContainer style="position: absolute"> </sdkContainer>
    <div id="sectionCharts" class="sectionChars">
      <echartsview ref="echartsview" />
    </div>
 
    <IdentifyTool ref="IdentifyTool" />
  </div>
</template>
<script>
import sdkContainer from "../../../components/sgword/mapView.vue";
import IdentifyTool from './IdentifyTool.vue'
import identifyTool from '@/utils/identifyTools.js'
import echartsview from "./echartview.vue";
export default {
  props: {
    btnClick: {
      type: Function,
      default: null,
    },
  },
  components: { sdkContainer, echartsview, IdentifyTool },
  data() {
    return {
      btnTag: 0,
      is2D3Don: false,
      isDoubleOn: false,
      bimObj: null
    };
  },
  methods: {
    hidesubbutton() {
      $("#funcZone").css("width", "55px");
      $("#funcZone").css("margin-left", "0px");
      if (this.btnTag === 0) {
        $("#btn2D").css("display", "none");
        $("#btn3D").css("display", "inline-block");
        $("#btnLD").css("display", "none");
        // $("#btn3D").css("margin-left", "90px");
      } else if (this.btnTag === 1) {
        $("#btn2D").css("display", "inline-block");
        $("#btn3D").css("display", "none");
        $("#btnLD").css("display", "none");
        // $("#btn2D").css("margin-left", "90px");
      } else if (this.btnTag === 2) {
        $("#btn2D").css("display", "none");
        $("#btn3D").css("display", "none");
        $("#btnLD").css("display", "inline-block");
        // $("#btnLD").css("margin-left", "90px");
      }
    },
    showsubbutton() {
      $("#funcZone").css("width", "135px");
      $("#funcZone").css("margin-left", "-85px");
      $("#btn2D").css("display", "inline-block");
      $("#btn3D").css("display", "inline-block");
      $("#btnLD").css("display", "inline-block");
      $("#btn3D").css("margin-left", "");
      $("#btn2D").css("margin-left", "");
      $("#btnLD").css("margin-left", "");
      // if (this.btnTag === 0) {
      //   $("#btn3D").css("margin-left", "5px");
      //   $("#btn2D").css("margin-left", "80px");
      //   $("#btnLD").css("margin-left", "80px");
      // } else if (this.btnTag === 1) {
      //   $("#btn2D").css("margin-left", "5px");
      //   $("#btnLD").css("margin-left", "80px");
      //   $("#btn3D").css("margin-left", "80px");
      // } else if (this.btnTag === 2) {
      //   $("#btn3D").css("margin-left", "80px");
      //   $("#btnLD").css("margin-left", "5px");
      //   $("#btn2D").css("margin-left", "80px");
      // }
    },
    showPanel(tag) {
      if (this.btnClick)
        switch (tag) {
          case 1:
            Viewer.scene.morphTo3D();
            this.btnTag = 0;
            break;
          case 2:
            Viewer.scene.morphTo2D();
            this.btnTag = 1;
            break;
          case 3:
            this.btnTag = 2;
            this.is2D3Don = !this.is2D3Don;
            this.btnClick({
              title: "联动",
              id: tag,
              isOn: this.is2D3Don,
              showtag: "2d",
            });
            // this.$emit("btnClick", {
            //   title: "联动",
            //   id: tag,
            //   isOn: this.is2D3Don,
            // });
            break;
          case 4:
            break;
          case 5:
            this.btnClick({ title: "交互", id: tag });
            // this.$emit("btnClick", { title: "定位", id: tag });
            break;
          case 6:
            this.btnClick({ title: "图层", id: tag });
            // this.$emit("btnClick", { title: "图层", id: tag });
            break;
          case 7:
            this.btnClick({ title: "场景", id: tag });
            // this.$emit("btnClick", { title: "场景", id: tag });
            break;
          case 8:
            this.btnClick({ title: "工具", id: tag });
            // this.$emit("btnClick", { title: "工具", id: tag });
            break;
          case 9:
            this.btnClick({ title: "分析", id: tag });
            // this.$emit("btnClick", { title: "专题", id: tag });
            break;
          default:
            break;
        }
    },
    syncViewer(global1, global2) {
      global1.camera.flyTo({
        destination: global2.camera.position,
        orientation: {
          heading: global2.camera.heading,
          pitch: global2.camera.pitch,
          roll: global2.camera.roll,
        },
        duration: 0.0,
      });
    },
    start() {
      this.syncViewer(ViewerEx, Viewer);
    },
    removeEventListener() {
      if (this.isDoubleOn === true) {
        let that = this;
        this.$nextTick(() => {
          if (sgworld && sgworldEx) {
            console.log("out");
            Viewer.scene.preRender.removeEventListener(that.start);
          }
        });
      }
    },
    addEventListener() {
      //双球开启时,匹配双球监听
      if (this.isDoubleOn === true) {
        let that = this;
        this.$nextTick(() => {
          if (sgworld && sgworldEx) {
            Viewer.scene.preRender.addEventListener(that.start);
          }
        });
      }
    },
    initalEcharts(option) {
      let v = option.ison ? "visible" : "hidden";
      $("#sectionCharts").css("visibility", v);
      this.$refs.echartsview.initalEcharts(option.data);
    },
    identifyInfo() {
      identifyTool.start((pick, type) => {
        this.$refs.IdentifyTool.open(pick, type)
      })
    }
  },
  mounted() {
    let elementResizeDetectorMaker = require("element-resize-detector");
    let erd = elementResizeDetectorMaker();
    //侦听元素的调整大小事件,并使用元素作为调整大小事件的参数来调用侦听器函数。传递给函数的选项将
    //覆盖实例选项
    erd.listenTo(
      document.getElementsByClassName("main3dviewer"),
      function (element) {
        let height = element.offsetHeight;
        let isOn = height > 400 ? "" : "none";
        $(".rightbuttongroup").css("display", isOn);
      }
    );
  },
};
</script>
<style lang="less" scoped>
.divbtn {
  width: 30px;
  height: 30px;
  line-height: 30px;
  margin: 5px;
  background-color: rgba(49, 49, 49, 0.8);
  color: #bfbfbf;
  border: 1px solid #858585;
  text-align: center;
  cursor: pointer;
  font-size: 8px;
}
 
.divbtn:hover {
  border: 1px solid #dddddd;
}
 
.sectionChars {
  position: absolute;
  top: auto;
  width: 90%;
  height: 200px;
  bottom: 10px;
  left: 5%;
  padding: 10px 15px;
  border-radius: 4px;
  border: 1px solid rgba(128, 128, 128, 0.5);
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 3px 14px rgba(128, 128, 128, 0.5);
  z-index: 99999;
  visibility: hidden;
}
</style>