@abi-software/scaffoldvuer 0.1.56 → 0.1.57

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.
@@ -21,7 +21,7 @@
21
21
  :data="treeData"
22
22
  :default-checked-keys="['__r/']"
23
23
  :expand-on-click-node="false"
24
- :renderAfterExpand="false"
24
+ :render-after-expand="false"
25
25
  @check="checkChanged"
26
26
  >
27
27
  <span
@@ -35,7 +35,7 @@
35
35
  @mouseover="changeHoverByNode(data, true)"
36
36
  >
37
37
  <el-color-picker
38
- v-if="data.primitives"
38
+ v-if="data.isPrimitives"
39
39
  :class="{ 'show-picker': showColourPicker }"
40
40
  :value="getColour(data)"
41
41
  size="small"
@@ -92,13 +92,6 @@ const nameSorting = (a, b) => {
92
92
  export default {
93
93
  name: "TreeControls",
94
94
  props: {
95
- /**
96
- * @ignore
97
- */
98
- module: {
99
- type: Object,
100
- default: undefined,
101
- },
102
95
  /**
103
96
  * Enable/disable colour picker
104
97
  */
@@ -122,22 +115,6 @@ export default {
122
115
  },
123
116
  },
124
117
  },
125
- created: function () {
126
- this.module.sceneData.geometries.forEach(zincObject => {
127
- this.zincObjectAdded(zincObject);
128
- });
129
- this.module.sceneData.lines.forEach(zincObject => {
130
- this.zincObjectAdded(zincObject);
131
- });
132
- this.module.sceneData.glyphsets.forEach(zincObject => {
133
- this.zincObjectAdded(zincObject);
134
- });
135
- this.module.sceneData.pointsets.forEach(zincObject => {
136
- this.zincObjectAdded(zincObject);
137
- });
138
- this.module.addOrganPartAddedCallback(this.zincObjectAdded);
139
- this.__nodeNumbers = 1;
140
- },
141
118
  destroyed: function () {
142
119
  this.sortedPrimitiveGroups = undefined;
143
120
  },
@@ -146,8 +123,7 @@ export default {
146
123
  //The following block prevent duplicate graphics with the same name
147
124
  for (let i = 0; i < parentContainer.length; i++) {
148
125
  if (parentContainer[i].id === item.id) {
149
- if (item.primitives && parentContainer[i].primitives) {
150
- parentContainer[i].primitives.push(...item.primitives);
126
+ if (item.isPrimitives && parentContainer[i].isPrimitives) {
151
127
  return;
152
128
  }
153
129
  }
@@ -165,10 +141,10 @@ export default {
165
141
  // '__r/'
166
142
  findOrCreateRegion: function (data, paths, prefix) {
167
143
  //check if root region has been set
168
- if (!this.treeData[0].region && this.module && this.module.scene) {
169
- this.treeData[0].region = this.module.scene.getRootRegion();
144
+ if ((this.treeData[0].regionPath === undefined) && this.$module && this.$module.scene) {
145
+ this.treeData[0].regionPath = "";
146
+ this.treeData[0].isRegion = true;
170
147
  }
171
-
172
148
  if (paths.length > 0) {
173
149
  const _paths = [...paths];
174
150
  let childRegion = data.children.find(
@@ -177,12 +153,12 @@ export default {
177
153
  const path = prefix + "/" + paths[0];
178
154
  const id = "__r" + path;
179
155
  if (!childRegion) {
180
- const region = this.treeData[0].region.findChildFromPath(path);
181
156
  childRegion = {
182
157
  label: _paths[0],
183
158
  id: id,
184
159
  children: [],
185
- region: region,
160
+ regionPath: path,
161
+ isRegion: true,
186
162
  };
187
163
  this.addTreeItem(data.children, childRegion);
188
164
  }
@@ -232,7 +208,7 @@ export default {
232
208
  const child = {
233
209
  label: zincObject.groupName,
234
210
  id: id,
235
- primitives: [zincObject],
211
+ isPrimitives: true,
236
212
  regionPath: zincObject.region.getFullPath(),
237
213
  };
238
214
  this.addTreeItem(regionData.children, child);
@@ -241,15 +217,19 @@ export default {
241
217
  }
242
218
  },
243
219
  checkChanged: function (node, data) {
244
- const isRegion = node.region;
245
- const isPrimitives = node.primitives;
220
+ const isRegion = node.isRegion;
221
+ const isPrimitives = node.isPrimitives;
246
222
  const isChecked = data.checkedKeys.includes(node.id);
247
- if (isRegion)
248
- isChecked ? node.region.showAllPrimitives() : node.region.hideAllPrimitives();
249
- if (isPrimitives)
250
- node.primitives.forEach(primitive => {
223
+ const region = this.$module.scene.getRootRegion().findChildFromPath(node.regionPath);
224
+ if (isRegion) {
225
+ isChecked ? region.showAllPrimitives() : region.hideAllPrimitives();
226
+ }
227
+ if (isPrimitives) {
228
+ const primitives = region.findObjectsWithGroupName(node.label);
229
+ primitives.forEach(primitive => {
251
230
  primitive.setVisibility(isChecked);
252
231
  });
232
+ }
253
233
  },
254
234
  updateActiveUI: function (primitives) {
255
235
  this.active.length = 0;
@@ -280,27 +260,31 @@ export default {
280
260
  * Select a region by its name.
281
261
  */
282
262
  changeActiveByNames: function (names, regionPath, propagate) {
283
- const rootRegion = this.module.scene.getRootRegion();
263
+ const rootRegion = this.$module.scene.getRootRegion();
284
264
  const targetObjects = findObjectsWithNames(rootRegion, names,
285
- regionPath);
265
+ regionPath, true);
286
266
  this.changeActiveByPrimitives(targetObjects, propagate);
287
267
  },
288
268
  /**
289
269
  * Hover a region by its name.
290
270
  */
291
271
  changeHoverByNames: function (names, regionPath, propagate) {
292
- const rootRegion = this.module.scene.getRootRegion();
272
+ const rootRegion = this.$module.scene.getRootRegion();
293
273
  const targetObjects = findObjectsWithNames(rootRegion, names,
294
- regionPath);
274
+ regionPath, true);
295
275
  this.changeHoverByPrimitives(targetObjects, propagate);
296
276
  },
297
277
  changeActiveByNode: function (node, propagate) {
298
- if (node.primitives)
299
- this.changeActiveByPrimitives(node.primitives, propagate);
278
+ if (node.isPrimitives) {
279
+ const targetObjects = this.getZincObjectsFromNode(node, false);
280
+ this.changeActiveByPrimitives(targetObjects, propagate);
281
+ }
300
282
  },
301
283
  changeHoverByNode: function (node, propagate) {
302
- if (node.primitives)
303
- this.changeHoverByPrimitives(node.primitives, propagate);
284
+ if (node.isPrimitives) {
285
+ const targetObjects = this.getZincObjectsFromNode(node, false);
286
+ this.changeHoverByPrimitives(targetObjects, propagate);
287
+ }
304
288
  },
305
289
  /**
306
290
  * Unselect the current selected region.
@@ -328,8 +312,10 @@ export default {
328
312
  this.$emit("object-selected", undefined);
329
313
  },
330
314
  getColour: function (nodeData) {
315
+ //Do not need to check for primitives as this is checked on the template
331
316
  if (nodeData) {
332
- let graphic = nodeData.primitives[0];
317
+ const targetObjects = this.getZincObjectsFromNode(nodeData, false);
318
+ let graphic = targetObjects[0];
333
319
  if (graphic) {
334
320
  let hex = graphic.getColourHex();
335
321
  if (hex) return "#" + hex;
@@ -337,19 +323,43 @@ export default {
337
323
  }
338
324
  return "#FFFFFF";
339
325
  },
326
+ getZincObjectsFromNode: function(node, transverse) {
327
+ const rootRegion = this.$module.scene.getRootRegion();
328
+ return findObjectsWithNames(rootRegion, node.label,
329
+ node.regionPath, transverse);
330
+ },
331
+ //Set this right at the beginning.
332
+ setModule: function (moduleIn) {
333
+ this.$module = moduleIn;
334
+ this.$module.primitiveData.geometries.forEach(zincObject => {
335
+ this.zincObjectAdded(zincObject);
336
+ });
337
+ this.$module.primitiveData.lines.forEach(zincObject => {
338
+ this.zincObjectAdded(zincObject);
339
+ });
340
+ this.$module.primitiveData.glyphsets.forEach(zincObject => {
341
+ this.zincObjectAdded(zincObject);
342
+ });
343
+ this.$module.primitiveData.pointsets.forEach(zincObject => {
344
+ this.zincObjectAdded(zincObject);
345
+ });
346
+ this.$module.addOrganPartAddedCallback(this.zincObjectAdded);
347
+ this.__nodeNumbers = 1;
348
+ },
340
349
  setColour: function (nodeData, value) {
341
- if (nodeData && nodeData.primitives) {
342
- nodeData.primitives.forEach(primitive => {
350
+ if (nodeData && nodeData.isPrimitives) {
351
+ const targetObjects = this.getZincObjectsFromNode(nodeData, false);
352
+ targetObjects.forEach(primitive => {
343
353
  let hexString = value.replace("#", "0x");
344
354
  primitive.setColourHex(hexString);
345
355
  });
346
356
  }
347
357
  },
348
358
  viewAll: function () {
349
- this.module.viewAll();
359
+ this.$module.viewAll();
350
360
  },
351
361
  visibilityToggle: function (item, event) {
352
- this.module.changeOrganPartsVisibility(item, event);
362
+ this.$module.changeOrganPartsVisibility(item, event);
353
363
  if (event == false) {
354
364
  if (this.activeRegion === item) {
355
365
  this.removeActive(true);
@@ -366,9 +376,15 @@ export default {
366
376
  setTreeVisibility: function(node, list) {
367
377
  let flag = false;
368
378
  if (list.includes(node.id)) flag = true;
369
- if (node.region) node.region.setVisibility(flag);
370
- if (node.primitives) node.primitives.forEach(primitive => primitive.setVisibility(flag))
371
- if (node.children) node.children.forEach(child => this.setTreeVisibility(child, list));
379
+ const region = this.$module.scene.getRootRegion().findChildFromPath(node.regionPath);
380
+ if (node.isRegion)
381
+ region.setVisibility(flag);
382
+ if (node.isPrimitives) {
383
+ const primitives = region.findObjectsWithGroupName(node.label);
384
+ primitives.forEach(primitive => primitive.setVisibility(flag))
385
+ }
386
+ if (node.children)
387
+ node.children.forEach(child => this.setTreeVisibility(child, list));
372
388
  },
373
389
  checkAllKeys: function () {
374
390
  const keysList = [];
@@ -60,7 +60,7 @@ exports.GraphicsHighlight = function() {
60
60
  }
61
61
 
62
62
  this.setHighlighted = function(objects) {
63
- const previousHighlightedObjects = currentHighlightedObjects;
63
+ const previousHighlightedObjects = [...currentHighlightedObjects];
64
64
  _this.resetHighlighted();
65
65
  // Selected object cannot be highlighted
66
66
  const array = getUnmatchingObjects(objects, currentSelectedObjects);
@@ -75,9 +75,9 @@ exports.GraphicsHighlight = function() {
75
75
 
76
76
  this.setSelected = function(objects) {
77
77
  // first find highlighted object that are not selected
78
- const previousHSelectedObjects = currentSelectedObjects;
78
+ const previousHSelectedObjects = [...currentSelectedObjects];
79
79
  const array = getUnmatchingObjects(currentHighlightedObjects, objects);
80
- currentHighlightedObjects = array;
80
+ _this.resetHighlighted();
81
81
  _this.resetSelected();
82
82
  const fullList = getFullListOfObjects(objects);
83
83
  for (let i = 0; i < fullList.length; i++) {
@@ -9,12 +9,15 @@ const OrgansSceneData = function() {
9
9
  this.currentSpecies = "";
10
10
  this.metaURL = "";
11
11
  this.viewURL = "";
12
+ this.currentTime = 0.0;
13
+ this.timeVarying = false;
14
+ }
15
+
16
+ const PrimitiveData = function () {
12
17
  this.geometries = [];
13
18
  this.lines = [];
14
19
  this.glyphsets = [];
15
20
  this.pointsets = [];
16
- this.currentTime = 0.0;
17
- this.timeVarying = false;
18
21
  }
19
22
 
20
23
  /**
@@ -36,6 +39,7 @@ const OrgansSceneData = function() {
36
39
  const _this = this;
37
40
  let pickerScene = undefined;
38
41
  this.sceneData = new OrgansSceneData();
42
+ this.primitiveData = new PrimitiveData();
39
43
  const timeChangedCallbacks = new Array();
40
44
  const sceneChangedCallbacks = new Array();
41
45
  const organPartAddedCallbacks = new Array();
@@ -350,15 +354,15 @@ const OrgansSceneData = function() {
350
354
  }
351
355
  }
352
356
 
353
- const addOrganPartToSceneData = function(zincObject) {
357
+ const addOrganPartToPrimitiveData = function(zincObject) {
354
358
  if (zincObject.isGeometry) {
355
- _this.sceneData.geometries.push(zincObject);
359
+ _this.primitiveData.geometries.push(zincObject);
356
360
  } else if (zincObject.isGlyphset) {
357
- _this.sceneData.glyphsets.push(zincObject);
361
+ _this.primitiveData.glyphsets.push(zincObject);
358
362
  } else if (zincObject.isLines) {
359
- _this.sceneData.lines.push(zincObject);
363
+ _this.primitiveData.lines.push(zincObject);
360
364
  } else if (zincObject.isPointset) {
361
- _this.sceneData.pointsets.push(zincObject);
365
+ _this.primitiveData.pointsets.push(zincObject);
362
366
  }
363
367
  }
364
368
 
@@ -368,7 +372,7 @@ const OrgansSceneData = function() {
368
372
  }
369
373
  if (useDefautColour)
370
374
  modelsLoader.setGeometryColour(zincObject, systemName, partName);
371
- addOrganPartToSceneData(zincObject);
375
+ addOrganPartToPrimitiveData(zincObject);
372
376
  const annotation = new (require('./annotation').annotation)();
373
377
  const region = zincObject.region.getFullPath();
374
378
  annotation.data = {species:_this.sceneData.currentSpecies, system:systemName,
@@ -458,10 +462,10 @@ const OrgansSceneData = function() {
458
462
  _this.sceneData.currentSystem = systemName;
459
463
  _this.sceneData.currentPart = partName;
460
464
  _this.sceneData.currentTime = 0.0;
461
- _this.sceneData.geometries.splice(0);
462
- _this.sceneData.lines.splice(0);
463
- _this.sceneData.glyphsets.splice(0);
464
- _this.sceneData.pointsets.splice(0);
465
+ _this.primitiveData.geometries.splice(0);
466
+ _this.primitiveData.lines.splice(0);
467
+ _this.primitiveData.glyphsets.splice(0);
468
+ _this.primitiveData.pointsets.splice(0);
465
469
  _this.sceneData.timeVarying = false;
466
470
  // This is used as title
467
471
  let name = "";
@@ -18,14 +18,18 @@ export const extractAllIds = (item, list) => {
18
18
  item.children.forEach(child => extractAllIds(child, list));
19
19
  }
20
20
 
21
- export const findObjectsWithNames = (rootRegion, names, regionPath) => {
21
+ export const findObjectsWithNames = (rootRegion, names, regionPath, transverse) => {
22
22
  let targetRegion = rootRegion;
23
23
  const targetObjects = [];
24
24
  if (regionPath)
25
25
  targetRegion = rootRegion.findChildFromPath(regionPath);
26
26
  if (targetRegion) {
27
- names.forEach(name => {
28
- const temp = targetRegion.findObjectsWithGroupName(name, true);
27
+ const isArray = Array.isArray(names);
28
+ let array = names;
29
+ if (!isArray)
30
+ array = [array];
31
+ array.forEach(name => {
32
+ const temp = targetRegion.findObjectsWithGroupName(name, transverse);
29
33
  targetObjects.push(...temp);
30
34
  });
31
35
  }