@abi-software/scaffoldvuer 1.21.1-beta.2 → 1.21.1-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.
- package/README.md +31 -12
- package/dist/index.html +9 -6
- package/dist/scaffoldvuer.js +11917 -11223
- package/dist/scaffoldvuer.umd.cjs +48 -48
- package/dist/style.css +1 -1
- package/eslint.config.js +37 -9
- package/package.json +9 -3
- package/public/index.html +9 -6
- package/src/App.vue +312 -279
- package/src/ScaffoldVuer-wc.js +4 -4
- package/src/app/DropZone.vue +11 -27
- package/src/app/ModelsInformation.js +22 -19
- package/src/app/ModelsTable.vue +42 -65
- package/src/app/TextureDemos.js +38 -64
- package/src/assets/_variables.scss +12 -10
- package/src/components/GlyphsControls.vue +3 -23
- package/src/components/LinesControls.vue +27 -66
- package/src/components/OpacityControls.vue +22 -26
- package/src/components/PointsControls.vue +20 -71
- package/src/components/PrimitiveControls.vue +35 -49
- package/src/components/ScaffoldOverlay.vue +63 -63
- package/src/components/ScaffoldTooltip.vue +36 -49
- package/src/components/ScaffoldTreeControls.vue +81 -129
- package/src/components/ScaffoldVuer.vue +485 -492
- package/src/components/TextureSlidesControls.vue +22 -64
- package/src/components/TransformationControls.vue +15 -42
- package/src/components/index.js +2 -2
- package/src/main.js +16 -18
- package/src/scripts/Annotation.js +3 -3
- package/src/scripts/BaseModule.js +26 -30
- package/src/scripts/EventNotifier.js +30 -36
- package/src/scripts/GraphicsHighlight.js +43 -50
- package/src/scripts/LocalFilesHelper.js +27 -26
- package/src/scripts/MappedNerves.js +2139 -697
- package/src/scripts/MappedOrgans.js +24 -25
- package/src/scripts/OrgansRenderer.js +445 -425
- package/src/scripts/RendererModule.js +129 -122
- package/src/scripts/Search.js +135 -151
- package/src/scripts/Utilities.js +129 -127
- package/src/scripts/WebGL.js +57 -91
- package/src/scripts/niftiHelper.js +3 -3
- package/src/store/index.js +7 -7
- package/vite.config.js +50 -50
- package/vite.static-build.js +7 -7
- package/vuese-generator.js +48 -56
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import GPU_SUPPORT from './WebGL';
|
|
2
2
|
import Zinc from 'zincjs';
|
|
3
3
|
const THREE = Zinc.THREE;
|
|
4
4
|
import { BaseModule } from './BaseModule';
|
|
5
|
-
import { EVENT_TYPE } from
|
|
6
|
-
import GraphicsHighlight from
|
|
7
|
-
import { objectsToZincObjects } from
|
|
5
|
+
import { EVENT_TYPE } from './EventNotifier';
|
|
6
|
+
import GraphicsHighlight from './GraphicsHighlight';
|
|
7
|
+
import { objectsToZincObjects } from './Utilities';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Create a {@link Zinc.Renderer} on the dom element with corresponding elementID.
|
|
@@ -12,22 +12,29 @@ import { objectsToZincObjects } from "./Utilities";
|
|
|
12
12
|
* @returns {Zinc.Renderer}
|
|
13
13
|
*/
|
|
14
14
|
const createRenderer = async function () {
|
|
15
|
-
const localContainer = document.createElement(
|
|
16
|
-
let localRenderer = undefined
|
|
17
|
-
localContainer.style.height =
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
const localContainer = document.createElement('div');
|
|
16
|
+
let localRenderer = undefined;
|
|
17
|
+
localContainer.style.height = '100%';
|
|
18
|
+
if (await GPU_SUPPORT.isRendererSupported()) {
|
|
19
|
+
try {
|
|
20
|
+
localRenderer = new Zinc.Renderer(localContainer, window);
|
|
21
|
+
Zinc.defaultMaterialColor = 0xffff9c;
|
|
22
|
+
await localRenderer.initialiseVisualisation();
|
|
23
|
+
localRenderer.playAnimation = false;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
//Device or context creation can still fail after the support check.
|
|
26
|
+
console.error('Failed to initialise the renderer.', error);
|
|
27
|
+
localRenderer = undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (!localRenderer) {
|
|
31
|
+
const warning = GPU_SUPPORT.getErrorMessage();
|
|
25
32
|
localContainer.appendChild(warning);
|
|
26
33
|
}
|
|
27
|
-
return {Zinc,
|
|
28
|
-
}
|
|
34
|
+
return { Zinc, renderer: localRenderer, container: localContainer };
|
|
35
|
+
};
|
|
29
36
|
|
|
30
|
-
const RendererModule = function()
|
|
37
|
+
const RendererModule = function () {
|
|
31
38
|
BaseModule.call(this);
|
|
32
39
|
this.scene = undefined;
|
|
33
40
|
this.rendererContainer = undefined;
|
|
@@ -39,20 +46,18 @@ const RendererModule = function() {
|
|
|
39
46
|
this.selectedCenter = undefined;
|
|
40
47
|
this.liveUpdatesObjects = undefined;
|
|
41
48
|
this.ignorePreviousSelected = false;
|
|
42
|
-
}
|
|
49
|
+
};
|
|
43
50
|
|
|
44
51
|
RendererModule.prototype = Object.create(BaseModule.prototype);
|
|
45
52
|
|
|
46
|
-
RendererModule.prototype.getIntersectedObject = function(intersects) {
|
|
47
|
-
|
|
48
|
-
const typeMap = intersects.map(intersect => {
|
|
49
|
-
if (intersect && intersect.object &&
|
|
50
|
-
intersect.object.userData) {
|
|
53
|
+
RendererModule.prototype.getIntersectedObject = function (intersects) {
|
|
54
|
+
if (intersects) {
|
|
55
|
+
const typeMap = intersects.map((intersect) => {
|
|
56
|
+
if (intersect && intersect.object && intersect.object.userData) {
|
|
51
57
|
if (intersect.object.userData.isMarker) {
|
|
52
58
|
return 1;
|
|
53
|
-
} else if (intersect.object.name &&
|
|
54
|
-
intersect.object.
|
|
55
|
-
if (intersect.object.name === "_Unnamed") {
|
|
59
|
+
} else if (intersect.object.name && intersect.object.userData.isZincObject) {
|
|
60
|
+
if (intersect.object.name === '_Unnamed') {
|
|
56
61
|
return 3;
|
|
57
62
|
} else {
|
|
58
63
|
return 2;
|
|
@@ -68,14 +73,13 @@ RendererModule.prototype.getIntersectedObject = function(intersects) {
|
|
|
68
73
|
}
|
|
69
74
|
//Proritise objects that is not called _Unnamed
|
|
70
75
|
i = typeMap.indexOf(2);
|
|
71
|
-
i =
|
|
76
|
+
i = i > -1 ? i : typeMap.indexOf(3);
|
|
72
77
|
return intersects[i];
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
};
|
|
77
81
|
|
|
78
|
-
RendererModule.prototype.getAnnotationsFromObjects = function(objects, extraData) {
|
|
82
|
+
RendererModule.prototype.getAnnotationsFromObjects = function (objects, extraData) {
|
|
79
83
|
const annotations = [];
|
|
80
84
|
for (var i = 0; i < objects.length; i++) {
|
|
81
85
|
const zincObject = objects[i].userData;
|
|
@@ -90,7 +94,7 @@ RendererModule.prototype.getAnnotationsFromObjects = function(objects, extraData
|
|
|
90
94
|
if (annotation && annotation.data) {
|
|
91
95
|
if (extraData && 'instanceId' in extraData) {
|
|
92
96
|
annotation.data.id = glyphset.getLabel(extraData.instanceId);
|
|
93
|
-
} else if (objects[i].name && objects[i].name !=
|
|
97
|
+
} else if (objects[i].name && objects[i].name != '') {
|
|
94
98
|
annotation.data.id = objects[i].name;
|
|
95
99
|
} else {
|
|
96
100
|
annotation.data.id = glyphset.groupName;
|
|
@@ -98,7 +102,7 @@ RendererModule.prototype.getAnnotationsFromObjects = function(objects, extraData
|
|
|
98
102
|
}
|
|
99
103
|
} else {
|
|
100
104
|
annotation = zincObject.userData ? zincObject.userData.annotation : undefined;
|
|
101
|
-
if (annotation && annotation.data){
|
|
105
|
+
if (annotation && annotation.data) {
|
|
102
106
|
annotation.data.id = objects[i].name;
|
|
103
107
|
}
|
|
104
108
|
}
|
|
@@ -108,20 +112,22 @@ RendererModule.prototype.getAnnotationsFromObjects = function(objects, extraData
|
|
|
108
112
|
annotation.data.zincObject = zincObject;
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
|
-
if (annotation)
|
|
112
|
-
annotations.push(annotation);
|
|
115
|
+
if (annotation) annotations.push(annotation);
|
|
113
116
|
}
|
|
114
|
-
|
|
115
|
-
}
|
|
117
|
+
return annotations;
|
|
118
|
+
};
|
|
116
119
|
|
|
117
|
-
RendererModule.prototype.setHighlightedByObjects = function(
|
|
118
|
-
objects,
|
|
120
|
+
RendererModule.prototype.setHighlightedByObjects = function (
|
|
121
|
+
objects,
|
|
122
|
+
coords,
|
|
123
|
+
extraData,
|
|
124
|
+
propagateChanges,
|
|
125
|
+
) {
|
|
119
126
|
const zincObjects = objectsToZincObjects(objects);
|
|
120
127
|
const changed = this.graphicsHighlight.setHighlighted(objects);
|
|
121
128
|
if (propagateChanges) {
|
|
122
129
|
let eventType = EVENT_TYPE.MOVE;
|
|
123
|
-
if (changed)
|
|
124
|
-
eventType = EVENT_TYPE.HIGHLIGHTED;
|
|
130
|
+
if (changed) eventType = EVENT_TYPE.HIGHLIGHTED;
|
|
125
131
|
const annotations = this.getAnnotationsFromObjects(objects, extraData);
|
|
126
132
|
if (annotations.length > 0) {
|
|
127
133
|
annotations[0].coords = coords;
|
|
@@ -130,25 +136,27 @@ RendererModule.prototype.setHighlightedByObjects = function(
|
|
|
130
136
|
this.publishChanges(annotations, eventType, zincObjects);
|
|
131
137
|
}
|
|
132
138
|
return changed;
|
|
133
|
-
}
|
|
139
|
+
};
|
|
134
140
|
|
|
141
|
+
RendererModule.prototype.setHighlightedByZincObjects = function (
|
|
142
|
+
zincObjects,
|
|
143
|
+
coords,
|
|
144
|
+
extraData,
|
|
145
|
+
propagateChanges,
|
|
146
|
+
) {
|
|
147
|
+
let morphs = [];
|
|
148
|
+
if (zincObjects) {
|
|
149
|
+
zincObjects.forEach((zincObject) => {
|
|
150
|
+
if (zincObject && zincObject.getMorph()) morphs.push(zincObject.getMorph());
|
|
151
|
+
});
|
|
152
|
+
}
|
|
135
153
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
let morphs = [];
|
|
139
|
-
if (zincObjects) {
|
|
140
|
-
zincObjects.forEach(zincObject => {
|
|
141
|
-
if (zincObject && zincObject.getMorph())
|
|
142
|
-
morphs.push(zincObject.getMorph());
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return this.setHighlightedByObjects(morphs, coords, extraData, propagateChanges);
|
|
147
|
-
}
|
|
154
|
+
return this.setHighlightedByObjects(morphs, coords, extraData, propagateChanges);
|
|
155
|
+
};
|
|
148
156
|
|
|
149
|
-
RendererModule.prototype.setupLiveCoordinates = function(zincObjects) {
|
|
157
|
+
RendererModule.prototype.setupLiveCoordinates = function (zincObjects) {
|
|
150
158
|
this.liveUpdatesObjects = zincObjects;
|
|
151
|
-
if (zincObjects &&
|
|
159
|
+
if (zincObjects && zincObjects.length > 0) {
|
|
152
160
|
const boundingBox = this.scene.getBoundingBoxOfZincObjects(zincObjects);
|
|
153
161
|
let newSelectedCenter = new THREE.Vector3();
|
|
154
162
|
if (boundingBox) {
|
|
@@ -164,12 +172,15 @@ RendererModule.prototype.setupLiveCoordinates = function(zincObjects) {
|
|
|
164
172
|
} else {
|
|
165
173
|
this.selectedCenter = undefined;
|
|
166
174
|
}
|
|
167
|
-
}
|
|
175
|
+
};
|
|
168
176
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
177
|
+
RendererModule.prototype.setSelectedByObjects = function (
|
|
178
|
+
objects,
|
|
179
|
+
coords,
|
|
180
|
+
extraData,
|
|
181
|
+
propagateChanges,
|
|
182
|
+
) {
|
|
183
|
+
let changed;
|
|
173
184
|
if (this.selectObjectOnPick) {
|
|
174
185
|
changed = this.graphicsHighlight.setSelected(objects);
|
|
175
186
|
} else {
|
|
@@ -191,13 +202,17 @@ RendererModule.prototype.setSelectedByObjects = function(
|
|
|
191
202
|
}
|
|
192
203
|
}
|
|
193
204
|
return changed;
|
|
194
|
-
}
|
|
205
|
+
};
|
|
195
206
|
|
|
196
|
-
RendererModule.prototype.setSelectedByZincObjects = function(
|
|
197
|
-
zincObjects,
|
|
207
|
+
RendererModule.prototype.setSelectedByZincObjects = function (
|
|
208
|
+
zincObjects,
|
|
209
|
+
coords,
|
|
210
|
+
extraData,
|
|
211
|
+
propagateChanges,
|
|
212
|
+
) {
|
|
198
213
|
let morphs = [];
|
|
199
214
|
if (zincObjects) {
|
|
200
|
-
zincObjects.forEach(zincObject => {
|
|
215
|
+
zincObjects.forEach((zincObject) => {
|
|
201
216
|
if (zincObject) {
|
|
202
217
|
const morph = zincObject.getMorph();
|
|
203
218
|
if (morph) {
|
|
@@ -208,101 +223,93 @@ RendererModule.prototype.setSelectedByZincObjects = function(
|
|
|
208
223
|
}
|
|
209
224
|
|
|
210
225
|
return this.setSelectedByObjects(morphs, coords, extraData, propagateChanges);
|
|
211
|
-
}
|
|
226
|
+
};
|
|
212
227
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
228
|
+
// Unused function, but keep it for reference.
|
|
229
|
+
// const addGlyphToArray = function (objects) {
|
|
230
|
+
// return function (glyph) {
|
|
231
|
+
// objects.push(glyph.getMesh());
|
|
232
|
+
// };
|
|
233
|
+
// };
|
|
218
234
|
|
|
219
|
-
RendererModule.prototype.findObjectsByGroupName = function(groupName) {
|
|
235
|
+
RendererModule.prototype.findObjectsByGroupName = function (groupName) {
|
|
220
236
|
return this.scene.findObjectsWithGroupName(groupName);
|
|
221
|
-
}
|
|
237
|
+
};
|
|
222
238
|
|
|
223
|
-
RendererModule.prototype.setHighlightedByGroupName = function(groupName, propagateChanges) {
|
|
239
|
+
RendererModule.prototype.setHighlightedByGroupName = function (groupName, propagateChanges) {
|
|
224
240
|
const objects = this.findObjectsByGroupName(groupName);
|
|
225
241
|
return this.setHighlightedByObjects(objects, undefined, {}, propagateChanges);
|
|
226
|
-
}
|
|
242
|
+
};
|
|
227
243
|
|
|
228
|
-
RendererModule.prototype.setSelectedByGroupName = function(groupName, propagateChanges) {
|
|
244
|
+
RendererModule.prototype.setSelectedByGroupName = function (groupName, propagateChanges) {
|
|
229
245
|
const objects = this.findObjectsByGroupName(groupName);
|
|
230
246
|
return this.setSelectedByObjects(objects, undefined, {}, propagateChanges);
|
|
231
|
-
}
|
|
247
|
+
};
|
|
232
248
|
|
|
233
|
-
RendererModule.prototype.changeBackgroundColour = function(backgroundColourString) {
|
|
249
|
+
RendererModule.prototype.changeBackgroundColour = function (backgroundColourString) {
|
|
234
250
|
const colour = new THREE.Color(backgroundColourString);
|
|
235
251
|
if (this.zincRenderer) {
|
|
236
252
|
let internalRenderer = this.zincRenderer.getThreeJSRenderer();
|
|
237
|
-
internalRenderer.setClearColor(
|
|
253
|
+
internalRenderer.setClearColor(colour, 1);
|
|
238
254
|
}
|
|
239
|
-
}
|
|
255
|
+
};
|
|
240
256
|
|
|
241
|
-
RendererModule.prototype.resetView = function() {
|
|
242
|
-
if (this.zincRenderer)
|
|
243
|
-
|
|
244
|
-
}
|
|
257
|
+
RendererModule.prototype.resetView = function () {
|
|
258
|
+
if (this.zincRenderer) this.zincRenderer.resetView();
|
|
259
|
+
};
|
|
245
260
|
|
|
246
|
-
RendererModule.prototype.viewAll = function() {
|
|
247
|
-
if (this.zincRenderer)
|
|
248
|
-
|
|
249
|
-
}
|
|
261
|
+
RendererModule.prototype.viewAll = function () {
|
|
262
|
+
if (this.zincRenderer) this.zincRenderer.viewAll();
|
|
263
|
+
};
|
|
250
264
|
|
|
251
265
|
/**
|
|
252
266
|
* Start the animation and let the renderer to processs with
|
|
253
267
|
* time progression
|
|
254
268
|
*/
|
|
255
|
-
RendererModule.prototype.playAnimation = function(flag) {
|
|
256
|
-
if (this.zincRenderer)
|
|
257
|
-
|
|
258
|
-
}
|
|
269
|
+
RendererModule.prototype.playAnimation = function (flag) {
|
|
270
|
+
if (this.zincRenderer) this.zincRenderer.playAnimation = flag;
|
|
271
|
+
};
|
|
259
272
|
|
|
260
273
|
/**
|
|
261
|
-
* Set the speed of playback
|
|
262
|
-
*/
|
|
263
|
-
RendererModule.prototype.setPlayRate = function(value) {
|
|
264
|
-
if (this.zincRenderer)
|
|
265
|
-
|
|
266
|
-
}
|
|
274
|
+
* Set the speed of playback
|
|
275
|
+
*/
|
|
276
|
+
RendererModule.prototype.setPlayRate = function (value) {
|
|
277
|
+
if (this.zincRenderer) this.zincRenderer.setPlayRate(value);
|
|
278
|
+
};
|
|
267
279
|
|
|
268
280
|
/**
|
|
269
|
-
* Get the speed of playback
|
|
270
|
-
*/
|
|
271
|
-
RendererModule.prototype.getPlayRate = function(
|
|
272
|
-
if (this.zincRenderer)
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
return 0.0;
|
|
276
|
-
}
|
|
281
|
+
* Get the speed of playback
|
|
282
|
+
*/
|
|
283
|
+
RendererModule.prototype.getPlayRate = function (_value) {
|
|
284
|
+
if (this.zincRenderer) return this.zincRenderer.getPlayRate();
|
|
285
|
+
else return 0.0;
|
|
286
|
+
};
|
|
277
287
|
|
|
278
|
-
|
|
288
|
+
/** Initialise everything in the renderer, including the 3D renderer,
|
|
279
289
|
* and picker for the 3D renderer.
|
|
280
290
|
*
|
|
281
291
|
*/
|
|
282
|
-
RendererModule.prototype.initialiseRenderer = async function(displayAreaIn) {
|
|
292
|
+
RendererModule.prototype.initialiseRenderer = async function (displayAreaIn) {
|
|
283
293
|
if (this.zincRenderer === undefined || this.rendererContainer === undefined) {
|
|
284
294
|
let returnedValue = await createRenderer();
|
|
285
|
-
this.Zinc = returnedValue[
|
|
286
|
-
this.zincRenderer = returnedValue[
|
|
287
|
-
this.rendererContainer = returnedValue[
|
|
295
|
+
this.Zinc = returnedValue['Zinc'];
|
|
296
|
+
this.zincRenderer = returnedValue['renderer'];
|
|
297
|
+
this.rendererContainer = returnedValue['container'];
|
|
288
298
|
}
|
|
289
299
|
if (displayAreaIn) {
|
|
290
300
|
this.displayArea = displayAreaIn;
|
|
291
|
-
this.displayArea.appendChild(
|
|
292
|
-
if (this.zincRenderer)
|
|
293
|
-
this.zincRenderer.animate();
|
|
301
|
+
this.displayArea.appendChild(this.rendererContainer);
|
|
302
|
+
if (this.zincRenderer) this.zincRenderer.animate();
|
|
294
303
|
}
|
|
295
|
-
}
|
|
304
|
+
};
|
|
296
305
|
|
|
297
|
-
RendererModule.prototype.destroy = function() {
|
|
306
|
+
RendererModule.prototype.destroy = function () {
|
|
298
307
|
if (this.zincRenderer) {
|
|
299
308
|
this.zincRenderer.dispose();
|
|
300
309
|
this.zincRenderer.getThreeJSRenderer().dispose();
|
|
301
310
|
this.zincRenderer = undefined;
|
|
302
311
|
}
|
|
303
|
-
BaseModule.prototype.destroy.call(
|
|
304
|
-
}
|
|
312
|
+
BaseModule.prototype.destroy.call(this);
|
|
313
|
+
};
|
|
305
314
|
|
|
306
|
-
export {
|
|
307
|
-
RendererModule
|
|
308
|
-
}
|
|
315
|
+
export { RendererModule };
|