otherOptions.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <div class="sm-function-module-content" v-show="otherOptions">
  3. <div class="sm-function-module-sub-section">
  4. <label class="label-container">{{ Resource.viewMode }}</label>
  5. <select class="sm-select" v-model="viewMode">
  6. <option value="3D">3D</option>
  7. <option value="2.5D">2.5D</option>
  8. <option value="2D">2D</option>
  9. </select>
  10. </div>
  11. <div class="sm-function-module-sub-section">
  12. <label class="label-container">{{ Resource.multiViewport }}</label>
  13. <select class="sm-select" v-model="multiViewport">
  14. <option value="NONE">{{ Resource.onePort }}</option>
  15. <option value="HORIZONTAL">{{ Resource.horizontalSnap }}</option>
  16. <option value="VERTICAL">{{ Resource.verticalSnap }}</option>
  17. <option value="TRIPLE">{{ Resource.tripeSnap }}</option>
  18. <option value="QUAD">{{ Resource.quadSnap }}</option>
  19. </select>
  20. </div>
  21. <div class="sm-function-module-sub-section">
  22. <label class="label-container">{{ Resource.sceneFlood }}</label>
  23. <br />
  24. <div class="flexbox">
  25. <label class="sm-viewshed-label-right">{{
  26. Resource.openSceneFlood
  27. }}</label>
  28. <input type="checkbox" v-model="openSceneFlood" />
  29. <div style="width: 45%"></div>
  30. </div>
  31. <div class="sm-function-module-sub-section">
  32. <label class="label-container">{{ Resource.threshold }}</label>
  33. <input
  34. class="sm-input-long"
  35. min="0"
  36. max="1"
  37. step="0.01"
  38. type="number"
  39. v-model="threshold"
  40. />
  41. </div>
  42. <div class="sm-function-module-sub-section">
  43. <label class="label-container">{{ Resource.bloomIntensity }}</label>
  44. <input
  45. class="sm-input-long"
  46. min="0"
  47. max="10"
  48. step="0.5"
  49. type="number"
  50. v-model="bloomIntensity"
  51. />
  52. </div>
  53. </div>
  54. <label class="label-container">{{ Resource.split }}</label>
  55. <div class="flexbox">
  56. <label class="sm-viewshed-label-right">{{ Resource.useRoller }}</label>
  57. <input type="checkbox" v-model="useRoller" />
  58. <label class="sm-viewshed-label-right">{{
  59. Resource.imageryRoller
  60. }}</label>
  61. <input type="checkbox" v-model="imageryRoller" />
  62. </div>
  63. <div class="sm-function-module-sub-section flexbox">
  64. <label class="label-container rollerLaber" for="lrRoller">{{
  65. Resource.lrRoller
  66. }}</label>
  67. <input
  68. type="radio"
  69. name="lrtbRoller"
  70. id="lrRoller"
  71. value="lrRoller"
  72. v-model="lrtbRoller"
  73. />
  74. <label class="label-container rollerLaber" for="tbRoller">{{
  75. Resource.tbRoller
  76. }}</label>
  77. <input
  78. type="radio"
  79. name="lrtbRoller"
  80. id="tbRoller"
  81. value="tbRoller"
  82. v-model="lrtbRoller"
  83. />
  84. </div>
  85. <div
  86. class="sm-function-module-sub-section flexbox"
  87. v-show="lrtbRoller == 'lrRoller'"
  88. >
  89. <label class="label-container rollerLaber" for="leftRoller">{{
  90. Resource.leftRoller
  91. }}</label>
  92. <input
  93. type="radio"
  94. name="lrRoller"
  95. id="leftRoller"
  96. value="leftRoller"
  97. v-model="lrRoller"
  98. />
  99. <label class="label-container rollerLaber" for="rightRoller">{{
  100. Resource.rightRoller
  101. }}</label>
  102. <input
  103. type="radio"
  104. name="lrRoller"
  105. id="rightRoller"
  106. value="rightRoller"
  107. v-model="lrRoller"
  108. />
  109. </div>
  110. <div
  111. class="sm-function-module-sub-section flexbox"
  112. v-show="lrtbRoller == 'tbRoller'"
  113. >
  114. <label class="label-container rollerLaber" for="topRoller">{{
  115. Resource.topRoller
  116. }}</label>
  117. <input
  118. type="radio"
  119. name="tbRoller"
  120. id="topRoller"
  121. value="topRoller"
  122. v-model="tbRoller"
  123. />
  124. <label class="label-container rollerLaber" for="bomRoller">{{
  125. Resource.bottomRoller
  126. }}</label>
  127. <input
  128. type="radio"
  129. name="tbRoller"
  130. id="bomRoller"
  131. value="bomRoller"
  132. v-model="tbRoller"
  133. />
  134. </div>
  135. </div>
  136. </template>
  137. <script>
  138. let rollerShutterConfig;
  139. import { setImageryRoller,hideImageryRoller } from "@/utils/MapHelper/map.js";
  140. export default {
  141. name: "sceneOtherOptions",
  142. data() {
  143. return {
  144. sharedState: store.state,
  145. isDestroyFlag: true,
  146. viewMode: "3D",
  147. multiViewport: "NONE",
  148. openSceneFlood: false,
  149. threshold: 0.6,
  150. bloomIntensity: 2.0,
  151. useRoller: false,
  152. imageryRoller: false,
  153. lrtbRoller: "lrRoller",
  154. lrRoller: "leftRoller",
  155. tbRoller: "topRoller",
  156. };
  157. },
  158. computed: {
  159. otherOptions: function () {
  160. return this.sharedState.sceneAtttribute[4];
  161. },
  162. SceneAtttributeShow: function () {
  163. return this.sharedState.toolBar[3];
  164. },
  165. },
  166. beforeDestroy() {
  167. // if (this.isDestroyFlag && camera) {
  168. // camera = undefined;
  169. // if (flyCircleDrawHandler) {
  170. // // flyCircleDrawHandler.destroy();
  171. // flyCircleDrawHandler = undefined;
  172. // }
  173. // if (flyManager) {
  174. // flyManager.destroy();
  175. // flyManager = this.undefined;
  176. // }
  177. // }
  178. },
  179. mounted() {
  180. if (this.SceneAtttributeShow && this.otherOptions) {
  181. this.init();
  182. }
  183. this.multiViewport = store.state.splitType;
  184. this.bus.$on("setImageryRoller", this.setImageryRollers);
  185. },
  186. methods: {
  187. //子组件部分
  188. init() {
  189. if (rollerShutterConfig) {
  190. return;
  191. }
  192. let windowWidth = document.body.clientWidth; // 窗口宽度
  193. let windowHeight = document.body.clientHeight; // 窗口高度
  194. // 卷帘配置参数,以对象方式实现地址传递
  195. rollerShutterConfig = {
  196. splitDirection: Cesium.SplitDirection.NONE,
  197. verticalSplitPosition: windowWidth / 2,
  198. horizontalSplitPosition: windowHeight / 2,
  199. };
  200. if (!document.getElementById("verticalSlider")) {
  201. let f = document.getElementById("cesiumContainer");
  202. let v = document.createElement("div");
  203. let h = document.createElement("div");
  204. v.classList.add("verticalSlider");
  205. v.id = "verticalSlider";
  206. h.id = "horizontalSlider";
  207. v.style.display = "none";
  208. h.style.display = "none";
  209. f.appendChild(v);
  210. f.appendChild(h);
  211. }
  212. this.setRollerShutterSplit();
  213. this.bindSliderEvt();
  214. },
  215. /**
  216. * 设置卷帘的分割方向及分割条的位置。
  217. *
  218. */
  219. setRollerShutterSplit() {
  220. let splitPosition = null;
  221. if (
  222. rollerShutterConfig.splitDirection === Cesium.SplitDirection.LEFT ||
  223. rollerShutterConfig.splitDirection === Cesium.SplitDirection.RIGHT
  224. ) {
  225. splitPosition = rollerShutterConfig.verticalSplitPosition;
  226. viewer.scene.imagerySplitPosition.x =
  227. rollerShutterConfig.verticalSplitPosition / document.body.clientWidth;
  228. } else if (
  229. rollerShutterConfig.splitDirection === Cesium.SplitDirection.TOP ||
  230. rollerShutterConfig.splitDirection === Cesium.SplitDirection.BOTTOM
  231. ) {
  232. splitPosition = rollerShutterConfig.horizontalSplitPosition;
  233. viewer.scene.imagerySplitPosition.y =
  234. rollerShutterConfig.horizontalSplitPosition /
  235. document.body.clientHeight;
  236. }
  237. for (let layer of scene.layers.layerQueue) {
  238. layer.splitDirection = rollerShutterConfig.splitDirection;
  239. if (splitPosition) {
  240. // 如果禁用卷帘就没有必要设置分割位置
  241. layer.splitPosition = splitPosition;
  242. }
  243. }
  244. },
  245. setImageryRollerMode: function () {
  246. store.setrollerType(rollerShutterConfig.splitDirection);
  247. // let imageryLayers = viewer.imageryLayers;
  248. // for (let i = 0; i < imageryLayers.length; i++) {
  249. // let imageryLayer = imageryLayers.get(i);
  250. // if (this.imageryRoller) this.setImageryRoller(imageryLayer)
  251. // else this.hideImageryRoller(imageryLayer)
  252. // }
  253. //案例展示
  254. let imageryLayer = viewer.imageryLayers.get(1);
  255. if (this.imageryRoller) setImageryRoller(imageryLayer,rollerShutterConfig);
  256. else hideImageryRoller(imageryLayer);
  257. },
  258. setImageryRollers(imageryLayer) {
  259. if (this.imageryRoller) setImageryRoller(imageryLayer,rollerShutterConfig);
  260. else hideImageryRoller(imageryLayer);
  261. },
  262. /**
  263. * 注册卷帘分割条的拖拽事件。
  264. */
  265. bindSliderEvt: function () {
  266. let verticalSlider = document.getElementById("verticalSlider");
  267. let horizontalSlider = document.getElementById("horizontalSlider");
  268. verticalSlider.addEventListener("mousedown", mouseDown, false);
  269. horizontalSlider.addEventListener("mousedown", mouseDown, false);
  270. let windowHeight = document.body.clientHeight;
  271. let me = this;
  272. document.addEventListener("mouseup", mouseUp, false);
  273. function mouseUp(e) {
  274. document.removeEventListener("mousemove", sliderMove, false);
  275. }
  276. function mouseDown(e) {
  277. document.addEventListener("mousemove", sliderMove, false);
  278. }
  279. function sliderMove(e) {
  280. // 鼠标拖拽时执行
  281. // 解决拖拽鼠标粘滞的问题
  282. if (e.preventDefault) {
  283. e.preventDefault();
  284. } else {
  285. e.returnValue = false;
  286. }
  287. if (
  288. rollerShutterConfig.splitDirection === Cesium.SplitDirection.LEFT ||
  289. rollerShutterConfig.splitDirection === Cesium.SplitDirection.RIGHT
  290. ) {
  291. verticalSlider.style.left = e.clientX + "px";
  292. rollerShutterConfig.verticalSplitPosition = e.clientX;
  293. } else if (
  294. rollerShutterConfig.splitDirection === Cesium.SplitDirection.TOP ||
  295. rollerShutterConfig.splitDirection === Cesium.SplitDirection.BOTTOM
  296. ) {
  297. let clientY = e.clientY;
  298. if (clientY < 0) {
  299. clientY = 0;
  300. } else if (clientY > windowHeight) {
  301. clientY = windowHeight - document.body.clientHeight;
  302. }
  303. horizontalSlider.style.top = clientY + "px";
  304. rollerShutterConfig.horizontalSplitPosition = windowHeight - clientY;
  305. }
  306. me.setRollerShutterSplit();
  307. }
  308. },
  309. // 更新卷帘
  310. updataLrRoller() {
  311. switch (this.lrRoller) {
  312. case "leftRoller":
  313. rollerShutterConfig.splitDirection = Cesium.SplitDirection.LEFT;
  314. break;
  315. case "rightRoller":
  316. rollerShutterConfig.splitDirection = Cesium.SplitDirection.RIGHT;
  317. break;
  318. default:
  319. break;
  320. }
  321. this.setImageryRollerMode();
  322. this.setRollerShutterSplit();
  323. },
  324. updaeTbRoller() {
  325. switch (this.tbRoller) {
  326. case "topRoller":
  327. rollerShutterConfig.splitDirection = Cesium.SplitDirection.TOP;
  328. break;
  329. case "bomRoller":
  330. rollerShutterConfig.splitDirection = Cesium.SplitDirection.BOTTOM;
  331. break;
  332. default:
  333. break;
  334. }
  335. this.setImageryRollerMode();
  336. this.setRollerShutterSplit();
  337. },
  338. },
  339. watch: {
  340. otherOptions(val) {
  341. if (val) {
  342. this.init();
  343. }
  344. },
  345. viewMode(value) {
  346. if (value === "2D") {
  347. viewer.scene.mode = Cesium.SceneMode.SCENE2D;
  348. } else if (value === "3D") {
  349. viewer.scene.mode = Cesium.SceneMode.SCENE3D;
  350. } else if (value === "2.5D") {
  351. viewer.scene.mode = Cesium.SceneMode.COLUMBUS_VIEW;
  352. }
  353. },
  354. multiViewport(value) {
  355. scene.multiViewportMode = Cesium.MultiViewportMode[value];
  356. store.setsplitType(value);
  357. },
  358. openSceneFlood(val) {
  359. viewer.scene.bloomEffect.show = val;
  360. viewer.scene.hdrEnabled = val;
  361. viewer.scene.toneMappingEnabled = val;
  362. viewer.scene.bloomEffect.threshold = Number(this.threshold);
  363. viewer.scene.bloomEffect.bloomIntensity = Number(this.bloomIntensity);
  364. },
  365. threshold(val) {
  366. viewer.scene.bloomEffect.threshold = Number(val);
  367. },
  368. bloomIntensity(val) {
  369. viewer.scene.bloomEffect.bloomIntensity = Number(val);
  370. },
  371. useRoller(val) {
  372. let verticalSlider = document.getElementById("verticalSlider");
  373. let horizontalSlider = document.getElementById("horizontalSlider");
  374. if (val) {
  375. switch (this.lrtbRoller) {
  376. case "lrRoller":
  377. verticalSlider.style.display = "block";
  378. horizontalSlider.style.display = "none";
  379. this.updataLrRoller();
  380. break;
  381. case "tbRoller":
  382. verticalSlider.style.display = "none";
  383. horizontalSlider.style.display = "block";
  384. this.updaeTbRoller();
  385. break;
  386. default:
  387. break;
  388. }
  389. } else {
  390. rollerShutterConfig.splitDirection = Cesium.SplitDirection.NONE;
  391. verticalSlider.style.display = "none";
  392. horizontalSlider.style.display = "none";
  393. this.setImageryRollerMode();
  394. this.setRollerShutterSplit();
  395. }
  396. },
  397. imageryRoller(val) {
  398. this.setImageryRollerMode();
  399. // this.setRollerShutterSplit();
  400. },
  401. lrtbRoller(val) {
  402. let verticalSlider = document.getElementById("verticalSlider");
  403. let horizontalSlider = document.getElementById("horizontalSlider");
  404. switch (val) {
  405. case "lrRoller":
  406. verticalSlider.style.display = "block";
  407. horizontalSlider.style.display = "none";
  408. this.updataLrRoller();
  409. break;
  410. case "tbRoller":
  411. verticalSlider.style.display = "none";
  412. horizontalSlider.style.display = "block";
  413. this.updaeTbRoller();
  414. break;
  415. default:
  416. break;
  417. }
  418. },
  419. lrRoller(val) {
  420. this.updataLrRoller();
  421. },
  422. tbRoller(val) {
  423. this.updaeTbRoller();
  424. },
  425. },
  426. };
  427. </script>
  428. <style lang="scss" scoped>
  429. @import "otherOptions";
  430. </style>