@abi-software/scaffoldvuer 1.11.0-demo.0 → 1.11.0-demo.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/scaffoldvuer",
3
- "version": "1.11.0-demo.0",
3
+ "version": "1.11.0-demo.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -54,7 +54,7 @@
54
54
  "vue": "^3.4.21",
55
55
  "vue-router": "^4.2.5",
56
56
  "vue3-component-svg-sprite": "^0.0.1",
57
- "zincjs": "^1.14.1"
57
+ "zincjs": "^1.14.2"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@vitejs/plugin-vue": "^4.6.2",
@@ -87,10 +87,6 @@ export default {
87
87
  Tooltip,
88
88
  },
89
89
  props: {
90
- clientHeight: {
91
- type: Number,
92
- default: 200,
93
- },
94
90
  createData: {
95
91
  type: Object,
96
92
  default: {
@@ -150,14 +146,12 @@ export default {
150
146
  computed: {
151
147
  ...mapState(useMainStore, ['userToken']),
152
148
  position: function () {
153
- let yOffset = 20;
149
+ let yOffset = 40;
154
150
  if (this.region) {
155
- yOffset = 35;
151
+ yOffset = 55;
156
152
  }
157
- const x = this.x - 100;
158
- const bottom = this.clientHeight - (this.y - yOffset);
159
- return { left: x + "px", bottom: (bottom >= 0) ? `${bottom}px` : '0px'
160
- };
153
+ const x = this.x - 40;
154
+ return { left: x + "px", top: this.y - yOffset + "px" };
161
155
  },
162
156
  },
163
157
  methods: {
@@ -222,8 +216,9 @@ export default {
222
216
  background-color: #fff;
223
217
  border: 1px solid $app-primary-color;
224
218
  border-radius: 4px;
225
- min-width: 250px!important;
226
- max-width:500px;
219
+ white-space: nowrap;
220
+ min-width: unset!important;
221
+ max-width:fit-content;
227
222
  width:unset!important;
228
223
  pointer-events: none;
229
224
  top: -15px !important;
@@ -235,13 +230,9 @@ export default {
235
230
  }
236
231
 
237
232
  .tooltip-text {
238
- word-wrap: normal;
239
233
  text-align: center;
240
234
  color: $app-primary-color;
241
235
  }
242
- .tooltip-text + .tooltip-text {
243
- border-top: 1px solid $app-primary-color;
244
- }
245
236
 
246
237
  :deep(.non-selectable) {
247
238
  user-select: none;
@@ -77,6 +77,7 @@ export default {
77
77
  drawerOpen: true,
78
78
  nodeNumbers: 0,
79
79
  module: undefined,
80
+ checkedRegions: [],
80
81
  };
81
82
  },
82
83
  computed: {
@@ -91,6 +92,16 @@ export default {
91
92
  if (this.isReady) {
92
93
  // Updated colour when scaffold is ready
93
94
  this.setColourField(data);
95
+ // _helper is unchecked by default
96
+ this.checkedRegions = data.filter(region => region.label !== '_helper');
97
+ }
98
+ },
99
+ },
100
+ checkedRegions: {
101
+ deep: true,
102
+ handler: function (data) {
103
+ if (this.isReady) {
104
+ this.$emit('checked-regions', data)
94
105
  }
95
106
  },
96
107
  },
@@ -221,7 +232,13 @@ export default {
221
232
  .getRootRegion()
222
233
  .findChildFromPath(node.regionPath);
223
234
  if (isRegion) {
224
- isChecked ? region.showAllPrimitives() : region.hideAllPrimitives();
235
+ if (isChecked) {
236
+ region.showAllPrimitives();
237
+ this.checkedRegions.push(node);
238
+ } else {
239
+ region.hideAllPrimitives();
240
+ this.checkedRegions = this.checkedRegions.filter(region => region.label !== node.label);
241
+ }
225
242
  }
226
243
  if (isPrimitives) {
227
244
  const primitives = region.findObjectsWithGroupName(node.label);
@@ -514,13 +531,28 @@ export default {
514
531
  });
515
532
  }
516
533
  },
517
- checkAllKeys: function () {
534
+ setCheckedKeys: function (ids, clear) {
535
+ this.$nextTick(() => {
536
+ if (clear) {
537
+ this.$refs.treeControls.$refs.regionTree.setCheckedKeys([]); // Clear previous checked keys
538
+ }
539
+ // this will be faster as it only requires region node ids only
540
+ // the number will be much less than all node ids
541
+ ids.forEach((id) => {
542
+ this.$refs.treeControls.$refs.regionTree.setChecked(id, true, true); // Set new checked keys
543
+ })
544
+ });
545
+ },
546
+ checkAllKeys: function (ignore = []) {
518
547
  const keysList = [];
519
548
  const ids = [];
520
549
  extractAllFullPaths(this.treeData[0], keysList);
550
+ const modifiedKeysList = keysList.filter((key) => {
551
+ return !ignore.some(item => key.includes(item));
552
+ });
521
553
  this.setTreeVisibilityWithFullPaths(
522
554
  this.treeData[0],
523
- keysList,
555
+ modifiedKeysList,
524
556
  ids,
525
557
  true
526
558
  );
@@ -8,7 +8,6 @@
8
8
  >
9
9
  <map-svg-sprite-color />
10
10
  <scaffold-tooltip
11
- :clientHeight="clientHeight"
12
11
  :createData="createData"
13
12
  :label="tData.label"
14
13
  :region="tData.region"
@@ -105,11 +104,13 @@
105
104
  @object-selected="objectSelected"
106
105
  @object-hovered="objectHovered"
107
106
  @drawer-toggled="drawerToggled"
107
+ @checked-regions="setCheckedRegions"
108
108
  />
109
109
  </template>
110
110
  </el-popover>
111
111
  <div class="primitive-controls-box">
112
112
  <primitive-controls
113
+ v-if="viewingMode === 'Exploration'"
113
114
  ref="primitiveControls"
114
115
  :createData="createData"
115
116
  @primitivesUpdated="primitivesUpdated"
@@ -680,7 +681,7 @@ export default {
680
681
  isNerves: {
681
682
  type: Object,
682
683
  default: {
683
- regions: ["nerves", "Spinal nerves"]
684
+ regions: ["nerves"]
684
685
  },
685
686
  },
686
687
  /**
@@ -772,7 +773,6 @@ export default {
772
773
  data: function () {
773
774
  return {
774
775
  annotator: undefined,
775
- clientHeight: 200,
776
776
  colourRadio: true,
777
777
  createData: {
778
778
  drawingBox: false,
@@ -889,7 +889,8 @@ export default {
889
889
  region: "",
890
890
  group: "",
891
891
  isSearch: false,
892
- })
892
+ }),
893
+ checkedRegions: []
893
894
  };
894
895
  },
895
896
  watch: {
@@ -1037,6 +1038,44 @@ export default {
1037
1038
  },
1038
1039
  },
1039
1040
  methods: {
1041
+ setCheckedRegions: function (data) {
1042
+ this.checkedRegions = data;
1043
+ },
1044
+ zoomToNerves: function (nerves, processed = false) {
1045
+ if (this.$module.scene) {
1046
+ const idsList = [];
1047
+ const regions = this.$module.scene.getRootRegion().getChildRegions();
1048
+ regions.forEach((region) => {
1049
+ const regionName = region.getName();
1050
+ if (processed) {
1051
+ region.hideAllPrimitives();
1052
+ if (regionName === 'Nerves') {
1053
+ const ids = nerves.reduce((acc, nerve) => {
1054
+ const primitive = this.findObjectsWithGroupName(nerve)
1055
+ const ids = primitive.map((object) => {
1056
+ object.setVisibility(true);
1057
+ return `${object.region.uuid}/${object.uuid}`;
1058
+ });
1059
+ acc.push(...ids);
1060
+ return acc;
1061
+ }, []);
1062
+ idsList.push(...ids)
1063
+ }
1064
+ } else {
1065
+ // if the checkboxes are checked previously, restore them
1066
+ const isChecked = this.checkedRegions.find(item => item.label === regionName);
1067
+ if (isChecked) {
1068
+ region.showAllPrimitives();
1069
+ const zincObjects = region.getAllObjects();
1070
+ const ids = zincObjects.map(object => object.region.uuid);
1071
+ idsList.push(...ids);
1072
+ }
1073
+ }
1074
+ });
1075
+ this.fitWindow();
1076
+ this.$refs.scaffoldTreeControls.setCheckedKeys([...new Set(idsList)], processed);
1077
+ }
1078
+ },
1040
1079
  enableAxisDisplay: function (enable, miniaxes) {
1041
1080
  if (this.$module.scene) {
1042
1081
  this.$module.scene.enableAxisDisplay(enable, miniaxes);
@@ -1073,12 +1112,10 @@ export default {
1073
1112
  const regions = this.isNerves?.regions;
1074
1113
  if (regions) {
1075
1114
  const regionPath = zincObject.getRegion().getFullPath().toLowerCase();
1076
- let searching = true;
1077
- for (let i = 0; i < regions.length && searching; i++) {
1115
+ for (let i = 0; i < regions.length; i++) {
1078
1116
  if (regionPath.includes(regions[i].toLowerCase())) {
1079
1117
  totalNerves++;
1080
1118
  zincObject.userData.isNerves = true;
1081
- searching = false;
1082
1119
  const groupName = zincObject.groupName.toLowerCase();
1083
1120
  if (groupName in nervesMap) {
1084
1121
  foundNerves++;
@@ -1793,11 +1830,13 @@ export default {
1793
1830
  * @arg objects objects to be set for the selected
1794
1831
  */
1795
1832
  updatePrimitiveControls: function (objects) {
1796
- this.selectedObjects = objects;
1797
- if (this.selectedObjects && this.selectedObjects.length > 0) {
1798
- this.$refs.primitiveControls.setObject(this.selectedObjects[0]);
1799
- } else {
1800
- this.$refs.primitiveControls.setObject(undefined);
1833
+ if (this.viewingMode === 'Exploration') {
1834
+ this.selectedObjects = objects;
1835
+ if (this.selectedObjects && this.selectedObjects.length > 0) {
1836
+ this.$refs.primitiveControls.setObject(this.selectedObjects[0]);
1837
+ } else {
1838
+ this.$refs.primitiveControls.setObject(undefined);
1839
+ }
1801
1840
  }
1802
1841
  },
1803
1842
  /**
@@ -2197,14 +2236,32 @@ export default {
2197
2236
  this.tData.visible = false;
2198
2237
  this.tData.region = undefined;
2199
2238
  },
2239
+ /**
2240
+ *
2241
+ * @param flag boolean
2242
+ * @param nerves array of nerve names
2243
+ */
2244
+ setGreyScale: function (flag, nerves = []) {
2245
+ const objects = this.$module.scene.getRootRegion().getAllObjects(true);
2246
+ objects.forEach((zincObject) => {
2247
+ if (nerves.length) {
2248
+ const groupName = zincObject.groupName.toLowerCase();
2249
+ if (zincObject.userData.isNerves) {
2250
+ if (!nerves.includes(groupName)) zincObject.setGreyScale(flag);
2251
+ }
2252
+ } else {
2253
+ if (!zincObject.userData.isNerves) zincObject.setGreyScale(flag);
2254
+ }
2255
+ });
2256
+ this.$refs.scaffoldTreeControls.updateAllNodeColours();
2257
+ },
2200
2258
  /**
2201
2259
  * @public
2202
2260
  * Function to toggle colour/greyscale of primitives.
2203
2261
  * The parameter ``flag`` is a boolean, ``true`` (colour) and ``false`` (greyscale).
2204
2262
  * @arg {Boolean} `flag`
2205
2263
  */
2206
- setColour: function (flag, forced = false) {
2207
- console.log(flag, this.colourRadio)
2264
+ setColour: function (flag, forced = false) {
2208
2265
  if (this.isReady && this.$module.scene &&
2209
2266
  typeof flag === "boolean" &&
2210
2267
  (forced || flag !== this.colourRadio)) {
@@ -2212,11 +2269,7 @@ export default {
2212
2269
  //This can take sometime to finish , nextTick does not bring out
2213
2270
  //the loading screen so I opt for timeout loop here.
2214
2271
  setTimeout(() => {
2215
- const objects = this.$module.scene.getRootRegion().getAllObjects(true);
2216
- objects.forEach((zincObject) => {
2217
- if (!zincObject.userData.isNerves) zincObject.setGreyScale(!flag);
2218
- });
2219
- this.$refs.scaffoldTreeControls.updateAllNodeColours();
2272
+ this.setGreyScale(!flag)
2220
2273
  this.loading = false;
2221
2274
  this.colourRadio = flag;
2222
2275
  }, 100);
@@ -2660,7 +2713,6 @@ export default {
2660
2713
  adjustLayout: function () {
2661
2714
  if (this.$refs.scaffoldContainer) {
2662
2715
  let width = this.$refs.scaffoldContainer.clientWidth;
2663
- this.clientHeight = this.$refs.scaffoldContainer.clientHeight;
2664
2716
  this.minimisedSlider = width < 812;
2665
2717
  if (this.minimisedSlider) {
2666
2718
  this.sliderPosition = this.drawerOpen ? "right" : "left";
@@ -829,21 +829,73 @@ const getNerveMaps = () => {
829
829
  const getTermNerveMaps = () => {
830
830
  const curatedMap = {};
831
831
  mappedNerves.forEach((item) => {
832
- if (item["nerve_id"] && item["label"] !== "nerve") {
833
- if (!item["subclass labels"].length) {
832
+ const nerve_id = item["nerve_id"];
833
+ const label = item["label"].toLowerCase();
834
+ const subclassLabels = item["subclass labels"];
835
+ if (nerve_id && label !== "nerve") {
836
+ if (!subclassLabels.length) {
834
837
  return;
835
838
  }
836
- if (!(item["nerve_id"] in curatedMap)) {
837
- curatedMap[item["nerve_id"]] = [];
839
+ if (!(nerve_id in curatedMap)) {
840
+ curatedMap[nerve_id] = {};
838
841
  }
839
- const labels = item["subclass labels"].map((label) => label.toLowerCase())
840
- curatedMap[item["nerve_id"]].push(...labels);
842
+ const subLabels = subclassLabels
843
+ .map((label) => label.toLowerCase())
844
+ .sort();
845
+ curatedMap[nerve_id] = {
846
+ nerve: label,
847
+ subNerves: subLabels,
848
+ };
841
849
  }
842
850
  });
843
851
  return curatedMap;
844
852
  };
845
853
 
854
+ const getFilterOptions = () => {
855
+ let filterOptions = [];
856
+ let main = {
857
+ key: "scaffold.connectivity.nerve",
858
+ label: "Nerves",
859
+ children: [],
860
+ };
861
+ let children1 = [];
862
+ for (const nerve of mappedNerves) {
863
+ if (nerve.label === "nerve") {
864
+ continue;
865
+ }
866
+ let sub = {
867
+ facetPropPath: "scaffold.connectivity.nerve",
868
+ label: "",
869
+ children: [],
870
+ };
871
+ let children2 = [];
872
+ for (const [key, value] of Object.entries(nerve)) {
873
+ if (key === "label") {
874
+ sub.label = value;
875
+ }
876
+ if (key === "subclass labels") {
877
+ for (const subnerve of value) {
878
+ children2.push({
879
+ facetPropPath: "scaffold.connectivity.subnerve",
880
+ label: subnerve,
881
+ });
882
+ }
883
+ }
884
+ }
885
+ if (children2.length) {
886
+ sub.children = children2.sort((a, b) => a.label.localeCompare(b.label));
887
+ children1.push(sub);
888
+ }
889
+ }
890
+ if (children1.length) {
891
+ main.children = children1.sort((a, b) => a.label.localeCompare(b.label));
892
+ filterOptions.push(main);
893
+ }
894
+ return filterOptions;
895
+ };
896
+
846
897
  export {
847
898
  getNerveMaps,
848
- getTermNerveMaps
899
+ getTermNerveMaps,
900
+ getFilterOptions
849
901
  };