@abi-software/scaffoldvuer 0.1.56 → 0.1.58

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.
@@ -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
  }
@@ -1,544 +0,0 @@
1
- <template>
2
- <div
3
- class="traditional-location"
4
- :class="{ open: drawerOpen, close: !drawerOpen }"
5
- >
6
- <div class="traditional-container">
7
- <el-row>
8
- <el-col :span="12">
9
- <div class="regions-display-text">
10
- Regions
11
- </div>
12
- </el-col>
13
- <el-col :span="12">
14
- <el-checkbox
15
- v-model="checkAll"
16
- class="all-checkbox"
17
- :indeterminate="isIndeterminate"
18
- @change="handleCheckAllChange"
19
- >
20
- Display all
21
- </el-checkbox>
22
- </el-col>
23
- </el-row>
24
- <el-checkbox-group
25
- v-model="checkedItems"
26
- size="small"
27
- class="checkbox-group"
28
- @change="handleCheckedItemsChange"
29
- >
30
- <div class="checkbox-group-inner">
31
- <el-row
32
- v-for="item in sortedPrimitiveGroups"
33
- :key="item"
34
- :label="item"
35
- >
36
- <div class="checkbox-container">
37
- <el-checkbox
38
- class="my-checkbox"
39
- :label="item"
40
- :checked="true"
41
- :class="{ activeItem: activeRegion === item,
42
- hoverItem: hoverRegion === item }"
43
- @click.native="itemClicked(item, $event)"
44
- @change="visibilityToggle(item, $event)"
45
- @mouseover.native="checkboxHover(item)"
46
- >
47
- <el-color-picker
48
- :class="{ 'show-picker' : showColourPicker }"
49
- :value="getColour(item)"
50
- size="small"
51
- :popper-class="myPopperClass"
52
- @change="setColour(item, $event)"
53
- />
54
- {{ item }}
55
- </el-checkbox>
56
- </div>
57
- </el-row>
58
- </div>
59
- </el-checkbox-group>
60
- </div>
61
- <div
62
- class="drawer-button"
63
- :class="{ open: drawerOpen, close: !drawerOpen }"
64
- @click="toggleDrawer"
65
- >
66
- <i class="el-icon-arrow-left" />
67
- </div>
68
- </div>
69
- </template>
70
-
71
- <script>
72
- /* eslint-disable no-alert, no-console */
73
- import Vue from "vue";
74
- import { Checkbox, CheckboxGroup, ColorPicker, Row } from "element-ui";
75
- import lang from "element-ui/lib/locale/lang/en";
76
- import locale from "element-ui/lib/locale";
77
-
78
- const orderBy = require("lodash/orderBy");
79
- const uniq = require("lodash/uniq");
80
- locale.use(lang);
81
- Vue.use(Checkbox);
82
- Vue.use(CheckboxGroup);
83
- Vue.use(ColorPicker);
84
- Vue.use(Row);
85
-
86
- /**
87
- * A vue component for toggling visibility of various regions.
88
- */
89
- export default {
90
- name: "TraditionalControls",
91
- props: {
92
- /**
93
- * @ignore
94
- */
95
- module: {
96
- type: Object,
97
- default: undefined
98
- },
99
- /**
100
- * Enable/disable colour picker
101
- */
102
- showColourPicker: Boolean
103
- },
104
- data: function() {
105
- return {
106
- checkAll: true,
107
- isIndeterminate: false,
108
- checkedItems: [],
109
- sortedPrimitiveGroups: [],
110
- activeRegion: "",
111
- hoverRegion: "",
112
- myPopperClass: "hide-scaffold-colour-popup",
113
- drawerOpen: true
114
- };
115
- },
116
- watch: {
117
- showColourPicker: {
118
- immediate: true,
119
- handler: function() {
120
- if (this.showColourPicker) this.myPopperClass = "showPicker";
121
- else this.myPopperClass = "hide-scaffold-colour-popup";
122
- }
123
- }
124
- },
125
- created: function() {
126
- let tmpArray = this.module.sceneData.geometries.concat(
127
- this.module.sceneData.lines
128
- );
129
- tmpArray = tmpArray.concat(this.module.sceneData.glyphsets);
130
- tmpArray = uniq(tmpArray.concat(this.module.sceneData.pointset));
131
- this.sortedPrimitiveGroups = orderBy(tmpArray);
132
- this.module.addOrganPartAddedCallback(this.organsAdded);
133
- },
134
- destroyed: function() {
135
- this.sortedPrimitiveGroups = undefined;
136
- },
137
- methods: {
138
- /**
139
- * This is called when a new organ is read into the scene.
140
- */
141
- organsAdded: function(name) {
142
- if (name && name != "") {
143
- let tmpArray = uniq(this.sortedPrimitiveGroups.concat([name]));
144
- tmpArray = orderBy(tmpArray);
145
- const index = tmpArray.indexOf(undefined);
146
- if (index > -1) {
147
- tmpArray.splice(index, 1);
148
- }
149
- this.sortedPrimitiveGroups = tmpArray;
150
- }
151
- },
152
- /**
153
- * Select a region by its name.
154
- */
155
- changeActiveByNames: function(names, propagate) {
156
- let targetObject = this.getFirstZincObjectWithGroupName(name);
157
- if (targetObject && targetObject.getVisibility()) {
158
- this.activeRegion = name;
159
- this.$emit("object-selected", targetObject, propagate);
160
- } else {
161
- this.removeActive(propagate);
162
- }
163
- this.removeHover(propagate);
164
- },
165
- /**
166
- * Hover a region by its name.
167
- */
168
- changeHoverByName: function(name, propagate) {
169
- let targetObject = this.getFirstZincObjectWithGroupName(name);
170
- if (targetObject) {
171
- this.hoverRegion = name;
172
- this.$emit("object-hovered", targetObject, propagate);
173
- } else {
174
- this.removeHover(propagate);
175
- }
176
- },
177
- /**
178
- * Unselect the current selected region.
179
- */
180
- removeActive: function(propagate) {
181
- this.activeRegion = "";
182
- this.$emit("object-selected", undefined, propagate);
183
- },
184
- /**
185
- * Unselect the current hover region.
186
- */
187
- removeHover: function(propagate) {
188
- this.hoverRegion = "";
189
- this.$emit("object-hovered", undefined, propagate);
190
- },
191
- /**
192
- * Reset the controls.
193
- */
194
- clear: function() {
195
- this.sortedPrimitiveGroups = [];
196
- this.checkedItems = [];
197
- this.checkAll = true;
198
- this.isIndeterminate = false;
199
- this.activeRegion = "";
200
- this.hoverRegion = "";
201
- this.$emit("object-selected", undefined);
202
- },
203
- getFirstZincObjectWithGroupName: function(name) {
204
- if (this.module && this.module.scene) {
205
- let array = this.module.scene.findGeometriesWithGroupName(name);
206
- if (array.length > 0) return array[0];
207
- array = this.module.scene.findGlyphsetsWithGroupName(name);
208
- if (array.length > 0) return array[0];
209
- array = this.module.scene.findLinesWithGroupName(name);
210
- if (array.length > 0) return array[0];
211
- array = this.module.scene.findPointsetsWithGroupName(name);
212
- if (array.length > 0) return array[0];
213
- }
214
- return undefined;
215
- },
216
- getColour: function(name) {
217
- let graphic = this.getFirstZincObjectWithGroupName(name);
218
- if (graphic) {
219
- let hex = graphic.getColourHex();
220
- if (hex) return "#" + hex;
221
- }
222
- return "#FFFFFF";
223
- },
224
- setColour: function(name, value) {
225
- let graphic = this.getFirstZincObjectWithGroupName(name);
226
- if (graphic) {
227
- let hexString = value.replace("#", "0x");
228
- graphic.setColourHex(hexString);
229
- }
230
- },
231
- checkboxHover: function(name) {
232
- this.changeHoverByName(name, true);
233
- },
234
- itemClicked: function(name, event) {
235
- if (
236
- !(
237
- event.target.classList.contains("el-checkbox__inner") ||
238
- event.target.classList.contains("el-checkbox__original")
239
- )
240
- ) {
241
- this.changeActiveByNames([name], true);
242
- event.preventDefault();
243
- }
244
- },
245
- handleCheckedItemsChange: function() {
246
- let unnamed = this.checkedItems.includes(undefined) ? true: false;
247
- let checkedCount = this.checkedItems.length;
248
- if (unnamed)
249
- checkedCount--;
250
- this.checkAll = checkedCount === this.sortedPrimitiveGroups.length;
251
- this.isIndeterminate =
252
- checkedCount > 0 && checkedCount < this.sortedPrimitiveGroups.length;
253
- },
254
- handleCheckAllChange(val) {
255
- this.checkedItems = val ? [...this.sortedPrimitiveGroups] : [];
256
- this.isIndeterminate = false;
257
- for (let i = 0; i < this.sortedPrimitiveGroups.length; i++) {
258
- this.visibilityToggle(this.sortedPrimitiveGroups[i], this.checkAll);
259
- }
260
- },
261
- viewAll: function() {
262
- this.module.viewAll();
263
- },
264
- visibilityToggle: function(item, event) {
265
- this.module.changeOrganPartsVisibility(item, event);
266
- if (event == false) {
267
- if (this.activeRegion === item) {
268
- this.removeActive(true);
269
- }
270
- if (this.hoverRegion === item) {
271
- this.removeHover(true);
272
- }
273
- }
274
- },
275
- toggleDrawer: function() {
276
- this.drawerOpen = !this.drawerOpen;
277
- this.$emit("drawer-toggled", this.drawerOpen);
278
- },
279
- getState: function() {
280
- if (this.checkAll) {
281
- return { checkAll: true };
282
- }
283
- let checkedItems = [...this.checkedItems];
284
- const index = checkedItems.indexOf(undefined);
285
- if (index > -1) {
286
- checkedItems.splice(index, 1);
287
- }
288
- return { checkedItems: checkedItems };
289
- },
290
- setState: function(state) {
291
- if (state) {
292
- if (state.checkAll) {
293
- this.checkedItems = [...this.sortedPrimitiveGroups];
294
- for (let i = 0; i < this.sortedPrimitiveGroups.length; i++) {
295
- this.module.changeOrganPartsVisibility(
296
- this.sortedPrimitiveGroups[i],
297
- true
298
- );
299
- }
300
- } else if (state.checkedItems) {
301
- this.checkedItems = [...state.checkedItems];
302
- for (let i = 0; i < this.sortedPrimitiveGroups.length; i++) {
303
- let visible = this.checkedItems.includes(
304
- this.sortedPrimitiveGroups[i]);
305
- this.module.changeOrganPartsVisibility(
306
- this.sortedPrimitiveGroups[i],
307
- visible
308
- );
309
- }
310
- }
311
- }
312
- this.handleCheckedItemsChange();
313
- }
314
- }
315
- };
316
- </script>
317
-
318
- <!-- Add "scoped" attribute to limit CSS to this component only -->
319
- <style scoped lang="scss">
320
- @import "~element-ui/packages/theme-chalk/src/checkbox";
321
- @import "~element-ui/packages/theme-chalk/src/checkbox-group";
322
- @import "~element-ui/packages/theme-chalk/src/color-picker";
323
- @import "~element-ui/packages/theme-chalk/src/row";
324
-
325
- .checkbox-container {
326
- display: flex;
327
- cursor: pointer;
328
- }
329
-
330
- .traditional-location {
331
- position: absolute;
332
- bottom: 0px;
333
- transition: all 1s ease;
334
-
335
- &:focus{
336
- outline: none;
337
- }
338
- &.open {
339
- left: 0px;
340
- .traditional-container {
341
- opacity: 1;
342
- }
343
- }
344
- &.close {
345
- left: -298px;
346
- .traditional-container {
347
- pointer-events:none;
348
- opacity: 0;
349
- }
350
- }
351
- }
352
-
353
- .traditional-container {
354
- transition: all 1s ease;
355
- float: left;
356
- padding-left: 16px;
357
- padding-right: 18px;
358
- max-height: calc(100% - 154px);
359
- text-align: left;
360
- overflow: none;
361
- border: 1px solid rgb(220, 223, 230);
362
- padding-top: 7px;
363
- padding-bottom: 16px;
364
- background: #ffffff;
365
- }
366
-
367
- .regions-display-text {
368
- width: 59px;
369
- height: 20px;
370
- color: rgb(48, 49, 51);
371
- font-size: 14px;
372
- font-weight: normal;
373
- line-height: 20px;
374
- margin-left: 8px;
375
- }
376
-
377
- .all-checkbox {
378
- float: right;
379
- }
380
-
381
- .checkbox-group {
382
- width: 260px;
383
- border: 1px solid rgb(144, 147, 153);
384
- border-radius: 4px;
385
- background: #ffffff;
386
- margin-top: 6px;
387
- }
388
-
389
- .checkbox-group-inner {
390
- padding: 18px;
391
- max-height: 240px;
392
- min-height: 130px;
393
- overflow: auto;
394
- scrollbar-color: #c0c4cc rgba(1, 1, 1, 0);
395
- scrollbar-width: thin;
396
-
397
- &::-webkit-scrollbar {
398
- width: 4px;
399
- }
400
-
401
- &::-webkit-scrollbar-thumb {
402
- border-radius: 10px;
403
- box-shadow: inset 0 0 6px #c0c4cc;
404
- }
405
- }
406
-
407
- ::v-deep .el-checkbox__input {
408
- &.is-indeterminate, &.is-checked {
409
- .el-checkbox__inner {
410
- background-color: $app-primary-color;
411
- border-color: $app-primary-color;
412
- }
413
- }
414
- }
415
-
416
- ::v-deep .el-color-picker__color {
417
- border: 1px solid $app-primary-color;
418
- }
419
-
420
- ::v-deep .el-checkbox__label {
421
- padding-left: 5px;
422
- color: $app-primary-color !important;
423
- font-size: 12px;
424
- font-weight: 500;
425
- letter-spacing: 0px;
426
- line-height: 14px;
427
- }
428
-
429
- .activeItem {
430
- background-color: #bbb !important;
431
- }
432
-
433
- .my-checkbox {
434
- background-color: #fff;
435
- width: 100%;
436
-
437
- ::v-deep .el-color-picker {
438
- height: 16px !important;
439
- top: 3px;
440
- }
441
-
442
- ::v-deep .el-color-picker__trigger {
443
- margin-left: 8px;
444
- margin-right: 8px;
445
- padding: 0px;
446
- height: 16px;
447
- width: 16px;
448
- border: 0px;
449
- }
450
-
451
- }
452
-
453
- .hoverItem {
454
- background-color: #eee !important;
455
- }
456
-
457
- ::v-deep .el-color-picker__icon {
458
- &.el-icon-arrow-down {
459
- display: none;
460
- }
461
- }
462
-
463
- ::v-deep .show-picker {
464
- .el-color-picker__icon {
465
- &.el-icon-arrow-down {
466
- display: block;
467
- }
468
- }
469
- }
470
-
471
- ::v-deep .my-drawer {
472
- background: rgba(0, 0, 0, 0);
473
- box-shadow: none;
474
- }
475
-
476
- .drawer {
477
- ::v-deep .el-drawer:focus {
478
- outline: none;
479
- }
480
- }
481
-
482
- .open-drawer {
483
- width: 20px;
484
- height: 40px;
485
- z-index: 8;
486
- position: absolute;
487
- left: 0px;
488
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
489
- border: solid 1px #e4e7ed;
490
- background-color: #f7faff;
491
- text-align: center;
492
- vertical-align: middle;
493
- cursor: pointer;
494
- pointer-events: auto;
495
- }
496
-
497
- .drawer-button {
498
- float: left;
499
- width: 20px;
500
- height: 40px;
501
- z-index: 8;
502
- margin-top: calc(50% - 52px);
503
- border: solid 1px #e4e7ed;
504
- border-left: 0;
505
- background-color: #ffffff;
506
- text-align: center;
507
- vertical-align: middle;
508
- cursor: pointer;
509
- pointer-events: auto;
510
- }
511
-
512
- .drawer-button {
513
- i {
514
- margin-top: 12px;
515
- color: $app-primary-color;
516
- transition-delay: 0.9s;
517
- }
518
- &.open {
519
- i {
520
- transform: rotate(0deg) scaleY(2.5);
521
- }
522
- }
523
- &.close {
524
- i {
525
- transform: rotate(180deg) scaleY(2.5);
526
- }
527
- }
528
- }
529
-
530
- .drawer-button.open i {
531
- transform: rotate(0deg) scaleY(2.5);
532
- }
533
-
534
- .drawer-button.close i {
535
- transform: rotate(180deg) scaleY(2.5);
536
- }
537
- </style>
538
-
539
- <style>
540
- .hide-scaffold-colour-popup {
541
- display: none;
542
- }
543
- </style>
544
-