@abi-software/scaffoldvuer 0.1.53 → 0.1.54-beta-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -354,7 +354,7 @@ export default {
354
354
  */
355
355
  displayMarkers: {
356
356
  type: Boolean,
357
- default: true
357
+ default: false
358
358
  },
359
359
  /**
360
360
  * Show/hide minimap.
@@ -363,6 +363,13 @@ export default {
363
363
  type: Boolean,
364
364
  default: false
365
365
  },
366
+ /**
367
+ * Format of the input URL
368
+ */
369
+ format: {
370
+ type: String,
371
+ default: "metadata"
372
+ },
366
373
  /**
367
374
  * Settings for minimap position, size and alignment.
368
375
  */
@@ -473,10 +480,17 @@ export default {
473
480
  visible: false,
474
481
  x: 200,
475
482
  y: 200
476
- }
483
+ },
484
+ fileFormat: "metadata",
477
485
  };
478
486
  },
479
487
  watch: {
488
+ format: {
489
+ handler: function(value) {
490
+ this.fileFormat = value;
491
+ },
492
+ immediate: true
493
+ },
480
494
  url: {
481
495
  handler: function(newValue) {
482
496
  if (this.state === undefined || this.state.url === undefined)
@@ -508,6 +522,8 @@ export default {
508
522
  },
509
523
  displayMarkers: function(val) {
510
524
  this.$module.scene.displayMarkers = val;
525
+ //Update pickable objects
526
+ this.$module.scene.forcePickableObjectsUpdate = true;
511
527
  },
512
528
  displayMinimap: function(val) {
513
529
  this.$module.scene.displayMinimap = val;
@@ -685,6 +701,7 @@ export default {
685
701
  viewRegion: function(names) {
686
702
  const rootRegion = this.$module.scene.getRootRegion();
687
703
  const groups = Array.isArray(names) ? names : [names];
704
+ const dist = this.$module.scene.camera.far - this.$module.scene.camera.near;
688
705
  const objects = findObjectsWithNames(rootRegion, groups, "");
689
706
  let box = this.$module.scene.getBoundingBoxOfZincObjects(objects);
690
707
  if (box) {
@@ -692,6 +709,7 @@ export default {
692
709
  this.$module.setSyncControlZoomToBox(box);
693
710
  } else {
694
711
  this.$module.scene.viewAllWithBoundingBox(box);
712
+ this.$module.scene.camera.far = this.$module.scene.camera.near + dist;
695
713
  }
696
714
  return true;
697
715
  }
@@ -747,6 +765,7 @@ export default {
747
765
  */
748
766
  eventNotifierCallback: function(event) {
749
767
  const names = [];
768
+ let zincObjects = [];
750
769
  const region = undefined;
751
770
  if (event.eventType == 1 || event.eventType == 2) {
752
771
  event.identifiers.forEach(identifier => {
@@ -757,13 +776,15 @@ export default {
757
776
  names.push(id);
758
777
  }
759
778
  });
779
+ zincObjects = event.zincObjects;
760
780
  }
761
781
  if (event.eventType == 1) {
762
782
  if (this.$refs.treeControl) {
763
783
  if (names.length > 0) {
764
- this.$refs.treeControl.changeActiveByNames(names, region, false);
784
+ //this.$refs.treeControl.changeActiveByNames(names, region, false);
785
+ this.$refs.treeControl.updateActiveUI(zincObjects);
765
786
  } else {
766
- this.$refs.treeControl.removeActive(true);
787
+ this.$refs.treeControl.removeActive(true)
767
788
  }
768
789
  }
769
790
  // Triggers when an object has been selected
@@ -773,7 +794,8 @@ export default {
773
794
  // const offsets = this.$refs.scaffoldContainer.getBoundingClientRect();
774
795
  if (this.$refs.treeControl) {
775
796
  if (names.length > 0) {
776
- this.$refs.treeControl.changeHoverByNames(names, region, false);
797
+ //this.$refs.treeControl.changeHoverByNames(names, region, false);
798
+ this.$refs.treeControl.updateHoverUI(zincObjects);
777
799
  } else {
778
800
  this.$refs.treeControl.removeHover(true);
779
801
  }
@@ -989,9 +1011,10 @@ export default {
989
1011
  */
990
1012
  getState: function() {
991
1013
  let state = {
1014
+ format: this.fileFormat,
992
1015
  url: this._currentURL,
993
1016
  viewport: undefined,
994
- visibility: undefined
1017
+ visibility: undefined,
995
1018
  };
996
1019
  if (this.$refs.treeControl)
997
1020
  state.visibility = this.$refs.treeControl.getState();
@@ -1011,6 +1034,7 @@ export default {
1011
1034
  if (state) {
1012
1035
  if (state.url && state.url !== this._currentURL) {
1013
1036
  this.setURLAndState(state.url, {
1037
+ fileFormat: state.fileFormat,
1014
1038
  viewport: state.viewport,
1015
1039
  visibility: state.visibility
1016
1040
  });
@@ -1047,6 +1071,7 @@ export default {
1047
1071
  */
1048
1072
  setURLAndState: function(newValue, state) {
1049
1073
  if (newValue != this._currentURL) {
1074
+ if (state && state.format) this.fileFormat = state.format;
1050
1075
  let viewport = state && state.viewport ? state.viewport : undefined;
1051
1076
  let visibility =
1052
1077
  state && state.visibility ? state.visibility : undefined;
@@ -1063,14 +1088,20 @@ export default {
1063
1088
  visibility: visibility
1064
1089
  })
1065
1090
  );
1066
- this.$module.loadOrgansFromURL(
1067
- newValue,
1068
- undefined,
1069
- undefined,
1070
- "scene",
1071
- undefined
1072
- );
1091
+ if (this.fileFormat === "gltf") {
1092
+ this.$module.loadGLTFFromURL(newValue, "scene", true);
1093
+ } else {
1094
+ this.$module.loadOrgansFromURL(
1095
+ newValue,
1096
+ undefined,
1097
+ undefined,
1098
+ "scene",
1099
+ undefined,
1100
+ true
1101
+ );
1102
+ }
1073
1103
  this.$module.scene.displayMarkers = this.displayMarkers;
1104
+ this.$module.scene.forcePickableObjectsUpdate = true;
1074
1105
  this.$module.scene.displayMinimap = this.displayMinimap;
1075
1106
  this.updateMinimapScissor();
1076
1107
  }
@@ -1086,7 +1117,6 @@ export default {
1086
1117
  },
1087
1118
  /**
1088
1119
  * Callback when drawer is toggled.
1089
- *
1090
1120
  */
1091
1121
  drawerToggled: function(flag) {
1092
1122
  this.drawerOpen = flag;
@@ -0,0 +1,544 @@
1
+ <template>
2
+ <div
3
+ class="traditional-location"
4
+ :class="{ open: drawerOpen, close: !drawerOpen }"
5
+ >
6
+ <div class="traditional-container">
7
+ <el-row>
8
+ <el-col :span="12">
9
+ <div class="regions-display-text">
10
+ Regions
11
+ </div>
12
+ </el-col>
13
+ <el-col :span="12">
14
+ <el-checkbox
15
+ v-model="checkAll"
16
+ class="all-checkbox"
17
+ :indeterminate="isIndeterminate"
18
+ @change="handleCheckAllChange"
19
+ >
20
+ Display all
21
+ </el-checkbox>
22
+ </el-col>
23
+ </el-row>
24
+ <el-checkbox-group
25
+ v-model="checkedItems"
26
+ size="small"
27
+ class="checkbox-group"
28
+ @change="handleCheckedItemsChange"
29
+ >
30
+ <div class="checkbox-group-inner">
31
+ <el-row
32
+ v-for="item in sortedPrimitiveGroups"
33
+ :key="item"
34
+ :label="item"
35
+ >
36
+ <div class="checkbox-container">
37
+ <el-checkbox
38
+ class="my-checkbox"
39
+ :label="item"
40
+ :checked="true"
41
+ :class="{ activeItem: activeRegion === item,
42
+ hoverItem: hoverRegion === item }"
43
+ @click.native="itemClicked(item, $event)"
44
+ @change="visibilityToggle(item, $event)"
45
+ @mouseover.native="checkboxHover(item)"
46
+ >
47
+ <el-color-picker
48
+ :class="{ 'show-picker' : showColourPicker }"
49
+ :value="getColour(item)"
50
+ size="small"
51
+ :popper-class="myPopperClass"
52
+ @change="setColour(item, $event)"
53
+ />
54
+ {{ item }}
55
+ </el-checkbox>
56
+ </div>
57
+ </el-row>
58
+ </div>
59
+ </el-checkbox-group>
60
+ </div>
61
+ <div
62
+ class="drawer-button"
63
+ :class="{ open: drawerOpen, close: !drawerOpen }"
64
+ @click="toggleDrawer"
65
+ >
66
+ <i class="el-icon-arrow-left" />
67
+ </div>
68
+ </div>
69
+ </template>
70
+
71
+ <script>
72
+ /* eslint-disable no-alert, no-console */
73
+ import Vue from "vue";
74
+ import { Checkbox, CheckboxGroup, ColorPicker, Row } from "element-ui";
75
+ import lang from "element-ui/lib/locale/lang/en";
76
+ import locale from "element-ui/lib/locale";
77
+
78
+ const orderBy = require("lodash/orderBy");
79
+ const uniq = require("lodash/uniq");
80
+ locale.use(lang);
81
+ Vue.use(Checkbox);
82
+ Vue.use(CheckboxGroup);
83
+ Vue.use(ColorPicker);
84
+ Vue.use(Row);
85
+
86
+ /**
87
+ * A vue component for toggling visibility of various regions.
88
+ */
89
+ export default {
90
+ name: "TraditionalControls",
91
+ props: {
92
+ /**
93
+ * @ignore
94
+ */
95
+ module: {
96
+ type: Object,
97
+ default: undefined
98
+ },
99
+ /**
100
+ * Enable/disable colour picker
101
+ */
102
+ showColourPicker: Boolean
103
+ },
104
+ data: function() {
105
+ return {
106
+ checkAll: true,
107
+ isIndeterminate: false,
108
+ checkedItems: [],
109
+ sortedPrimitiveGroups: [],
110
+ activeRegion: "",
111
+ hoverRegion: "",
112
+ myPopperClass: "hide-scaffold-colour-popup",
113
+ drawerOpen: true
114
+ };
115
+ },
116
+ watch: {
117
+ showColourPicker: {
118
+ immediate: true,
119
+ handler: function() {
120
+ if (this.showColourPicker) this.myPopperClass = "showPicker";
121
+ else this.myPopperClass = "hide-scaffold-colour-popup";
122
+ }
123
+ }
124
+ },
125
+ created: function() {
126
+ let tmpArray = this.module.sceneData.geometries.concat(
127
+ this.module.sceneData.lines
128
+ );
129
+ tmpArray = tmpArray.concat(this.module.sceneData.glyphsets);
130
+ tmpArray = uniq(tmpArray.concat(this.module.sceneData.pointset));
131
+ this.sortedPrimitiveGroups = orderBy(tmpArray);
132
+ this.module.addOrganPartAddedCallback(this.organsAdded);
133
+ },
134
+ destroyed: function() {
135
+ this.sortedPrimitiveGroups = undefined;
136
+ },
137
+ methods: {
138
+ /**
139
+ * This is called when a new organ is read into the scene.
140
+ */
141
+ organsAdded: function(name) {
142
+ if (name && name != "") {
143
+ let tmpArray = uniq(this.sortedPrimitiveGroups.concat([name]));
144
+ tmpArray = orderBy(tmpArray);
145
+ const index = tmpArray.indexOf(undefined);
146
+ if (index > -1) {
147
+ tmpArray.splice(index, 1);
148
+ }
149
+ this.sortedPrimitiveGroups = tmpArray;
150
+ }
151
+ },
152
+ /**
153
+ * Select a region by its name.
154
+ */
155
+ changeActiveByNames: function(names, propagate) {
156
+ let targetObject = this.getFirstZincObjectWithGroupName(name);
157
+ if (targetObject && targetObject.getVisibility()) {
158
+ this.activeRegion = name;
159
+ this.$emit("object-selected", targetObject, propagate);
160
+ } else {
161
+ this.removeActive(propagate);
162
+ }
163
+ this.removeHover(propagate);
164
+ },
165
+ /**
166
+ * Hover a region by its name.
167
+ */
168
+ changeHoverByName: function(name, propagate) {
169
+ let targetObject = this.getFirstZincObjectWithGroupName(name);
170
+ if (targetObject) {
171
+ this.hoverRegion = name;
172
+ this.$emit("object-hovered", targetObject, propagate);
173
+ } else {
174
+ this.removeHover(propagate);
175
+ }
176
+ },
177
+ /**
178
+ * Unselect the current selected region.
179
+ */
180
+ removeActive: function(propagate) {
181
+ this.activeRegion = "";
182
+ this.$emit("object-selected", undefined, propagate);
183
+ },
184
+ /**
185
+ * Unselect the current hover region.
186
+ */
187
+ removeHover: function(propagate) {
188
+ this.hoverRegion = "";
189
+ this.$emit("object-hovered", undefined, propagate);
190
+ },
191
+ /**
192
+ * Reset the controls.
193
+ */
194
+ clear: function() {
195
+ this.sortedPrimitiveGroups = [];
196
+ this.checkedItems = [];
197
+ this.checkAll = true;
198
+ this.isIndeterminate = false;
199
+ this.activeRegion = "";
200
+ this.hoverRegion = "";
201
+ this.$emit("object-selected", undefined);
202
+ },
203
+ getFirstZincObjectWithGroupName: function(name) {
204
+ if (this.module && this.module.scene) {
205
+ let array = this.module.scene.findGeometriesWithGroupName(name);
206
+ if (array.length > 0) return array[0];
207
+ array = this.module.scene.findGlyphsetsWithGroupName(name);
208
+ if (array.length > 0) return array[0];
209
+ array = this.module.scene.findLinesWithGroupName(name);
210
+ if (array.length > 0) return array[0];
211
+ array = this.module.scene.findPointsetsWithGroupName(name);
212
+ if (array.length > 0) return array[0];
213
+ }
214
+ return undefined;
215
+ },
216
+ getColour: function(name) {
217
+ let graphic = this.getFirstZincObjectWithGroupName(name);
218
+ if (graphic) {
219
+ let hex = graphic.getColourHex();
220
+ if (hex) return "#" + hex;
221
+ }
222
+ return "#FFFFFF";
223
+ },
224
+ setColour: function(name, value) {
225
+ let graphic = this.getFirstZincObjectWithGroupName(name);
226
+ if (graphic) {
227
+ let hexString = value.replace("#", "0x");
228
+ graphic.setColourHex(hexString);
229
+ }
230
+ },
231
+ checkboxHover: function(name) {
232
+ this.changeHoverByName(name, true);
233
+ },
234
+ itemClicked: function(name, event) {
235
+ if (
236
+ !(
237
+ event.target.classList.contains("el-checkbox__inner") ||
238
+ event.target.classList.contains("el-checkbox__original")
239
+ )
240
+ ) {
241
+ this.changeActiveByNames([name], true);
242
+ event.preventDefault();
243
+ }
244
+ },
245
+ handleCheckedItemsChange: function() {
246
+ let unnamed = this.checkedItems.includes(undefined) ? true: false;
247
+ let checkedCount = this.checkedItems.length;
248
+ if (unnamed)
249
+ checkedCount--;
250
+ this.checkAll = checkedCount === this.sortedPrimitiveGroups.length;
251
+ this.isIndeterminate =
252
+ checkedCount > 0 && checkedCount < this.sortedPrimitiveGroups.length;
253
+ },
254
+ handleCheckAllChange(val) {
255
+ this.checkedItems = val ? [...this.sortedPrimitiveGroups] : [];
256
+ this.isIndeterminate = false;
257
+ for (let i = 0; i < this.sortedPrimitiveGroups.length; i++) {
258
+ this.visibilityToggle(this.sortedPrimitiveGroups[i], this.checkAll);
259
+ }
260
+ },
261
+ viewAll: function() {
262
+ this.module.viewAll();
263
+ },
264
+ visibilityToggle: function(item, event) {
265
+ this.module.changeOrganPartsVisibility(item, event);
266
+ if (event == false) {
267
+ if (this.activeRegion === item) {
268
+ this.removeActive(true);
269
+ }
270
+ if (this.hoverRegion === item) {
271
+ this.removeHover(true);
272
+ }
273
+ }
274
+ },
275
+ toggleDrawer: function() {
276
+ this.drawerOpen = !this.drawerOpen;
277
+ this.$emit("drawer-toggled", this.drawerOpen);
278
+ },
279
+ getState: function() {
280
+ if (this.checkAll) {
281
+ return { checkAll: true };
282
+ }
283
+ let checkedItems = [...this.checkedItems];
284
+ const index = checkedItems.indexOf(undefined);
285
+ if (index > -1) {
286
+ checkedItems.splice(index, 1);
287
+ }
288
+ return { checkedItems: checkedItems };
289
+ },
290
+ setState: function(state) {
291
+ if (state) {
292
+ if (state.checkAll) {
293
+ this.checkedItems = [...this.sortedPrimitiveGroups];
294
+ for (let i = 0; i < this.sortedPrimitiveGroups.length; i++) {
295
+ this.module.changeOrganPartsVisibility(
296
+ this.sortedPrimitiveGroups[i],
297
+ true
298
+ );
299
+ }
300
+ } else if (state.checkedItems) {
301
+ this.checkedItems = [...state.checkedItems];
302
+ for (let i = 0; i < this.sortedPrimitiveGroups.length; i++) {
303
+ let visible = this.checkedItems.includes(
304
+ this.sortedPrimitiveGroups[i]);
305
+ this.module.changeOrganPartsVisibility(
306
+ this.sortedPrimitiveGroups[i],
307
+ visible
308
+ );
309
+ }
310
+ }
311
+ }
312
+ this.handleCheckedItemsChange();
313
+ }
314
+ }
315
+ };
316
+ </script>
317
+
318
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
319
+ <style scoped lang="scss">
320
+ @import "~element-ui/packages/theme-chalk/src/checkbox";
321
+ @import "~element-ui/packages/theme-chalk/src/checkbox-group";
322
+ @import "~element-ui/packages/theme-chalk/src/color-picker";
323
+ @import "~element-ui/packages/theme-chalk/src/row";
324
+
325
+ .checkbox-container {
326
+ display: flex;
327
+ cursor: pointer;
328
+ }
329
+
330
+ .traditional-location {
331
+ position: absolute;
332
+ bottom: 0px;
333
+ transition: all 1s ease;
334
+
335
+ &:focus{
336
+ outline: none;
337
+ }
338
+ &.open {
339
+ left: 0px;
340
+ .traditional-container {
341
+ opacity: 1;
342
+ }
343
+ }
344
+ &.close {
345
+ left: -298px;
346
+ .traditional-container {
347
+ pointer-events:none;
348
+ opacity: 0;
349
+ }
350
+ }
351
+ }
352
+
353
+ .traditional-container {
354
+ transition: all 1s ease;
355
+ float: left;
356
+ padding-left: 16px;
357
+ padding-right: 18px;
358
+ max-height: calc(100% - 154px);
359
+ text-align: left;
360
+ overflow: none;
361
+ border: 1px solid rgb(220, 223, 230);
362
+ padding-top: 7px;
363
+ padding-bottom: 16px;
364
+ background: #ffffff;
365
+ }
366
+
367
+ .regions-display-text {
368
+ width: 59px;
369
+ height: 20px;
370
+ color: rgb(48, 49, 51);
371
+ font-size: 14px;
372
+ font-weight: normal;
373
+ line-height: 20px;
374
+ margin-left: 8px;
375
+ }
376
+
377
+ .all-checkbox {
378
+ float: right;
379
+ }
380
+
381
+ .checkbox-group {
382
+ width: 260px;
383
+ border: 1px solid rgb(144, 147, 153);
384
+ border-radius: 4px;
385
+ background: #ffffff;
386
+ margin-top: 6px;
387
+ }
388
+
389
+ .checkbox-group-inner {
390
+ padding: 18px;
391
+ max-height: 240px;
392
+ min-height: 130px;
393
+ overflow: auto;
394
+ scrollbar-color: #c0c4cc rgba(1, 1, 1, 0);
395
+ scrollbar-width: thin;
396
+
397
+ &::-webkit-scrollbar {
398
+ width: 4px;
399
+ }
400
+
401
+ &::-webkit-scrollbar-thumb {
402
+ border-radius: 10px;
403
+ box-shadow: inset 0 0 6px #c0c4cc;
404
+ }
405
+ }
406
+
407
+ ::v-deep .el-checkbox__input {
408
+ &.is-indeterminate, &.is-checked {
409
+ .el-checkbox__inner {
410
+ background-color: $app-primary-color;
411
+ border-color: $app-primary-color;
412
+ }
413
+ }
414
+ }
415
+
416
+ ::v-deep .el-color-picker__color {
417
+ border: 1px solid $app-primary-color;
418
+ }
419
+
420
+ ::v-deep .el-checkbox__label {
421
+ padding-left: 5px;
422
+ color: $app-primary-color !important;
423
+ font-size: 12px;
424
+ font-weight: 500;
425
+ letter-spacing: 0px;
426
+ line-height: 14px;
427
+ }
428
+
429
+ .activeItem {
430
+ background-color: #bbb !important;
431
+ }
432
+
433
+ .my-checkbox {
434
+ background-color: #fff;
435
+ width: 100%;
436
+
437
+ ::v-deep .el-color-picker {
438
+ height: 16px !important;
439
+ top: 3px;
440
+ }
441
+
442
+ ::v-deep .el-color-picker__trigger {
443
+ margin-left: 8px;
444
+ margin-right: 8px;
445
+ padding: 0px;
446
+ height: 16px;
447
+ width: 16px;
448
+ border: 0px;
449
+ }
450
+
451
+ }
452
+
453
+ .hoverItem {
454
+ background-color: #eee !important;
455
+ }
456
+
457
+ ::v-deep .el-color-picker__icon {
458
+ &.el-icon-arrow-down {
459
+ display: none;
460
+ }
461
+ }
462
+
463
+ ::v-deep .show-picker {
464
+ .el-color-picker__icon {
465
+ &.el-icon-arrow-down {
466
+ display: block;
467
+ }
468
+ }
469
+ }
470
+
471
+ ::v-deep .my-drawer {
472
+ background: rgba(0, 0, 0, 0);
473
+ box-shadow: none;
474
+ }
475
+
476
+ .drawer {
477
+ ::v-deep .el-drawer:focus {
478
+ outline: none;
479
+ }
480
+ }
481
+
482
+ .open-drawer {
483
+ width: 20px;
484
+ height: 40px;
485
+ z-index: 8;
486
+ position: absolute;
487
+ left: 0px;
488
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
489
+ border: solid 1px #e4e7ed;
490
+ background-color: #f7faff;
491
+ text-align: center;
492
+ vertical-align: middle;
493
+ cursor: pointer;
494
+ pointer-events: auto;
495
+ }
496
+
497
+ .drawer-button {
498
+ float: left;
499
+ width: 20px;
500
+ height: 40px;
501
+ z-index: 8;
502
+ margin-top: calc(50% - 52px);
503
+ border: solid 1px #e4e7ed;
504
+ border-left: 0;
505
+ background-color: #ffffff;
506
+ text-align: center;
507
+ vertical-align: middle;
508
+ cursor: pointer;
509
+ pointer-events: auto;
510
+ }
511
+
512
+ .drawer-button {
513
+ i {
514
+ margin-top: 12px;
515
+ color: $app-primary-color;
516
+ transition-delay: 0.9s;
517
+ }
518
+ &.open {
519
+ i {
520
+ transform: rotate(0deg) scaleY(2.5);
521
+ }
522
+ }
523
+ &.close {
524
+ i {
525
+ transform: rotate(180deg) scaleY(2.5);
526
+ }
527
+ }
528
+ }
529
+
530
+ .drawer-button.open i {
531
+ transform: rotate(0deg) scaleY(2.5);
532
+ }
533
+
534
+ .drawer-button.close i {
535
+ transform: rotate(180deg) scaleY(2.5);
536
+ }
537
+ </style>
538
+
539
+ <style>
540
+ .hide-scaffold-colour-popup {
541
+ display: none;
542
+ }
543
+ </style>
544
+