@abi-software/scaffoldvuer 0.1.52-beta.0 → 0.1.52-beta.3

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.
@@ -58,7 +58,6 @@ RendererModule.prototype.getIntersectedObject = function(intersects) {
58
58
 
59
59
  RendererModule.prototype.getAnnotationsFromObjects = function(objects) {
60
60
  const annotations = [];
61
- let count = 0;
62
61
  for (var i = 0; i < objects.length; i++) {
63
62
  const zincObject = objects[i].userData;
64
63
  let annotation = undefined;
@@ -67,7 +66,7 @@ RendererModule.prototype.getAnnotationsFromObjects = function(objects) {
67
66
  const glyphset = zincObject;
68
67
  if (zincObject.isGlyph)
69
68
  glyphset = zincObject.getGlyphset();
70
- annotation = glyphset.userData ? glyphset.userData[0] : undefined;
69
+ annotation = glyphset.userData ? glyphset.userData.annotation : undefined;
71
70
  if (annotation && annotation.data) {
72
71
  if (objects[i].name && objects[i].name != "")
73
72
  annotation.data.id = objects[i].name;
@@ -75,23 +74,28 @@ RendererModule.prototype.getAnnotationsFromObjects = function(objects) {
75
74
  annotation.data.id = glyphset.groupName;
76
75
  }
77
76
  } else {
78
- annotation = zincObject.userData ? zincObject.userData[0] : undefined;
77
+ annotation = zincObject.userData ? zincObject.userData.annotation : undefined;
79
78
  if (annotation && annotation.data){
80
79
  annotation.data.id = objects[i].name;
81
80
  }
82
81
  }
83
82
  }
84
83
  if (annotation)
85
- annotations[count++] = annotation;
84
+ annotations.push(annotation);
86
85
  }
87
86
  return annotations;
88
87
  }
89
88
 
90
- RendererModule.prototype.setHighlightedByObjects = function(objects, propagateChanges) {
89
+ RendererModule.prototype.setHighlightedByObjects = function(
90
+ objects, coords, propagateChanges) {
91
91
  const changed = this.graphicsHighlight.setHighlighted(objects);
92
- if (changed && propagateChanges) {
93
- const eventType = require("./eventNotifier").EVENT_TYPE.HIGHLIGHTED;
92
+ if (propagateChanges) {
93
+ eventType = require("./eventNotifier").EVENT_TYPE.MOVE;
94
+ if (changed)
95
+ eventType = require("./eventNotifier").EVENT_TYPE.HIGHLIGHTED;
94
96
  const annotations = this.getAnnotationsFromObjects(objects);
97
+ if (annotations.length > 0)
98
+ annotations[0].coords = coords;
95
99
  this.publishChanges(annotations, eventType);
96
100
  }
97
101
  return changed;
@@ -99,8 +103,8 @@ RendererModule.prototype.setHighlightedByObjects = function(objects, propagateCh
99
103
 
100
104
 
101
105
  RendererModule.prototype.setHighlightedByZincObject = function(
102
- zincObject, propagateChanges) {
103
- return this.setHighlightedByObjects([zincObject ? zincObject.morph : undefined], propagateChanges);
106
+ zincObject, coords, propagateChanges) {
107
+ return this.setHighlightedByObjects([zincObject ? zincObject.morph : undefined], coords,propagateChanges);
104
108
  }
105
109
 
106
110
  RendererModule.prototype.setupLiveCoordinates = function(zincObjects) {
@@ -139,7 +143,7 @@ RendererModule.prototype.objectsToZincObjects = function(objects) {
139
143
 
140
144
 
141
145
  RendererModule.prototype.setSelectedByObjects = function(
142
- objects, propagateChanges) {
146
+ objects, coords, propagateChanges) {
143
147
  const changed = this.graphicsHighlight.setSelected(objects);
144
148
  if (changed) {
145
149
  const zincObjects = this.objectsToZincObjects(objects);
@@ -147,6 +151,8 @@ RendererModule.prototype.setSelectedByObjects = function(
147
151
  if (propagateChanges) {
148
152
  const eventType = require("./eventNotifier").EVENT_TYPE.SELECTED;
149
153
  const annotations = this.getAnnotationsFromObjects(objects);
154
+ if (annotations.length > 0)
155
+ annotations[0].coords = coords;
150
156
  this.publishChanges(annotations, eventType);
151
157
  }
152
158
  }
@@ -154,8 +160,9 @@ RendererModule.prototype.setSelectedByObjects = function(
154
160
  }
155
161
 
156
162
  RendererModule.prototype.setSelectedByZincObject = function(
157
- zincObject, propagateChanges) {
158
- return this.setSelectedByObjects([zincObject ? zincObject.morph : undefined], propagateChanges);
163
+ zincObject, coords, propagateChanges) {
164
+ return this.setSelectedByObjects([zincObject ? zincObject.morph : undefined],
165
+ coords, propagateChanges);
159
166
  }
160
167
 
161
168
  const addGlyphToArray = function(objects) {
@@ -180,12 +187,12 @@ RendererModule.prototype.findObjectsByGroupName = function(groupName) {
180
187
 
181
188
  RendererModule.prototype.setHighlightedByGroupName = function(groupName, propagateChanges) {
182
189
  const objects = this.findObjectsByGroupName(groupName);
183
- return this.setHighlightedByObjects(objects, propagateChanges);
190
+ return this.setHighlightedByObjects(objects, undefined, propagateChanges);
184
191
  }
185
192
 
186
193
  RendererModule.prototype.setSelectedByGroupName = function(groupName, propagateChanges) {
187
194
  const objects = this.findObjectsByGroupName(groupName);
188
- return this.setSelectedByObjects(objects, propagateChanges);
195
+ return this.setSelectedByObjects(objects, undefined, propagateChanges);
189
196
  }
190
197
 
191
198
  RendererModule.prototype.changeBackgroundColour = function(backgroundColourString) {
@@ -1,4 +1,4 @@
1
- const EVENT_TYPE = { ALL: 0, SELECTED: 1, HIGHLIGHTED: 2 };
1
+ const EVENT_TYPE = { ALL: 0, SELECTED: 1, HIGHLIGHTED: 2, MOVE: 3 };
2
2
 
3
3
  const SelectionEvent = function(eventTypeIn, identifiersIn) {
4
4
  this.eventType = eventTypeIn;
@@ -41,6 +41,7 @@ const OrgansSceneData = function() {
41
41
  const organPartAddedCallbacks = new Array();
42
42
  let finishDownloadCallback = undefined;
43
43
  const modelsLoader = ModelsLoaderIn;
44
+ this.NDCCameraControl = undefined;
44
45
  _this.typeName = "Organ Viewer";
45
46
 
46
47
  this.getSceneData = function() {
@@ -82,6 +83,39 @@ const OrgansSceneData = function() {
82
83
  duration);
83
84
  _this.sceneData.currentTime = currentTime / duration * 100.0;
84
85
  }
86
+
87
+ this.toggleSyncControl = (flag) => {
88
+ let cameraControl = this.scene.getZincCameraControls();
89
+ if (flag) {
90
+ cameraControl.resetView();
91
+ this.NDCCameraControl = cameraControl.enableSyncControl();
92
+ } else {
93
+ cameraControl.disableSyncControl();
94
+ this.NDCCameraControl = undefined;
95
+ }
96
+ }
97
+
98
+ this.isSyncControl = () => {
99
+ return this.NDCCameraControl !== undefined;
100
+ }
101
+
102
+ this.setSyncControlZoomToBox = (box) => {
103
+ if (this.NDCCameraControl) {
104
+ this.NDCCameraControl.zoomToBox(box, 2);
105
+ }
106
+ }
107
+
108
+ this.setSyncControlCallback = (callback) => {
109
+ if (this.NDCCameraControl) {
110
+ this.NDCCameraControl.setEventCallback(callback);
111
+ }
112
+ }
113
+
114
+ this.setSyncControlCenterZoom = (center, zoom) => {
115
+ if (this.NDCCameraControl) {
116
+ this.NDCCameraControl.setCenterZoom(center, zoom);
117
+ }
118
+ }
85
119
 
86
120
  const postRenderSelectedCoordinatesUpdate = function() {
87
121
  if (_this.selectedCenter) {
@@ -185,18 +219,20 @@ const OrgansSceneData = function() {
185
219
  return function(intersects, window_x, window_y) {
186
220
  const intersected = _this.getIntersectedObject(intersects);
187
221
  const idObject = getIdObjectFromIntersect(intersected);
222
+ const coords = { x: window_x, y: window_y };
188
223
  if (idObject.id) {
189
- if (idObject.object.userData.isGlyph) {
224
+ if (idObject.object.userData.isGlyph) {
190
225
  if (idObject.object.name)
191
- _this.setSelectedByObjects([idObject.object], true);
226
+ _this.setSelectedByObjects([idObject.object], coords, true);
192
227
  else
193
- _this.setSelectedByZincObject(idObject.object.userData.getGlyphset(), true);
228
+ _this.setSelectedByZincObject(idObject.object.userData.getGlyphset(),
229
+ coords, true);
194
230
  } else {
195
- _this.setSelectedByObjects([idObject.object], true);
231
+ _this.setSelectedByObjects([idObject.object], coords, true);
196
232
  }
197
233
  return;
198
234
  } else {
199
- _this.setSelectedByObjects([], true);
235
+ _this.setSelectedByObjects([], coords, true);
200
236
  }
201
237
  }
202
238
  };
@@ -210,14 +246,15 @@ const OrgansSceneData = function() {
210
246
  return function(intersects, window_x, window_y) {
211
247
  const intersected = _this.getIntersectedObject(intersects);
212
248
  const idObject = getIdObjectFromIntersect(intersected);
249
+ const coords = { x: window_x, y: window_y };
213
250
  if (idObject.id) {
214
251
  _this.displayArea.style.cursor = "pointer";
215
- _this.setHighlightedByObjects([idObject.object], true);
252
+ _this.setHighlightedByObjects([idObject.object], coords, true);
216
253
  return;
217
254
  }
218
255
  else {
219
256
  _this.displayArea.style.cursor = "auto";
220
- _this.setHighlightedByObjects([], true);
257
+ _this.setHighlightedByObjects([], coords, true);
221
258
  }
222
259
  }
223
260
  };
@@ -312,37 +349,29 @@ const OrgansSceneData = function() {
312
349
  }
313
350
 
314
351
  const addOrganPartToSceneData = function(zincObject) {
315
- if (zincObject.groupName) {
316
- if (zincObject.isGeometry) {
317
- if (!_this.sceneData.geometries.includes(zincObject.groupName)) {
318
- _this.sceneData.geometries.push(zincObject.groupName);
319
- }
320
- } else if (zincObject.isGlyphset) {
321
- if (!_this.sceneData.glyphsets.includes(zincObject.groupName)) {
322
- _this.sceneData.glyphsets.push(zincObject.groupName);
323
- }
324
- } else if (zincObject.isLines) {
325
- if (!_this.sceneData.lines.includes(zincObject.groupName)) {
326
- _this.sceneData.lines.push(zincObject.groupName);
327
- }
328
- } else if (zincObject.isPointset) {
329
- if (!_this.sceneData.pointsets.includes(zincObject.groupName)) {
330
- _this.sceneData.pointsets.push(zincObject.groupName);
331
- }
332
- }
333
- }
352
+ if (zincObject.isGeometry) {
353
+ _this.sceneData.geometries.push(zincObject);
354
+ } else if (zincObject.isGlyphset) {
355
+ _this.sceneData.glyphsets.push(zincObject);
356
+ } else if (zincObject.isLines) {
357
+ _this.sceneData.lines.push(zincObject);
358
+ } else if (zincObject.isPointset) {
359
+ _this.sceneData.pointsets.push(zincObject);
360
+ }
334
361
  }
335
362
 
336
363
  const addOrganPart = function(systemName, partName, useDefautColour, zincObject) {
337
364
  for (let i = 0; i < organPartAddedCallbacks.length;i++) {
338
- organPartAddedCallbacks[i](zincObject.groupName, _this.scene.isTimeVarying(), zincObject);
365
+ organPartAddedCallbacks[i](zincObject, _this.scene.isTimeVarying());
339
366
  }
340
367
  if (useDefautColour)
341
368
  modelsLoader.setGeometryColour(zincObject, systemName, partName);
342
369
  addOrganPartToSceneData(zincObject);
343
370
  const annotation = new (require('./annotation').annotation)();
344
- annotation.data = {species:_this.sceneData.currentSpecies, system:systemName, part:partName, group:zincObject.groupName};
345
- zincObject.userData = [annotation];
371
+ const region = zincObject.region.getFullPath();
372
+ annotation.data = {species:_this.sceneData.currentSpecies, system:systemName,
373
+ part:partName, group:zincObject.groupName, region: region};
374
+ zincObject.userData["annotation"] = annotation;
346
375
  }
347
376
 
348
377
  /**