@abi-software/map-utilities 0.0.0-beta.6 → 1.0.0-beta.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/src/App.vue CHANGED
@@ -1,511 +1,630 @@
1
- <script setup>
2
- import { ref, provide, onMounted, watch } from "vue";
3
-
4
- import flatmapTreeData from "../static/FlatmapTreeData.json";
5
- import scaffoldTreeData from "../static/ScaffoldTreeData.json";
6
-
7
- /**
8
- * DrawToolbar
9
- */
10
- const flatmapToolbarOptions = [
11
- "Edit",
12
- "Delete",
13
- "Point",
14
- "LineString",
15
- "Polygon",
16
- "Connection",
17
- ];
18
- const scaffoldToolbarOptions = ["Edit", "Delete", "Point", "LineString"];
19
- const activeDrawTool = ref(undefined);
20
- const activeDrawMode = ref(undefined);
21
- const hoverVisibilities = [
22
- { value: false, refs: "toolbarPopover", ref: "editPopover" },
23
- { value: false, refs: "toolbarPopover", ref: "deletePopover" },
24
- { value: false, refs: "toolbarPopover", ref: "pointPopover" },
25
- { value: false, refs: "toolbarPopover", ref: "lineStringPopover" },
26
- { value: false, refs: "toolbarPopover", ref: "polygonPopover" },
27
- { value: false, refs: "toolbarPopover", ref: "connectionPopover" },
28
- ];
29
- const isFlatmap = ref(true);
30
- const appRef = ref(null);
31
- const newlyDrawnEntry = ref({});
32
- const connectionEntry = ref({});
33
- const drawnType = ref("All tools");
34
- const drawnTypes = [
35
- { value: "All tools", label: "All tools" },
36
- { value: "Point", label: "Point" },
37
- { value: "LineString", label: "LineString" },
38
- { value: "Polygon", label: "Polygon" },
39
- { value: "None", label: "None" },
40
- ];
41
-
42
- onMounted(() => {
43
- console.log("🚀 ~ onMounted ~ appRef:", appRef.value);
44
- });
45
-
46
- watch(drawnType, () => {
47
- finaliseNewDrawn();
48
- });
49
-
50
- function toolbarEvent(type, name) {
51
- console.log("🚀 ~ toolbarEvent ~ type, name:", type, name);
52
- connectionEntry.value = {};
53
- if (type === "mode") {
54
- activeDrawMode.value = name;
55
- } else if (type === "tool") {
56
- activeDrawTool.value = name;
57
- }
58
- }
59
- function startNewDrawn(type) {
60
- activeDrawTool.value = type;
61
- newlyDrawnEntry.value = {};
62
- connectionEntry.value = {};
63
- }
64
- function finishNewDrawn() {
65
- newlyDrawnEntry.value = {
66
- id: 1,
67
- value: "newly drawn entry",
68
- };
69
- }
70
- function addConnection() {
71
- connectionEntry.value = {
72
- " 1026": {
73
- id: 1026,
74
- label: "body proper",
75
- models: "UBERON:0013702",
76
- },
77
- " 4958": {
78
- id: 4958,
79
- label: "liver",
80
- models: "UBERON:0002107",
81
- },
82
- };
83
- }
84
- function removeConnection() {
85
- connectionEntry.value = {};
86
- }
87
- function featureTooltip(value) {
88
- console.log("🚀 ~ featureTooltip ~ value:", value);
89
- }
90
- function finaliseNewDrawn() {
91
- activeDrawTool.value = undefined;
92
- newlyDrawnEntry.value = {};
93
- connectionEntry.value = {};
94
- }
95
- /**
96
- * HelpModeDialog
97
- */
98
- const helpMode = ref(false);
99
- const helpModeActiveItem = ref(0);
100
- const helpModeLastItem = ref(false);
101
- const useHelpModeDialog = ref(false);
102
-
103
- function showHelpModeDialog() {
104
- helpMode.value = true;
105
- useHelpModeDialog.value = true;
106
- }
107
- function onHelpModeShowNext() {
108
- helpModeActiveItem.value += 1;
109
- console.log(
110
- "🚀 ~ onHelpModeShowNext ~ helpModeActiveItem:",
111
- helpModeActiveItem.value
112
- );
113
- }
114
- function onFinishHelpMode() {
115
- helpMode.value = false;
116
- // reset help mode to default values
117
- helpModeActiveItem.value = 0;
118
- helpModeLastItem.value = false;
119
- }
120
- function onActionClick(value) {
121
- console.log("🚀 ~ onActionClick ~ value:", value);
122
- }
123
-
124
- /**
125
- * Tooltip
126
- */
127
- const tooltipDisplay = ref(false);
128
- const tooltipEntry = ref({});
129
- const featuresAlert = ref(undefined);
130
- const annotationDisplay = ref(false);
131
- const annotationEntry = ref({});
132
-
133
- provide(/* key */ "getFeaturesAlert", /* value */ () => featuresAlert.value);
134
- provide(/* key */ "$annotator", /* value */ undefined);
135
- provide(/* key */ "userApiKey", /* value */ undefined);
136
-
137
- function addTooltipEntry() {
138
- tooltipDisplay.value = true;
139
- tooltipEntry.value = {
140
- destinations: [null],
141
- origins: [null],
142
- components: ["pudendal nerve"],
143
- destinationsWithDatasets: [
144
- { id: "UBERON:0004917", name: "urethral sphincter" },
145
- ],
146
- originsWithDatasets: [
147
- { id: "UBERON:0022278", name: "nucleus of pudendal nerve" },
148
- ],
149
- componentsWithDatasets: [{ id: "UBERON:0011390", name: "pudendal nerve" }],
150
- title:
151
- "Nucleus of the pudendal nerve to urethral sphincter via pudendal nerve",
152
- featureId: ["ilxtr:sparc-nlp/mmset1/1"],
153
- hyperlinks: [
154
- {
155
- url: "https://pubmed.ncbi.nlm.nih.gov/?term=%2F%2Fdoi.org%2F10.1155%252F2012%252F816274",
156
- id: "pubmed",
157
- },
158
- ],
159
- provenanceTaxonomy: ["NCBITaxon:9606"],
160
- provenanceTaxonomyLabel: ["Homo sapiens"],
161
- };
162
- }
163
- function removeTooltipEntry() {
164
- tooltipDisplay.value = false;
165
- tooltipEntry.value = {};
166
- }
167
- function addAnnotationEntry() {
168
- tooltipDisplay.value = true;
169
- annotationDisplay.value = true;
170
- annotationEntry.value = {
171
- id: "digestive_8-1",
172
- featureId: 4958,
173
- label: "liver",
174
- models: "UBERON:0002107",
175
- type: "feature",
176
- mapUUID: "b650201e-f27a-54a1-84fc-6ec2e7cf4c15",
177
- resourceId:
178
- "https://mapcore-demo.org/devel/flatmap/v4/flatmap/b650201e-f27a-54a1-84fc-6ec2e7cf4c15",
179
- };
180
- }
181
- function removeAnnotationEntry() {
182
- tooltipDisplay.value = false;
183
- annotationDisplay.value = false;
184
- annotationEntry.value = {};
185
- }
186
- function commitAnnotationEvent(value) {
187
- console.log("🚀 ~ commitAnnotationEvent ~ value:", value);
188
- }
189
- /**
190
- * TreeControls
191
- */
192
- const isReady = ref(true);
193
- const mapType = ref("flatmap");
194
- const flatmapTreeDataEntry = flatmapTreeData;
195
- const scaffoldTreeDataEntry = scaffoldTreeData[0].children;
196
- const treeDataEntry = ref(flatmapTreeDataEntry);
197
-
198
- function switchTreeEntry(value) {
199
- isReady.value = false;
200
- if (value === "flatmap") {
201
- mapType.value = "flatmap";
202
- treeDataEntry.value = flatmapTreeDataEntry;
203
- } else if (value === "scaffold") {
204
- mapType.value = "scaffold";
205
- treeDataEntry.value = scaffoldTreeDataEntry;
206
- }
207
- isReady.value = true;
208
- }
209
- function setColourField(treeData, nodeData, activeColour) {
210
- treeData
211
- .filter((data) => {
212
- // Filtering if single node is provided and it does not have children field
213
- if (nodeData && !data.children) {
214
- return data.id === nodeData.id;
215
- } else {
216
- return true;
217
- }
218
- })
219
- .map((data) => {
220
- if (data.children) {
221
- // Using recursive to process nested data if children field exists
222
- setColourField(data.children, nodeData, activeColour);
223
- } else {
224
- // Active colour used for current display
225
- data["activeColour"] = activeColour;
226
- }
227
- });
228
- }
229
- function setColour(nodeData, value) {
230
- if (nodeData && nodeData.isPrimitives) {
231
- const activeColour = value ? value : nodeData.defaultColour;
232
- setColourField(treeDataEntry.value, nodeData, activeColour)
233
- }
234
- }
235
- function checkAll(value) {
236
- console.log("🚀 ~ checkAll ~ value:", value);
237
- }
238
- function checkChanged(value) {
239
- console.log("🚀 ~ checkChanged ~ value:", value);
240
- }
241
- function changeActive(value) {
242
- console.log("🚀 ~ changeActive ~ value:", value);
243
- }
244
- function changeHover(value) {
245
- console.log("🚀 ~ changeHover ~ value:", value);
246
- }
247
- </script>
248
-
249
- <template>
250
- <div ref="appRef">
251
- <div class="maplibregl-canvas"></div>
252
- <el-row>
253
- <el-col>
254
- <h3>DrawToolbar</h3>
255
- </el-col>
256
- <el-col>
257
- <el-switch
258
- v-model="isFlatmap"
259
- active-text="Flatmap"
260
- inactive-text="Scaffold"
261
- />
262
- </el-col>
263
- </el-row>
264
- <el-row v-show="isFlatmap">
265
- <el-col>
266
- <el-select
267
- v-model="drawnType"
268
- placeholder="Select"
269
- style="width: 120px"
270
- >
271
- <el-option
272
- v-for="item in drawnTypes"
273
- :key="item.value"
274
- :label="item.label"
275
- :value="item.value"
276
- />
277
- </el-select>
278
- </el-col>
279
- <el-col>
280
- <el-button
281
- v-show="
282
- (!activeDrawTool || activeDrawTool === 'Point') &&
283
- (drawnType === 'All tools' ||
284
- drawnType === 'Point' ||
285
- drawnType === 'None')
286
- "
287
- @click="startNewDrawn('Point')"
288
- size="small"
289
- >
290
- Draw New Point
291
- </el-button>
292
- <el-button
293
- v-show="
294
- (!activeDrawTool || activeDrawTool === 'LineString') &&
295
- (drawnType === 'All tools' ||
296
- drawnType === 'LineString' ||
297
- drawnType === 'None')
298
- "
299
- @click="startNewDrawn('LineString')"
300
- size="small"
301
- >
302
- Draw New LineString
303
- </el-button>
304
- <el-button
305
- v-show="
306
- (!activeDrawTool || activeDrawTool === 'Polygon') &&
307
- (drawnType === 'All tools' ||
308
- drawnType === 'Polygon' ||
309
- drawnType === 'None')
310
- "
311
- @click="startNewDrawn('Polygon')"
312
- size="small"
313
- >
314
- Draw New Polygon
315
- </el-button>
316
- <el-button v-show="activeDrawTool" @click="finishNewDrawn" size="small">
317
- Finish New Drawn
318
- </el-button>
319
- <el-button
320
- v-show="Object.keys(newlyDrawnEntry).length > 0"
321
- @click="finaliseNewDrawn"
322
- size="small"
323
- >
324
- Finalise New Drawn
325
- </el-button>
326
- </el-col>
327
- <el-col>
328
- <el-button
329
- v-show="
330
- !Object.keys(connectionEntry).length > 0 &&
331
- (!activeDrawTool || activeDrawTool === 'LineString') &&
332
- (drawnType === 'All tools' ||
333
- drawnType === 'LineString' ||
334
- drawnType === 'None')
335
- "
336
- @click="addConnection"
337
- size="small"
338
- >
339
- Add Connection
340
- </el-button>
341
- <el-button
342
- v-show="Object.keys(connectionEntry).length > 0"
343
- @click="removeConnection"
344
- size="small"
345
- >
346
- Remove Connection
347
- </el-button>
348
- </el-col>
349
- </el-row>
350
- <el-row>
351
- <el-col>
352
- <h3>HelpModeDialog</h3>
353
- <span v-show="helpMode && useHelpModeDialog"
354
- >Current item: {{ helpModeActiveItem }}</span
355
- >
356
- </el-col>
357
- <el-col>
358
- <el-button @click="showHelpModeDialog" size="small">
359
- Show HelpMode Dialog
360
- </el-button>
361
- <el-button
362
- v-show="helpMode && useHelpModeDialog"
363
- @click="onHelpModeShowNext"
364
- size="small"
365
- >
366
- Show Next
367
- </el-button>
368
- <el-button
369
- v-show="helpMode && useHelpModeDialog"
370
- @click="onFinishHelpMode"
371
- size="small"
372
- >
373
- Hide HelpMode Dialog
374
- </el-button>
375
- </el-col>
376
- </el-row>
377
- <el-row>
378
- <el-col>
379
- <h3>Tooltip</h3>
380
- </el-col>
381
- <el-col>
382
- <el-button
383
- v-show="!annotationDisplay"
384
- @click="addTooltipEntry"
385
- size="small"
386
- >
387
- Add Tooltip Entry
388
- </el-button>
389
- <el-button
390
- v-show="Object.keys(tooltipEntry).length > 0"
391
- @click="removeTooltipEntry"
392
- size="small"
393
- >
394
- Remove Tooltip Entry
395
- </el-button>
396
- <el-button
397
- v-show="!Object.keys(tooltipEntry).length > 0"
398
- @click="addAnnotationEntry"
399
- size="small"
400
- >
401
- Add Annotation Entry
402
- </el-button>
403
- <el-button
404
- v-show="Object.keys(annotationEntry).length > 0"
405
- @click="removeAnnotationEntry"
406
- size="small"
407
- >
408
- Remove Annotation Entry
409
- </el-button>
410
- </el-col>
411
- </el-row>
412
- <el-row>
413
- <el-col>
414
- <h3>TreeControls - {{ mapType }}</h3>
415
- </el-col>
416
- <el-col>
417
- <el-button v-show="mapType==='scaffold'" @click="switchTreeEntry('flatmap')" size="small">
418
- Display Flatmap Tree
419
- </el-button>
420
- <el-button v-show="mapType==='flatmap'" @click="switchTreeEntry('scaffold')" size="small">
421
- Display Scaffold Tree
422
- </el-button>
423
- </el-col>
424
- </el-row>
425
-
426
- <DrawToolbar
427
- v-show="isFlatmap"
428
- :mapCanvas="{
429
- containerHTML: appRef,
430
- class: '.maplibregl-canvas',
431
- }"
432
- :toolbarOptions="flatmapToolbarOptions"
433
- :drawnType="drawnType"
434
- :activeDrawTool="activeDrawTool"
435
- :activeDrawMode="activeDrawMode"
436
- :newlyDrawnEntry="newlyDrawnEntry"
437
- :connectionEntry="connectionEntry"
438
- :hoverVisibilities="hoverVisibilities"
439
- @clickToolbar="toolbarEvent"
440
- @featureTooltip="featureTooltip"
441
- @confirmDrawn="finaliseNewDrawn"
442
- @cancelDrawn="finaliseNewDrawn"
443
- ref="toolbarPopover"
444
- />
445
- <DrawToolbar
446
- v-show="!isFlatmap"
447
- :toolbarOptions="scaffoldToolbarOptions"
448
- :activeDrawTool="activeDrawTool"
449
- :activeDrawMode="activeDrawMode"
450
- :hoverVisibilities="hoverVisibilities"
451
- @clickToolbar="toolbarEvent"
452
- ref="toolbarPopover"
453
- />
454
- <HelpModeDialog
455
- v-show="helpMode && useHelpModeDialog"
456
- class="help-mode-dialog"
457
- :lastItem="helpModeLastItem"
458
- @show-next="onHelpModeShowNext"
459
- @finish-help-mode="onFinishHelpMode"
460
- />
461
- <Tooltip
462
- v-show="tooltipDisplay"
463
- class="tooltip"
464
- :tooltipEntry="tooltipEntry"
465
- :annotationDisplay="annotationDisplay"
466
- :annotationEntry="annotationEntry"
467
- @annotation="commitAnnotationEvent"
468
- @onActionClick="onActionClick"
469
- />
470
- <TreeControls
471
- v-show="mapType === 'flatmap'"
472
- mapType="flatmap"
473
- title="Systems"
474
- :treeData="treeDataEntry"
475
- active=""
476
- hover=""
477
- @checkAll="checkAll"
478
- @checkChanged="checkChanged"
479
- @changeActive="changeActive"
480
- @changeHover="changeHover"
481
- />
482
- <TreeControls
483
- v-show="mapType === 'scaffold'"
484
- mapType="scaffold"
485
- title="Regions"
486
- :isReady="isReady"
487
- :treeData="treeDataEntry"
488
- :active="[]"
489
- :hover="[]"
490
- :showColourPicker="true"
491
- @setColour="setColour"
492
- @checkChanged="checkChanged"
493
- />
494
- </div>
495
- </template>
496
-
497
- <style scoped>
498
- .options-container {
499
- text-align: center;
500
- }
501
- .help-mode-dialog {
502
- position: absolute;
503
- top: 50%;
504
- }
505
- .tooltip {
506
- width: 400px;
507
- position: absolute;
508
- top: calc(50% - 100px);
509
- left: calc(50% - 200px);
510
- }
511
- </style>
1
+ <script setup>
2
+ import { ref, provide, onMounted, watch } from "vue";
3
+
4
+ import flatmapTreeData from "../static/FlatmapTreeData.json";
5
+ import scaffoldTreeData from "../static/ScaffoldTreeData.json";
6
+
7
+ /**
8
+ * DrawToolbar
9
+ */
10
+ const flatmapToolbarOptions = [
11
+ "Edit",
12
+ "Delete",
13
+ "Point",
14
+ "LineString",
15
+ "Polygon",
16
+ "Connection",
17
+ ];
18
+ const scaffoldToolbarOptions = ["Edit", "Delete", "Point", "LineString"];
19
+ const activeDrawTool = ref(undefined);
20
+ const activeDrawMode = ref(undefined);
21
+ const hoverVisibilities = [
22
+ { value: false, refs: "toolbarPopover", ref: "editPopover" },
23
+ { value: false, refs: "toolbarPopover", ref: "deletePopover" },
24
+ { value: false, refs: "toolbarPopover", ref: "pointPopover" },
25
+ { value: false, refs: "toolbarPopover", ref: "lineStringPopover" },
26
+ { value: false, refs: "toolbarPopover", ref: "polygonPopover" },
27
+ { value: false, refs: "toolbarPopover", ref: "connectionPopover" },
28
+ ];
29
+ const isFlatmap = ref(true);
30
+ const appRef = ref(null);
31
+ const newlyDrawnEntry = ref({});
32
+ const connectionEntry = ref({});
33
+ const drawnType = ref("All tools");
34
+ const drawnTypes = [
35
+ { value: "All tools", label: "All tools" },
36
+ { value: "Point", label: "Point" },
37
+ { value: "LineString", label: "LineString" },
38
+ { value: "Polygon", label: "Polygon" },
39
+ { value: "None", label: "None" },
40
+ ];
41
+
42
+ onMounted(() => {
43
+ console.log("🚀 ~ onMounted ~ appRef:", appRef.value);
44
+ });
45
+
46
+ watch(drawnType, () => {
47
+ finaliseNewDrawn();
48
+ });
49
+
50
+ function toolbarEvent(type, name) {
51
+ console.log("🚀 ~ toolbarEvent ~ type, name:", type, name);
52
+ connectionEntry.value = {};
53
+ if (type === "mode") {
54
+ activeDrawMode.value = name;
55
+ } else if (type === "tool") {
56
+ activeDrawTool.value = name;
57
+ }
58
+ }
59
+ function startNewDrawn(type) {
60
+ activeDrawTool.value = type;
61
+ newlyDrawnEntry.value = {};
62
+ connectionEntry.value = {};
63
+ }
64
+ function finishNewDrawn() {
65
+ newlyDrawnEntry.value = {
66
+ id: 1,
67
+ value: "newly drawn entry",
68
+ };
69
+ }
70
+ function addConnection() {
71
+ connectionEntry.value = {
72
+ " 1026": {
73
+ id: 1026,
74
+ label: "body proper",
75
+ models: "UBERON:0013702",
76
+ },
77
+ " 4958": {
78
+ id: 4958,
79
+ label: "liver",
80
+ models: "UBERON:0002107",
81
+ },
82
+ };
83
+ }
84
+ function removeConnection() {
85
+ connectionEntry.value = {};
86
+ }
87
+ function featureTooltip(value) {
88
+ console.log("🚀 ~ featureTooltip ~ value:", value);
89
+ }
90
+ function finaliseNewDrawn() {
91
+ activeDrawTool.value = undefined;
92
+ newlyDrawnEntry.value = {};
93
+ connectionEntry.value = {};
94
+ }
95
+ /**
96
+ * HelpModeDialog
97
+ */
98
+ const helpMode = ref(false);
99
+ const helpModeActiveItem = ref(0);
100
+ const helpModeLastItem = ref(false);
101
+ const useHelpModeDialog = ref(false);
102
+
103
+ function showHelpModeDialog() {
104
+ helpMode.value = true;
105
+ useHelpModeDialog.value = true;
106
+ }
107
+ function onHelpModeShowNext() {
108
+ helpModeActiveItem.value += 1;
109
+ console.log(
110
+ "🚀 ~ onHelpModeShowNext ~ helpModeActiveItem:",
111
+ helpModeActiveItem.value
112
+ );
113
+ }
114
+ function onFinishHelpMode() {
115
+ helpMode.value = false;
116
+ // reset help mode to default values
117
+ helpModeActiveItem.value = 0;
118
+ helpModeLastItem.value = false;
119
+ }
120
+ function onActionClick(value) {
121
+ console.log("🚀 ~ onActionClick ~ value:", value);
122
+ }
123
+
124
+ /**
125
+ * Tooltip
126
+ */
127
+ const tooltipType = ref("");
128
+ const provenanceEntry = ref({});
129
+ const featuresAlert = ref(undefined);
130
+ const annotationEntry = ref({});
131
+ const imageEntry = ref([]);
132
+
133
+ provide(/* key */ "getFeaturesAlert", /* value */ () => featuresAlert.value);
134
+ provide(/* key */ "$annotator", /* value */ undefined);
135
+ provide(/* key */ "userApiKey", /* value */ undefined);
136
+
137
+ function addProvenanceEntry() {
138
+ tooltipType.value = "provenance";
139
+ provenanceEntry.value = {
140
+ destinations: [null],
141
+ origins: [null],
142
+ components: ["pudendal nerve"],
143
+ destinationsWithDatasets: [
144
+ { id: "UBERON:0004917", name: "urethral sphincter" },
145
+ ],
146
+ originsWithDatasets: [
147
+ { id: "UBERON:0022278", name: "nucleus of pudendal nerve" },
148
+ ],
149
+ componentsWithDatasets: [{ id: "UBERON:0011390", name: "pudendal nerve" }],
150
+ title:
151
+ "Nucleus of the pudendal nerve to urethral sphincter via pudendal nerve",
152
+ featureId: ["ilxtr:sparc-nlp/mmset1/1"],
153
+ hyperlinks: [
154
+ {
155
+ url: "https://pubmed.ncbi.nlm.nih.gov/?term=%2F%2Fdoi.org%2F10.1155%252F2012%252F816274",
156
+ id: "pubmed",
157
+ },
158
+ ],
159
+ provenanceTaxonomy: ["NCBITaxon:9606"],
160
+ provenanceTaxonomyLabel: ["Homo sapiens"],
161
+ };
162
+ }
163
+ function removeProvenanceEntry() {
164
+ tooltipType.value = "";
165
+ provenanceEntry.value = {};
166
+ }
167
+ function addAnnotationEntry() {
168
+ tooltipType.value = "annotation";
169
+ annotationEntry.value = {
170
+ id: "digestive_8-1",
171
+ featureId: 4958,
172
+ label: "liver",
173
+ models: "UBERON:0002107",
174
+ type: "feature",
175
+ mapUUID: "b650201e-f27a-54a1-84fc-6ec2e7cf4c15",
176
+ resourceId:
177
+ "https://mapcore-demo.org/devel/flatmap/v4/flatmap/b650201e-f27a-54a1-84fc-6ec2e7cf4c15",
178
+ };
179
+ }
180
+ function removeAnnotationEntry() {
181
+ tooltipType.value = "";
182
+ annotationEntry.value = {};
183
+ }
184
+ function commitAnnotationEvent(value) {
185
+ console.log("🚀 ~ commitAnnotationEvent ~ value:", value);
186
+ }
187
+ function addImageEntry() {
188
+ tooltipType.value = "image";
189
+ imageEntry.value = [
190
+ {
191
+ anatomy: [
192
+ {
193
+ curie: "",
194
+ matchingStatus: "Exact Match",
195
+ name: "stomach",
196
+ },
197
+ ],
198
+ datasetId: "22",
199
+ datasetVersion: "2",
200
+ link: "https://sparc.biolucida.net/image?c=Mzg3Ny1jb2wtMTUw",
201
+ resource: {
202
+ share_link: "https://sparc.biolucida.net/image?c=Mzg3Ny1jb2wtMTUw",
203
+ },
204
+ s3uri: "s3://prd-sparc-discover50-use1/22/",
205
+ species: [
206
+ {
207
+ species: {
208
+ curie: "NCBITaxon:9825",
209
+ matchingStatus: "approved",
210
+ name: "Pig",
211
+ originalName: "Domestic Pig",
212
+ parents: [
213
+ {
214
+ curie: "ilx:0739765",
215
+ name: "Pig",
216
+ },
217
+ ],
218
+ },
219
+ strain: {
220
+ name: "Large White / Landrace crossbred pig",
221
+ },
222
+ },
223
+ ],
224
+ thumbnail: "https://sparc.biolucida.net/api/v1/thumbnail/3877",
225
+ title: "SPARC Image 1",
226
+ type: "image",
227
+ },
228
+ {
229
+ anatomy: [
230
+ {
231
+ curie: "",
232
+ matchingStatus: "Exact Match",
233
+ name: "stomach",
234
+ },
235
+ ],
236
+ datasetId: "22",
237
+ datasetVersion: "2",
238
+ link: "https://sparc.biolucida.net/image?c=Mzg3Ny1jb2wtMTUw",
239
+ resource: {
240
+ share_link: "https://sparc.biolucida.net/image?c=Mzg3Ny1jb2wtMTUw",
241
+ },
242
+ s3uri: "s3://prd-sparc-discover50-use1/22/",
243
+ species: [
244
+ {
245
+ species: {
246
+ curie: "NCBITaxon:9825",
247
+ matchingStatus: "approved",
248
+ name: "Pig",
249
+ originalName: "Domestic Pig",
250
+ parents: [
251
+ {
252
+ curie: "ilx:0739765",
253
+ name: "Pig",
254
+ },
255
+ ],
256
+ },
257
+ strain: {
258
+ name: "Large White / Landrace crossbred pig",
259
+ },
260
+ },
261
+ ],
262
+ thumbnail: "https://sparc.biolucida.net/api/v1/thumbnail/3877",
263
+ title: "SPARC Image 2",
264
+ type: "image",
265
+ },
266
+ ];
267
+ }
268
+ function removeImageEntry() {
269
+ tooltipType.value = "";
270
+ imageEntry.value = [];
271
+ }
272
+ /**
273
+ * TreeControls
274
+ */
275
+ const isReady = ref(true);
276
+ const mapType = ref("flatmap");
277
+ const flatmapTreeDataEntry = flatmapTreeData;
278
+ const scaffoldTreeDataEntry = scaffoldTreeData[0].children;
279
+ const treeDataEntry = ref(flatmapTreeDataEntry);
280
+
281
+ function switchTreeEntry(value) {
282
+ isReady.value = false;
283
+ if (value === "flatmap") {
284
+ mapType.value = "flatmap";
285
+ treeDataEntry.value = flatmapTreeDataEntry;
286
+ } else if (value === "scaffold") {
287
+ mapType.value = "scaffold";
288
+ treeDataEntry.value = scaffoldTreeDataEntry;
289
+ }
290
+ isReady.value = true;
291
+ }
292
+ function setColourField(treeData, nodeData, activeColour) {
293
+ treeData
294
+ .filter((data) => {
295
+ // Filtering if single node is provided and it does not have children field
296
+ if (nodeData && !data.children) {
297
+ return data.id === nodeData.id;
298
+ } else {
299
+ return true;
300
+ }
301
+ })
302
+ .map((data) => {
303
+ if (data.children) {
304
+ // Using recursive to process nested data if children field exists
305
+ setColourField(data.children, nodeData, activeColour);
306
+ } else {
307
+ // Active colour used for current display
308
+ data["activeColour"] = activeColour;
309
+ }
310
+ });
311
+ }
312
+ function setColour(nodeData, value) {
313
+ if (nodeData && nodeData.isPrimitives) {
314
+ const activeColour = value ? value : nodeData.defaultColour;
315
+ setColourField(treeDataEntry.value, nodeData, activeColour);
316
+ }
317
+ }
318
+ function checkAll(value) {
319
+ console.log("🚀 ~ checkAll ~ value:", value);
320
+ }
321
+ function checkChanged(value) {
322
+ console.log("🚀 ~ checkChanged ~ value:", value);
323
+ }
324
+ function changeActive(value) {
325
+ console.log("🚀 ~ changeActive ~ value:", value);
326
+ }
327
+ function changeHover(value) {
328
+ console.log("🚀 ~ changeHover ~ value:", value);
329
+ }
330
+ </script>
331
+
332
+ <template>
333
+ <div ref="appRef">
334
+ <div class="maplibregl-canvas"></div>
335
+ <el-row>
336
+ <el-col>
337
+ <h3>DrawToolbar</h3>
338
+ </el-col>
339
+ <el-col>
340
+ <el-switch
341
+ v-model="isFlatmap"
342
+ active-text="Flatmap"
343
+ inactive-text="Scaffold"
344
+ />
345
+ </el-col>
346
+ </el-row>
347
+ <el-row v-show="isFlatmap">
348
+ <el-col>
349
+ <el-select
350
+ v-model="drawnType"
351
+ placeholder="Select"
352
+ style="width: 120px"
353
+ >
354
+ <el-option
355
+ v-for="item in drawnTypes"
356
+ :key="item.value"
357
+ :label="item.label"
358
+ :value="item.value"
359
+ />
360
+ </el-select>
361
+ </el-col>
362
+ <el-col>
363
+ <el-button
364
+ v-show="
365
+ (!activeDrawTool || activeDrawTool === 'Point') &&
366
+ (drawnType === 'All tools' ||
367
+ drawnType === 'Point' ||
368
+ drawnType === 'None')
369
+ "
370
+ @click="startNewDrawn('Point')"
371
+ size="small"
372
+ >
373
+ Draw New Point
374
+ </el-button>
375
+ <el-button
376
+ v-show="
377
+ (!activeDrawTool || activeDrawTool === 'LineString') &&
378
+ (drawnType === 'All tools' ||
379
+ drawnType === 'LineString' ||
380
+ drawnType === 'None')
381
+ "
382
+ @click="startNewDrawn('LineString')"
383
+ size="small"
384
+ >
385
+ Draw New LineString
386
+ </el-button>
387
+ <el-button
388
+ v-show="
389
+ (!activeDrawTool || activeDrawTool === 'Polygon') &&
390
+ (drawnType === 'All tools' ||
391
+ drawnType === 'Polygon' ||
392
+ drawnType === 'None')
393
+ "
394
+ @click="startNewDrawn('Polygon')"
395
+ size="small"
396
+ >
397
+ Draw New Polygon
398
+ </el-button>
399
+ <el-button v-show="activeDrawTool" @click="finishNewDrawn" size="small">
400
+ Finish New Drawn
401
+ </el-button>
402
+ <el-button
403
+ v-show="Object.keys(newlyDrawnEntry).length > 0"
404
+ @click="finaliseNewDrawn"
405
+ size="small"
406
+ >
407
+ Finalise New Drawn
408
+ </el-button>
409
+ </el-col>
410
+ <el-col>
411
+ <el-button
412
+ v-show="
413
+ !Object.keys(connectionEntry).length > 0 &&
414
+ (!activeDrawTool || activeDrawTool === 'LineString') &&
415
+ (drawnType === 'All tools' ||
416
+ drawnType === 'LineString' ||
417
+ drawnType === 'None')
418
+ "
419
+ @click="addConnection"
420
+ size="small"
421
+ >
422
+ Add Connection
423
+ </el-button>
424
+ <el-button
425
+ v-show="Object.keys(connectionEntry).length > 0"
426
+ @click="removeConnection"
427
+ size="small"
428
+ >
429
+ Remove Connection
430
+ </el-button>
431
+ </el-col>
432
+ </el-row>
433
+ <el-row>
434
+ <el-col>
435
+ <h3>HelpModeDialog</h3>
436
+ <span v-show="helpMode && useHelpModeDialog"
437
+ >Current item: {{ helpModeActiveItem }}</span
438
+ >
439
+ </el-col>
440
+ <el-col>
441
+ <el-button @click="showHelpModeDialog" size="small">
442
+ Show HelpMode Dialog
443
+ </el-button>
444
+ <el-button
445
+ v-show="helpMode && useHelpModeDialog"
446
+ @click="onHelpModeShowNext"
447
+ size="small"
448
+ >
449
+ Show Next
450
+ </el-button>
451
+ <el-button
452
+ v-show="helpMode && useHelpModeDialog"
453
+ @click="onFinishHelpMode"
454
+ size="small"
455
+ >
456
+ Hide HelpMode Dialog
457
+ </el-button>
458
+ </el-col>
459
+ </el-row>
460
+ <el-row>
461
+ <el-col>
462
+ <h3>Tooltip</h3>
463
+ </el-col>
464
+ <el-col>
465
+ <el-button
466
+ v-show="
467
+ tooltipType === '' ||
468
+ (tooltipType === 'provenance' &&
469
+ Object.keys(provenanceEntry).length === 0)
470
+ "
471
+ @click="addProvenanceEntry"
472
+ size="small"
473
+ >
474
+ Add Provenance Entry
475
+ </el-button>
476
+ <el-button
477
+ v-show="Object.keys(provenanceEntry).length > 0"
478
+ @click="removeProvenanceEntry"
479
+ size="small"
480
+ >
481
+ Remove Provenance Entry
482
+ </el-button>
483
+ <el-button
484
+ v-show="
485
+ tooltipType === '' ||
486
+ (tooltipType === 'annotation' &&
487
+ Object.keys(annotationEntry).length === 0)
488
+ "
489
+ @click="addAnnotationEntry"
490
+ size="small"
491
+ >
492
+ Add Annotation Entry
493
+ </el-button>
494
+ <el-button
495
+ v-show="Object.keys(annotationEntry).length > 0"
496
+ @click="removeAnnotationEntry"
497
+ size="small"
498
+ >
499
+ Remove Annotation Entry
500
+ </el-button>
501
+ <el-button
502
+ v-show="
503
+ tooltipType === '' ||
504
+ (tooltipType === 'image' && Object.keys(imageEntry).length === 0)
505
+ "
506
+ @click="addImageEntry"
507
+ size="small"
508
+ >
509
+ Add Image Entry
510
+ </el-button>
511
+ <el-button
512
+ v-show="Object.keys(imageEntry).length > 0"
513
+ @click="removeImageEntry"
514
+ size="small"
515
+ >
516
+ Remove Image Entry
517
+ </el-button>
518
+ </el-col>
519
+ </el-row>
520
+ <el-row>
521
+ <el-col>
522
+ <h3>TreeControls - {{ mapType }}</h3>
523
+ </el-col>
524
+ <el-col>
525
+ <el-button
526
+ v-show="mapType === 'scaffold'"
527
+ @click="switchTreeEntry('flatmap')"
528
+ size="small"
529
+ >
530
+ Display Flatmap Tree
531
+ </el-button>
532
+ <el-button
533
+ v-show="mapType === 'flatmap'"
534
+ @click="switchTreeEntry('scaffold')"
535
+ size="small"
536
+ >
537
+ Display Scaffold Tree
538
+ </el-button>
539
+ </el-col>
540
+ </el-row>
541
+
542
+ <DrawToolbar
543
+ v-show="isFlatmap"
544
+ :mapCanvas="{
545
+ containerHTML: appRef,
546
+ class: '.maplibregl-canvas',
547
+ }"
548
+ :toolbarOptions="flatmapToolbarOptions"
549
+ :drawnType="drawnType"
550
+ :activeDrawTool="activeDrawTool"
551
+ :activeDrawMode="activeDrawMode"
552
+ :newlyDrawnEntry="newlyDrawnEntry"
553
+ :connectionEntry="connectionEntry"
554
+ :hoverVisibilities="hoverVisibilities"
555
+ @clickToolbar="toolbarEvent"
556
+ @featureTooltip="featureTooltip"
557
+ @confirmDrawn="finaliseNewDrawn"
558
+ @cancelDrawn="finaliseNewDrawn"
559
+ ref="toolbarPopover"
560
+ />
561
+ <DrawToolbar
562
+ v-show="!isFlatmap"
563
+ :toolbarOptions="scaffoldToolbarOptions"
564
+ :activeDrawTool="activeDrawTool"
565
+ :activeDrawMode="activeDrawMode"
566
+ :hoverVisibilities="hoverVisibilities"
567
+ @clickToolbar="toolbarEvent"
568
+ ref="toolbarPopover"
569
+ />
570
+ <HelpModeDialog
571
+ v-show="helpMode && useHelpModeDialog"
572
+ class="help-mode-dialog"
573
+ :lastItem="helpModeLastItem"
574
+ @show-next="onHelpModeShowNext"
575
+ @finish-help-mode="onFinishHelpMode"
576
+ />
577
+ <Tooltip
578
+ v-show="tooltipType"
579
+ class="tooltip"
580
+ :tooltipType="tooltipType"
581
+ :provenanceEntry="provenanceEntry"
582
+ :annotationEntry="annotationEntry"
583
+ :imageEntry="imageEntry"
584
+ @annotation="commitAnnotationEvent"
585
+ @onActionClick="onActionClick"
586
+ />
587
+ <TreeControls
588
+ v-show="mapType === 'flatmap'"
589
+ mapType="flatmap"
590
+ title="Systems"
591
+ :treeData="treeDataEntry"
592
+ active=""
593
+ hover=""
594
+ @checkAll="checkAll"
595
+ @checkChanged="checkChanged"
596
+ @changeActive="changeActive"
597
+ @changeHover="changeHover"
598
+ />
599
+ <TreeControls
600
+ v-show="mapType === 'scaffold'"
601
+ mapType="scaffold"
602
+ title="Regions"
603
+ :isReady="isReady"
604
+ :treeData="treeDataEntry"
605
+ :active="[]"
606
+ :hover="[]"
607
+ :showColourPicker="true"
608
+ @setColour="setColour"
609
+ @checkChanged="checkChanged"
610
+ />
611
+ </div>
612
+ </template>
613
+
614
+ <style scoped>
615
+ .options-container {
616
+ text-align: center;
617
+ }
618
+
619
+ .help-mode-dialog {
620
+ position: absolute;
621
+ top: 50%;
622
+ }
623
+
624
+ .tooltip {
625
+ width: 400px;
626
+ position: absolute;
627
+ top: calc(50% - 100px);
628
+ left: calc(50% - 200px);
629
+ }
630
+ </style>