@abi-software/scaffoldvuer 0.1.60 → 0.1.61

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.
@@ -26,25 +26,44 @@
26
26
  <el-popover
27
27
  v-if="displayWarning"
28
28
  ref="warningPopover"
29
- v-model="hoverVisabilities[6].value"
29
+ v-model="hoverVisibilities[6].value"
30
30
  :content="warningMessage"
31
31
  placement="right"
32
32
  :append-to-body="false"
33
33
  trigger="manual"
34
- popper-class="warning-popper right-popper non-selectable"
34
+ popper-class="warning-popper message-popper right-popper non-selectable"
35
35
  />
36
36
  <i
37
37
  v-if="displayWarning"
38
38
  v-popover:warningPopover
39
- class="el-icon-warning warning-icon"
39
+ class="el-icon-warning message-icon warning-icon"
40
40
  @mouseover="showHelpText(6)"
41
41
  @mouseout="hideHelpText(6)"
42
42
  >
43
- <span class="warning-text">Beta</span>
43
+ <span class="message-text">Beta</span>
44
+ </i>
45
+ <el-popover
46
+ v-if="displayLatestChanges"
47
+ ref="latestChangesPopover"
48
+ v-model="hoverVisibilities[7].value"
49
+ :content="latestChangesMessage"
50
+ placement="right"
51
+ :append-to-body="false"
52
+ trigger="manual"
53
+ popper-class="latest-popper message-popper right-popper non-selectable"
54
+ />
55
+ <i
56
+ v-if="displayLatestChanges && latestChangesMessage"
57
+ v-popover:latestChangesPopover
58
+ class="el-icon-warning message-icon latest-changesicon"
59
+ @mouseover="showHelpText(7)"
60
+ @mouseout="hideHelpText(7)"
61
+ >
62
+ <span class="message-text">What's new?</span>
44
63
  </i>
45
64
  <el-popover
46
65
  ref="checkBoxPopover"
47
- v-model="hoverVisabilities[5].value"
66
+ v-model="hoverVisibilities[5].value"
48
67
  content="Change region visibility"
49
68
  placement="right"
50
69
  :append-to-body="false"
@@ -66,7 +85,7 @@
66
85
  <el-popover
67
86
  v-if="sceneData.timeVarying"
68
87
  ref="sliderPopover"
69
- v-model="hoverVisabilities[4].value"
88
+ v-model="hoverVisibilities[4].value"
70
89
  content="Move the slider to animate the region"
71
90
  placement="top"
72
91
  :append-to-body="false"
@@ -145,7 +164,7 @@
145
164
  </div>
146
165
  <div class="bottom-right-control">
147
166
  <el-popover
148
- v-model="hoverVisabilities[0].value"
167
+ v-model="hoverVisibilities[0].value"
149
168
  content="Zoom in"
150
169
  placement="left"
151
170
  :append-to-body="false"
@@ -162,7 +181,7 @@
162
181
  />
163
182
  </el-popover>
164
183
  <el-popover
165
- v-model="hoverVisabilities[1].value"
184
+ v-model="hoverVisibilities[1].value"
166
185
  content="Zoom out"
167
186
  placement="top-end"
168
187
  :append-to-body="false"
@@ -179,7 +198,7 @@
179
198
  />
180
199
  </el-popover>
181
200
  <el-popover
182
- v-model="hoverVisabilities[2].value"
201
+ v-model="hoverVisibilities[2].value"
183
202
  placement="top"
184
203
  :append-to-body="false"
185
204
  trigger="manual"
@@ -221,7 +240,7 @@
221
240
  </el-row>
222
241
  </el-popover>
223
242
  <el-popover
224
- v-model="hoverVisabilities[3].value"
243
+ v-model="hoverVisibilities[3].value"
225
244
  content="Change background color"
226
245
  placement="right"
227
246
  :append-to-body="false"
@@ -249,7 +268,8 @@ import OpacityControls from "./OpacityControls";
249
268
  import ScaffoldTooltip from "./ScaffoldTooltip";
250
269
  import TreeControls from "./TreeControls";
251
270
  import { MapSvgIcon, MapSvgSpriteColor } from "@abi-software/svg-sprite";
252
- import { findObjectsWithNames } from "../scripts/utilities.js";
271
+ import { findObjectsWithNames, getAllObjects } from "../scripts/utilities.js";
272
+ import { SearchIndex } from "../scripts/search.js";
253
273
  import {
254
274
  Col,
255
275
  Loading,
@@ -349,6 +369,14 @@ export default {
349
369
  type: String,
350
370
  default: "Beta feature - under active development"
351
371
  },
372
+ displayLatestChanges: {
373
+ type: Boolean,
374
+ default: false,
375
+ },
376
+ latestChangesMessage: {
377
+ type: String,
378
+ default: "New feature - Local search is now available",
379
+ },
352
380
  /**
353
381
  * Show/hide pickable markers for regions.
354
382
  */
@@ -426,14 +454,15 @@ export default {
426
454
  */
427
455
  isTransitioning: false,
428
456
  tooltipAppendToBody: false,
429
- hoverVisabilities: [
457
+ hoverVisibilities: [
458
+ { value: false },
459
+ { value: false },
430
460
  { value: false },
431
461
  { value: false },
432
462
  { value: false },
433
463
  { value: false },
434
464
  { value: false },
435
465
  { value: false },
436
- { value: false }
437
466
  ],
438
467
  inHelp: false,
439
468
  loading: false,
@@ -481,9 +510,8 @@ export default {
481
510
  visible: false,
482
511
  x: 200,
483
512
  y: 200,
484
- external: false,
485
513
  },
486
- fileFormat: "metadata",
514
+ fileFormat: "metadata"
487
515
  };
488
516
  },
489
517
  watch: {
@@ -558,6 +586,8 @@ export default {
558
586
  this.currentBackground = "white";
559
587
  this._currentURL = undefined;
560
588
  this.availableBackground = ["white", "black", "lightskyblue"];
589
+ this.$_searchIndex = new SearchIndex();;
590
+ this.$_tempId = 1;
561
591
  },
562
592
  mounted: function() {
563
593
  this.$refs.treeControls.setModule(this.$module);
@@ -583,6 +613,8 @@ export default {
583
613
  */
584
614
  zincObjectAdded: function(zincObject) {
585
615
  this.loading = false;
616
+ zincObject.searchIndexId = ++this.$_tempId;
617
+ this.$_searchIndex.addZincObject(zincObject, zincObject.searchIndexId);
586
618
  this.$emit("zinc-object-added", zincObject);
587
619
  },
588
620
  /**
@@ -795,40 +827,42 @@ export default {
795
827
  //this.$refs.treeControls.changeActiveByNames(names, region, false);
796
828
  this.$refs.treeControls.updateActiveUI(zincObjects);
797
829
  } else {
798
- this.$refs.treeControls.removeActive(true)
830
+ this.hideRegionTooltip();
831
+ this.$refs.treeControls.removeActive(true);
799
832
  }
800
833
  }
801
834
  // Triggers when an object has been selected
802
835
  this.$emit("scaffold-selected", event.identifiers);
803
836
  } else if (event.eventType == 2) {
804
- this.tData.visible = false;
805
- // const offsets = this.$refs.scaffoldContainer.getBoundingClientRect();
806
- if (this.$refs.treeControls) {
807
- if (names.length > 0) {
808
- //this.$refs.treeControls.changeHoverByNames(names, region, false);
809
- this.$refs.treeControls.updateHoverUI(zincObjects);
810
- } else {
811
- this.$refs.treeControls.removeHover(true);
837
+ if (this.selectedObjects.length === 0) {
838
+ this.hideRegionTooltip();
839
+ // const offsets = this.$refs.scaffoldContainer.getBoundingClientRect();
840
+ if (this.$refs.treeControls) {
841
+ if (names.length > 0) {
842
+ //this.$refs.treeControls.changeHoverByNames(names, region, false);
843
+ this.$refs.treeControls.updateHoverUI(zincObjects);
844
+ } else {
845
+ this.$refs.treeControls.removeHover(true);
846
+ }
812
847
  }
813
- }
814
- if ((event.identifiers.length > 0) && event.identifiers[0]) {
815
- let id = event.identifiers[0].data.id
816
- ? event.identifiers[0].data.id
817
- : event.identifiers[0].data.group;
818
- if (event.identifiers[0].coords) {
819
- this.tData.external = false;
820
- this.tData.visible = true;
821
- this.tData.label = id;
822
- if (event.identifiers[0].data.region)
823
- this.tData.region = event.identifiers[0].data.region;
824
- else
825
- this.tData.region = "Root";
826
- this.tData.x = event.identifiers[0].coords.x;
827
- this.tData.y = event.identifiers[0].coords.y;
848
+ if ((event.identifiers.length > 0) && event.identifiers[0]) {
849
+ let id = event.identifiers[0].data.id
850
+ ? event.identifiers[0].data.id
851
+ : event.identifiers[0].data.group;
852
+ if (event.identifiers[0].coords) {
853
+ this.tData.visible = true;
854
+ this.tData.label = id;
855
+ if (event.identifiers[0].data.region)
856
+ this.tData.region = event.identifiers[0].data.region;
857
+ else
858
+ this.tData.region = "Root";
859
+ this.tData.x = event.identifiers[0].coords.x;
860
+ this.tData.y = event.identifiers[0].coords.y;
861
+ }
828
862
  }
863
+ // Triggers when an object has been highlighted
864
+ this.$emit("scaffold-highlighted", event.identifiers);
829
865
  }
830
- // Triggers when an object has been highlighted
831
- this.$emit("scaffold-highlighted", event.identifiers);
832
866
  } else if (event.eventType == 3) { //MOVE
833
867
  if ((event.identifiers.length > 0) && event.identifiers[0]) {
834
868
  if (event.identifiers[0].coords) {
@@ -846,7 +880,7 @@ export default {
846
880
  */
847
881
  getCoordinatesOfSelected: function() {
848
882
  if (this.selectedObjects && this.selectedObjects.length > 0) {
849
- return this.$module.scene.getObjectsScreenXY([this.selectedObjects]);
883
+ return this.$module.scene.getObjectsScreenXY(this.selectedObjects);
850
884
  }
851
885
  return undefined;
852
886
  },
@@ -875,10 +909,9 @@ export default {
875
909
  */
876
910
  objectSelected: function(objects, propagate) {
877
911
  this.selectedObjects = objects;
878
- if (this.selectedObjects)
912
+ if (this.selectedObjects && this.selectedObjects.length > 0)
879
913
  this.$refs.opacityControl.setObject(this.selectedObjects[0]);
880
- if (objects) this.$module.setSelectedByZincObjects(objects, undefined, propagate);
881
- else this.$module.setSelectedByObjects([], undefined, propagate);
914
+ this.$module.setSelectedByZincObjects(objects, undefined, propagate);
882
915
  },
883
916
  /**
884
917
  * A callback used by children components. Set the highlighted zinc object
@@ -887,8 +920,7 @@ export default {
887
920
  */
888
921
  objectHovered: function(objects, propagate) {
889
922
  this.hoveredObjects = objects;
890
- if (objects) this.$module.setHighlightedByZincObjects(objects, undefined, propagate);
891
- else this.$module.setHighlightedByObjects([], undefined, propagate);
923
+ this.$module.setHighlightedByZincObjects(objects, undefined, propagate);
892
924
  },
893
925
  /**
894
926
  * Set the selected by name.
@@ -930,6 +962,8 @@ export default {
930
962
  play: function(flag) {
931
963
  this.$module.playAnimation(flag);
932
964
  this.isPlaying = flag;
965
+ //Hide tooltip as location may
966
+ //this.hideRegionTooltip();
933
967
  },
934
968
  /**
935
969
  * Function to toggle on/off overlay help.
@@ -937,12 +971,12 @@ export default {
937
971
  setHelpMode: function(helpMode) {
938
972
  if (helpMode) {
939
973
  this.inHelp = true;
940
- this.hoverVisabilities.forEach(item => {
974
+ this.hoverVisibilities.forEach(item => {
941
975
  item.value = true;
942
976
  });
943
977
  } else {
944
978
  this.inHelp = false;
945
- this.hoverVisabilities.forEach(item => {
979
+ this.hoverVisibilities.forEach(item => {
946
980
  item.value = false;
947
981
  });
948
982
  }
@@ -951,61 +985,87 @@ export default {
951
985
  * Callback function used by showRegionTooltip in the case when the tooltip
952
986
  * is out of view.
953
987
  */
954
- showRegionTooltipCallback: function(name) {
988
+ displayTooltipOfObjectsCallback: function(name, objects, resetView, liveUpdates) {
955
989
  const instance = this;
956
990
  return function() {
957
991
  instance.$module.zincRenderer.removePostRenderCallbackFunction(instance.$_regionTooltipCallback);
958
992
  instance.$_regionTooltipCallback = undefined;
959
- instance.showRegionTooltip(name, false);
993
+ instance.displayTooltipOfObjects(name, objects, resetView, liveUpdates);
960
994
  }
961
995
  },
996
+ liveUpdateTooltipPosition: function() {
997
+ if (this.$module.selectedCenter) {
998
+ this.tData.x = this.$module.selectedScreenCoordinates.x;
999
+ this.tData.y = this.$module.selectedScreenCoordinates.y;
1000
+ }
1001
+ },
1002
+ displayTooltipOfObjects: function(name, objects, resetView, liveUpdates) {
1003
+ if (objects.length > 0) {
1004
+ let coords = objects[0].getClosestVertexDOMElementCoords(this.$module.scene);
1005
+ if (coords) {
1006
+ //The coords is not in view, view all if resetView flag is true
1007
+ if (!coords.inView) {
1008
+ this.hideRegionTooltip();
1009
+ if (resetView) {
1010
+ this.$module.scene.viewAll();
1011
+ //Use the post render callback to make sure the scene has been updated
1012
+ //before getting the position of the tooltip.
1013
+ if (this.$_regionTooltipCallback) {
1014
+ this.$module.zincRenderer.removePostRenderCallbackFunction(this.$_regionTooltipCallback);
1015
+ }
1016
+ this.$_regionTooltipCallback =
1017
+ this.$module.zincRenderer.addPostRenderCallbackFunction(
1018
+ this.displayTooltipOfObjectsCallback(name, objects, resetView, liveUpdates)
1019
+ );
1020
+ }
1021
+ } else {
1022
+ this.tData.visible = true;
1023
+ this.tData.label = name;
1024
+ this.tData.x = coords.position.x;
1025
+ this.tData.y = coords.position.y;
1026
+ const regionPath = objects[0].getRegion().getFullPath();
1027
+ if (regionPath)
1028
+ this.tData.region = regionPath;
1029
+ else
1030
+ this.tData.region = "Root";
1031
+ if (liveUpdates) {
1032
+ this.$module.setupLiveCoordinates(objects);
1033
+ if (this.$_liveCoordinatesUpdated) {
1034
+ this.$module.zincRenderer.removePostRenderCallbackFunction(this.$_liveCoordinatesUpdated);
1035
+ }
1036
+ this.$_liveCoordinatesUpdated =
1037
+ this.$module.zincRenderer.addPostRenderCallbackFunction(
1038
+ this.liveUpdateTooltipPosition);
1039
+ }
1040
+ }
1041
+ return true;
1042
+ }
1043
+ }
1044
+ this.hideRegionTooltip();
1045
+ return false;
1046
+ },
962
1047
  /**
963
- * Display the tooltip. Reset view if the tooltip is not
964
- * in view.
1048
+ * Display the tooltip. When resetView is set to true, it will
1049
+ * reset view if the tooltip is not in view.
1050
+ * Setting liveUpdates to true will update the tooltip location
1051
+ * at every rendering loop.
965
1052
  */
966
- showRegionTooltip: function(name, resetView) {
1053
+ showRegionTooltip: function(name, resetView, liveUpdates) {
967
1054
  if (name && this.$module.scene) {
968
1055
  const rootRegion = this.$module.scene.getRootRegion();
969
1056
  const groups = [name];
970
1057
  const objects = findObjectsWithNames(rootRegion, groups, "", true);
971
- if (objects.length > 0) {
972
- let coords = objects[0].getClosestVertexDOMElementCoords(this.$module.scene);
973
- if (coords) {
974
- //The coords is not in view, view all if resetView flag is true
975
- if (!coords.inView) {
976
- this.hideRegionTooltip();
977
- if (resetView) {
978
- this.$module.scene.viewAll();
979
- //Use the post render callback to make sure the scene has been updated
980
- //before getting the position of the tooltip.
981
- if (this.$_regionTooltipCallback) {
982
- this.$module.zincRenderer.removePostRenderCallbackFunction(this.$_regionTooltipCallback);
983
- }
984
- this.$_regionTooltipCallback =
985
- this.$module.zincRenderer.addPostRenderCallbackFunction(
986
- this.showRegionTooltipCallback(name)
987
- );
988
- }
989
- } else {
990
- this.tData.external = true;
991
- this.tData.visible = true;
992
- this.tData.label = name;
993
- this.tData.x = coords.position.x;
994
- this.tData.y = coords.position.y;
995
- const regionPath = objects[0].getRegion().getFullPath();
996
- if (regionPath)
997
- this.tData.region = regionPath;
998
- else
999
- this.tData.region = "Root";
1000
- }
1001
- return true;
1002
- }
1003
- }
1058
+ return this.displayTooltipOfObjects(name, objects, resetView, liveUpdates);
1004
1059
  }
1005
1060
  this.hideRegionTooltip();
1006
1061
  return false;
1007
1062
  },
1008
1063
  hideRegionTooltip: function() {
1064
+ if (this.$_liveCoordinatesUpdated) {
1065
+ this.$module.zincRenderer.removePostRenderCallbackFunction(this.$_liveCoordinatesUpdated);
1066
+ //Unset the tracking
1067
+ this.$module.setupLiveCoordinates(undefined);
1068
+ }
1009
1069
  this.tData.visible = false;
1010
1070
  this.tData.region = "Root";
1011
1071
  },
@@ -1016,7 +1076,7 @@ export default {
1016
1076
  showHelpText: function(helpTextNumber) {
1017
1077
  if (!this.inHelp) {
1018
1078
  this.helpTextWait = setTimeout(() => {
1019
- this.hoverVisabilities[helpTextNumber].value = true;
1079
+ this.hoverVisibilities[helpTextNumber].value = true;
1020
1080
  }, 500);
1021
1081
  }
1022
1082
  },
@@ -1025,10 +1085,42 @@ export default {
1025
1085
  */
1026
1086
  hideHelpText: function(helpTextNumber) {
1027
1087
  if (!this.inHelp) {
1028
- this.hoverVisabilities[helpTextNumber].value = false;
1088
+ this.hoverVisibilities[helpTextNumber].value = false;
1029
1089
  clearTimeout(this.helpTextWait);
1030
1090
  }
1031
1091
  },
1092
+ search: function(text, displayLabel) {
1093
+ if (this.$_searchIndex) {
1094
+ if (text === undefined || text === "") {
1095
+ this.objectSelected([], true);
1096
+ return false;
1097
+ } else {
1098
+ let zincObjectResults = this.$_searchIndex.search(text);
1099
+ if (zincObjectResults.length > 0) {
1100
+ this.objectSelected(zincObjectResults, true);
1101
+ if (displayLabel) {
1102
+ for (let i = 0; i < zincObjectResults.length; i++) {
1103
+ if (zincObjectResults[i] && zincObjectResults[i].groupName) {
1104
+ this.showRegionTooltip(zincObjectResults[i].groupName, true, true)
1105
+ }
1106
+ }
1107
+ }
1108
+ return true;
1109
+ } else {
1110
+ this.objectSelected([], true);
1111
+ }
1112
+ }
1113
+ }
1114
+ return false;
1115
+ },
1116
+ /**
1117
+ * Get the list of suggested terms
1118
+ */
1119
+ fetchSuggestions: function(term) {
1120
+ if(this.$_searchIndex === undefined)
1121
+ return [];
1122
+ return this.$_searchIndex.auto_suggest(term);
1123
+ },
1032
1124
  /**
1033
1125
  * Called when minimap settings has changed. Pass the
1034
1126
  * parameters to ZincJS and marked it for update.
@@ -1178,6 +1270,9 @@ export default {
1178
1270
  true
1179
1271
  );
1180
1272
  }
1273
+ this.$_searchIndex.removeAll();
1274
+ this.$_tempId = 1;
1275
+ this.hideRegionTooltip();
1181
1276
  this.$module.scene.displayMarkers = this.displayMarkers;
1182
1277
  this.$module.scene.forcePickableObjectsUpdate = true;
1183
1278
  this.$module.scene.displayMinimap = this.displayMinimap;
@@ -1257,7 +1352,8 @@ export default {
1257
1352
  @import "~element-ui/packages/theme-chalk/src/tabs";
1258
1353
  @import "~element-ui/packages/theme-chalk/src/tab-pane";
1259
1354
 
1260
- .warning-icon {
1355
+
1356
+ .message-icon {
1261
1357
  position: absolute;
1262
1358
  top: 15px;
1263
1359
  left: 37px;
@@ -1270,18 +1366,30 @@ export default {
1270
1366
  }
1271
1367
  }
1272
1368
 
1273
- .warning-text {
1369
+ .warning-icon {
1370
+ color: $warning;
1371
+ top: 15px;
1372
+ }
1373
+
1374
+ .latest-changesicon {
1375
+ color: $success;
1376
+ top: 45px;
1377
+ }
1378
+
1379
+ .message-text {
1274
1380
  font-size: 15px;
1275
1381
  vertical-align: 5px;
1276
1382
  }
1277
1383
 
1278
- ::v-deep .warning-popper {
1384
+ ::v-deep .message-popper {
1279
1385
  padding: 9px 10px;
1280
1386
  min-width: 150px;
1281
1387
  font-size: 12px;
1282
1388
  color: #fff;
1283
- background-color: $warning;
1389
+ }
1284
1390
 
1391
+ ::v-deep .warning-popper {
1392
+ background-color: $warning;
1285
1393
  &.right-popper {
1286
1394
  .popper__arrow {
1287
1395
  &::after {
@@ -1291,6 +1399,17 @@ export default {
1291
1399
  }
1292
1400
  }
1293
1401
 
1402
+ ::v-deep .latest-popper {
1403
+ background-color: $success;
1404
+ &.right-popper {
1405
+ .popper__arrow {
1406
+ &::after {
1407
+ border-right-color: $success !important;
1408
+ }
1409
+ }
1410
+ }
1411
+ }
1412
+
1294
1413
  #organsDisplayArea {
1295
1414
  &:focus {
1296
1415
  outline: none !important;
@@ -289,14 +289,14 @@ export default {
289
289
  */
290
290
  removeActive: function (propagate) {
291
291
  this.active = [];
292
- this.$emit("object-selected", undefined, propagate);
292
+ this.$emit("object-selected", [], propagate);
293
293
  },
294
294
  /**
295
295
  * Unselect the current hover region.
296
296
  */
297
297
  removeHover: function (propagate) {
298
298
  this.hover = [];
299
- this.$emit("object-hovered", undefined, propagate);
299
+ this.$emit("object-hovered", [], propagate);
300
300
  },
301
301
  /**
302
302
  * Reset the controls.
@@ -32,6 +32,7 @@ const RendererModule = function() {
32
32
  this.zincRenderer = null;
33
33
  this.selectedScreenCoordinates = new THREE.Vector3();
34
34
  this.selectedCenter = undefined;
35
+ this.liveUpdatesObjects = undefined;
35
36
  }
36
37
 
37
38
  RendererModule.prototype = Object.create((require('./BaseModule').BaseModule).prototype);
@@ -118,6 +119,7 @@ RendererModule.prototype.setHighlightedByZincObjects = function(
118
119
  }
119
120
 
120
121
  RendererModule.prototype.setupLiveCoordinates = function(zincObjects) {
122
+ this.liveUpdatesObjects = zincObjects;
121
123
  if (zincObjects && (zincObjects.length > 0)) {
122
124
  const boundingBox = this.scene.getBoundingBoxOfZincObjects(zincObjects);
123
125
  let newSelectedCenter = new THREE.Vector3();
@@ -124,6 +124,10 @@ const PrimitiveData = function () {
124
124
  }
125
125
 
126
126
  const postRenderSelectedCoordinatesUpdate = function() {
127
+ //It is animating, the coordinates may have been updated
128
+ if (_this.zincRenderer.playAnimation && _this.liveUpdatesObjects) {
129
+ _this.setupLiveCoordinates(_this.liveUpdatesObjects);
130
+ }
127
131
  if (_this.selectedCenter) {
128
132
  const vector = new THREE.Vector3();
129
133
  vector.copy(_this.selectedCenter);