@abi-software/scaffoldvuer 1.10.0 → 1.11.0-demo.1

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.10.0",
3
+ "version": "1.11.0-demo.1",
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.0"
57
+ "zincjs": "^1.14.2"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@vitejs/plugin-vue": "^4.6.2",
@@ -218,7 +218,7 @@ export default {
218
218
  border-radius: 4px;
219
219
  white-space: nowrap;
220
220
  min-width: unset!important;
221
- max-width:330px;
221
+ max-width:fit-content;
222
222
  width:unset!important;
223
223
  pointer-events: none;
224
224
  top: -15px !important;
@@ -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
  );
@@ -104,11 +104,13 @@
104
104
  @object-selected="objectSelected"
105
105
  @object-hovered="objectHovered"
106
106
  @drawer-toggled="drawerToggled"
107
+ @checked-regions="setCheckedRegions"
107
108
  />
108
109
  </template>
109
110
  </el-popover>
110
111
  <div class="primitive-controls-box">
111
112
  <primitive-controls
113
+ v-if="viewingMode === 'Exploration'"
112
114
  ref="primitiveControls"
113
115
  :createData="createData"
114
116
  @primitivesUpdated="primitivesUpdated"
@@ -323,7 +325,7 @@
323
325
  <el-radio-group
324
326
  v-model="colourRadio"
325
327
  class="scaffold-radio"
326
- @change="setColour"
328
+ @change="setColour(colourRadio, true)"
327
329
  >
328
330
  <el-radio :value="true">Colour</el-radio>
329
331
  <el-radio :value="false">Greyscale</el-radio>
@@ -335,7 +337,7 @@
335
337
  <el-radio-group
336
338
  v-model="outlinesRadio"
337
339
  class="scaffold-radio"
338
- @change="setOutlines"
340
+ @change="setOutlines(outlinesRadio, true)"
339
341
  >
340
342
  <el-radio :value="true">Show</el-radio>
341
343
  <el-radio :value="false">Hide</el-radio>
@@ -437,7 +439,6 @@ import {
437
439
  findObjectsWithNames,
438
440
  updateBoundingBox,
439
441
  } from "../scripts/Utilities.js";
440
-
441
442
  import {
442
443
  ElButton as Button,
443
444
  ElCol as Col,
@@ -458,6 +459,9 @@ import { OrgansViewer } from "../scripts/OrgansRenderer.js";
458
459
  import { SearchIndex } from "../scripts/Search.js";
459
460
  import { mapState } from 'pinia';
460
461
  import { useMainStore } from "@/store/index";
462
+ import { getNerveMaps } from "../scripts/MappedNerves.js";
463
+ const nervesMap = getNerveMaps();
464
+ let totalNerves = 0, foundNerves = 0;
461
465
 
462
466
  /**
463
467
  * A vue component of the scaffold viewer.
@@ -885,7 +889,8 @@ export default {
885
889
  region: "",
886
890
  group: "",
887
891
  isSearch: false,
888
- })
892
+ }),
893
+ checkedRegions: []
889
894
  };
890
895
  },
891
896
  watch: {
@@ -1033,6 +1038,43 @@ export default {
1033
1038
  },
1034
1039
  },
1035
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.$refs.scaffoldTreeControls.setCheckedKeys([...new Set(idsList)], processed);
1076
+ }
1077
+ },
1036
1078
  enableAxisDisplay: function (enable, miniaxes) {
1037
1079
  if (this.$module.scene) {
1038
1080
  this.$module.scene.enableAxisDisplay(enable, miniaxes);
@@ -1071,11 +1113,19 @@ export default {
1071
1113
  const regionPath = zincObject.getRegion().getFullPath().toLowerCase();
1072
1114
  for (let i = 0; i < regions.length; i++) {
1073
1115
  if (regionPath.includes(regions[i].toLowerCase())) {
1116
+ totalNerves++;
1074
1117
  zincObject.userData.isNerves = true;
1118
+ const groupName = zincObject.groupName.toLowerCase();
1119
+ if (groupName in nervesMap) {
1120
+ foundNerves++;
1121
+ zincObject.setAnatomicalId(nervesMap[groupName]);
1122
+ console.log(groupName, zincObject.anatomicalId, zincObject.uuid)
1123
+ }
1075
1124
  } else {
1076
1125
  zincObject.userData.isNerves = false;
1077
1126
  }
1078
1127
  }
1128
+
1079
1129
  }
1080
1130
  /**
1081
1131
  * Emit when a new object is added to the scene
@@ -1779,11 +1829,13 @@ export default {
1779
1829
  * @arg objects objects to be set for the selected
1780
1830
  */
1781
1831
  updatePrimitiveControls: function (objects) {
1782
- this.selectedObjects = objects;
1783
- if (this.selectedObjects && this.selectedObjects.length > 0) {
1784
- this.$refs.primitiveControls.setObject(this.selectedObjects[0]);
1785
- } else {
1786
- this.$refs.primitiveControls.setObject(undefined);
1832
+ if (this.viewingMode === 'Exploration') {
1833
+ this.selectedObjects = objects;
1834
+ if (this.selectedObjects && this.selectedObjects.length > 0) {
1835
+ this.$refs.primitiveControls.setObject(this.selectedObjects[0]);
1836
+ } else {
1837
+ this.$refs.primitiveControls.setObject(undefined);
1838
+ }
1787
1839
  }
1788
1840
  },
1789
1841
  /**
@@ -2183,24 +2235,40 @@ export default {
2183
2235
  this.tData.visible = false;
2184
2236
  this.tData.region = undefined;
2185
2237
  },
2238
+ /**
2239
+ *
2240
+ * @param flag boolean
2241
+ * @param nerves array of nerve names
2242
+ */
2243
+ setGreyScale: function (flag, nerves = []) {
2244
+ const objects = this.$module.scene.getRootRegion().getAllObjects(true);
2245
+ objects.forEach((zincObject) => {
2246
+ if (nerves.length) {
2247
+ const groupName = zincObject.groupName.toLowerCase();
2248
+ if (zincObject.userData.isNerves) {
2249
+ if (!nerves.includes(groupName)) zincObject.setGreyScale(flag);
2250
+ }
2251
+ } else {
2252
+ if (!zincObject.userData.isNerves) zincObject.setGreyScale(flag);
2253
+ }
2254
+ });
2255
+ this.$refs.scaffoldTreeControls.updateAllNodeColours();
2256
+ },
2186
2257
  /**
2187
2258
  * @public
2188
2259
  * Function to toggle colour/greyscale of primitives.
2189
2260
  * The parameter ``flag`` is a boolean, ``true`` (colour) and ``false`` (greyscale).
2190
2261
  * @arg {Boolean} `flag`
2191
2262
  */
2192
- setColour: function (flag) {
2263
+ setColour: function (flag, forced = false) {
2193
2264
  if (this.isReady && this.$module.scene &&
2194
- typeof flag === "boolean" && flag !== this.colourRadio) {
2265
+ typeof flag === "boolean" &&
2266
+ (forced || flag !== this.colourRadio)) {
2195
2267
  this.loading = true;
2196
2268
  //This can take sometime to finish , nextTick does not bring out
2197
2269
  //the loading screen so I opt for timeout loop here.
2198
2270
  setTimeout(() => {
2199
- const objects = this.$module.scene.getRootRegion().getAllObjects(true);
2200
- objects.forEach((zincObject) => {
2201
- if (!zincObject.userData.isNerves) zincObject.setGreyScale(!flag);
2202
- });
2203
- this.$refs.scaffoldTreeControls.updateAllNodeColours();
2271
+ this.setGreyScale(!flag)
2204
2272
  this.loading = false;
2205
2273
  this.colourRadio = flag;
2206
2274
  }, 100);
@@ -2212,9 +2280,10 @@ export default {
2212
2280
  * The parameter ``flag`` is a boolean, ``true`` to show lines, ``false`` to hide them.
2213
2281
  * @arg {Boolean} `flag`
2214
2282
  */
2215
- setOutlines: function (flag) {
2283
+ setOutlines: function (flag, forced = false) {
2216
2284
  if (this.isReady && this.$module.scene &&
2217
- typeof flag === "boolean" && flag !== this.outlinesRadio) {
2285
+ typeof flag === "boolean" &&
2286
+ (forced || flag !== this.outlinesRadio)) {
2218
2287
  this.outlinesRadio = flag;
2219
2288
  this.$nextTick(() => this.$refs.scaffoldTreeControls.setOutlines(flag));
2220
2289
  }
@@ -2431,6 +2500,7 @@ export default {
2431
2500
  //this.$module.scene.createAxisDisplay(false);
2432
2501
  //this.$module.scene.enableAxisDisplay(true, true);
2433
2502
  this.isReady = true;
2503
+ console.log(`Total ${totalNerves}, found ${foundNerves}`);
2434
2504
  this.$nextTick(() => {
2435
2505
  this.restoreSettings(options);
2436
2506
  this.$emit("on-ready");