@jbrowse/plugin-circular-view 2.5.0 → 2.6.2

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.
Files changed (126) hide show
  1. package/dist/BaseChordDisplay/components/BaseChordDisplay.d.ts +1 -1
  2. package/dist/BaseChordDisplay/components/BaseChordDisplay.js +0 -1
  3. package/dist/BaseChordDisplay/components/DisplayError.d.ts +2 -1
  4. package/dist/BaseChordDisplay/components/DisplayError.js +0 -1
  5. package/dist/BaseChordDisplay/components/Loading.d.ts +2 -1
  6. package/dist/BaseChordDisplay/components/Loading.js +0 -1
  7. package/dist/BaseChordDisplay/index.js +0 -1
  8. package/dist/BaseChordDisplay/models/configSchema.js +0 -1
  9. package/dist/BaseChordDisplay/models/model.d.ts +8 -2
  10. package/dist/BaseChordDisplay/models/model.js +0 -1
  11. package/dist/BaseChordDisplay/models/renderReaction.js +0 -1
  12. package/dist/CircularView/components/CircularView.d.ts +2 -1
  13. package/dist/CircularView/components/CircularView.js +0 -1
  14. package/dist/CircularView/components/Controls.d.ts +2 -1
  15. package/dist/CircularView/components/Controls.js +0 -1
  16. package/dist/CircularView/components/ExportSvgDialog.d.ts +2 -1
  17. package/dist/CircularView/components/ExportSvgDialog.js +0 -1
  18. package/dist/CircularView/components/ImportForm.d.ts +2 -1
  19. package/dist/CircularView/components/ImportForm.js +0 -1
  20. package/dist/CircularView/components/Ruler.d.ts +2 -1
  21. package/dist/CircularView/components/Ruler.js +0 -1
  22. package/dist/CircularView/index.js +0 -1
  23. package/dist/CircularView/models/CircularView.d.ts +1 -3
  24. package/dist/CircularView/models/CircularView.js +30 -7
  25. package/dist/CircularView/models/slices.js +0 -1
  26. package/dist/CircularView/models/viewportVisibleRegion.js +0 -1
  27. package/dist/CircularView/svgcomponents/SVGBackground.d.ts +2 -1
  28. package/dist/CircularView/svgcomponents/SVGBackground.js +0 -1
  29. package/dist/CircularView/svgcomponents/SVGCircularView.js +0 -1
  30. package/dist/LaunchCircularView/index.js +0 -1
  31. package/dist/index.js +0 -1
  32. package/esm/BaseChordDisplay/components/BaseChordDisplay.d.ts +1 -1
  33. package/esm/BaseChordDisplay/components/BaseChordDisplay.js +0 -1
  34. package/esm/BaseChordDisplay/components/DisplayError.d.ts +2 -1
  35. package/esm/BaseChordDisplay/components/DisplayError.js +0 -1
  36. package/esm/BaseChordDisplay/components/Loading.d.ts +2 -1
  37. package/esm/BaseChordDisplay/components/Loading.js +0 -1
  38. package/esm/BaseChordDisplay/index.js +0 -1
  39. package/esm/BaseChordDisplay/models/configSchema.js +0 -1
  40. package/esm/BaseChordDisplay/models/model.d.ts +8 -2
  41. package/esm/BaseChordDisplay/models/model.js +0 -1
  42. package/esm/BaseChordDisplay/models/renderReaction.js +0 -1
  43. package/esm/CircularView/components/CircularView.d.ts +2 -1
  44. package/esm/CircularView/components/CircularView.js +0 -1
  45. package/esm/CircularView/components/Controls.d.ts +2 -1
  46. package/esm/CircularView/components/Controls.js +0 -1
  47. package/esm/CircularView/components/ExportSvgDialog.d.ts +2 -1
  48. package/esm/CircularView/components/ExportSvgDialog.js +0 -1
  49. package/esm/CircularView/components/ImportForm.d.ts +2 -1
  50. package/esm/CircularView/components/ImportForm.js +0 -1
  51. package/esm/CircularView/components/Ruler.d.ts +2 -1
  52. package/esm/CircularView/components/Ruler.js +0 -1
  53. package/esm/CircularView/index.js +0 -1
  54. package/esm/CircularView/models/CircularView.d.ts +1 -3
  55. package/esm/CircularView/models/CircularView.js +6 -6
  56. package/esm/CircularView/models/slices.js +0 -1
  57. package/esm/CircularView/models/viewportVisibleRegion.js +0 -1
  58. package/esm/CircularView/svgcomponents/SVGBackground.d.ts +2 -1
  59. package/esm/CircularView/svgcomponents/SVGBackground.js +0 -1
  60. package/esm/CircularView/svgcomponents/SVGCircularView.js +0 -1
  61. package/esm/LaunchCircularView/index.js +0 -1
  62. package/esm/index.js +0 -1
  63. package/package.json +3 -4
  64. package/dist/BaseChordDisplay/components/BaseChordDisplay.js.map +0 -1
  65. package/dist/BaseChordDisplay/components/DisplayError.js.map +0 -1
  66. package/dist/BaseChordDisplay/components/Loading.js.map +0 -1
  67. package/dist/BaseChordDisplay/index.js.map +0 -1
  68. package/dist/BaseChordDisplay/models/configSchema.js.map +0 -1
  69. package/dist/BaseChordDisplay/models/model.js.map +0 -1
  70. package/dist/BaseChordDisplay/models/renderReaction.js.map +0 -1
  71. package/dist/CircularView/components/CircularView.js.map +0 -1
  72. package/dist/CircularView/components/Controls.js.map +0 -1
  73. package/dist/CircularView/components/ExportSvgDialog.js.map +0 -1
  74. package/dist/CircularView/components/ImportForm.js.map +0 -1
  75. package/dist/CircularView/components/Ruler.js.map +0 -1
  76. package/dist/CircularView/index.js.map +0 -1
  77. package/dist/CircularView/models/CircularView.js.map +0 -1
  78. package/dist/CircularView/models/slices.js.map +0 -1
  79. package/dist/CircularView/models/viewportVisibleRegion.js.map +0 -1
  80. package/dist/CircularView/svgcomponents/SVGBackground.js.map +0 -1
  81. package/dist/CircularView/svgcomponents/SVGCircularView.js.map +0 -1
  82. package/dist/LaunchCircularView/index.js.map +0 -1
  83. package/dist/index.js.map +0 -1
  84. package/esm/BaseChordDisplay/components/BaseChordDisplay.js.map +0 -1
  85. package/esm/BaseChordDisplay/components/DisplayError.js.map +0 -1
  86. package/esm/BaseChordDisplay/components/Loading.js.map +0 -1
  87. package/esm/BaseChordDisplay/index.js.map +0 -1
  88. package/esm/BaseChordDisplay/models/configSchema.js.map +0 -1
  89. package/esm/BaseChordDisplay/models/model.js.map +0 -1
  90. package/esm/BaseChordDisplay/models/renderReaction.js.map +0 -1
  91. package/esm/CircularView/components/CircularView.js.map +0 -1
  92. package/esm/CircularView/components/Controls.js.map +0 -1
  93. package/esm/CircularView/components/ExportSvgDialog.js.map +0 -1
  94. package/esm/CircularView/components/ImportForm.js.map +0 -1
  95. package/esm/CircularView/components/Ruler.js.map +0 -1
  96. package/esm/CircularView/index.js.map +0 -1
  97. package/esm/CircularView/models/CircularView.js.map +0 -1
  98. package/esm/CircularView/models/slices.js.map +0 -1
  99. package/esm/CircularView/models/viewportVisibleRegion.js.map +0 -1
  100. package/esm/CircularView/svgcomponents/SVGBackground.js.map +0 -1
  101. package/esm/CircularView/svgcomponents/SVGCircularView.js.map +0 -1
  102. package/esm/LaunchCircularView/index.js.map +0 -1
  103. package/esm/index.js.map +0 -1
  104. package/src/BaseChordDisplay/components/BaseChordDisplay.tsx +0 -26
  105. package/src/BaseChordDisplay/components/DisplayError.tsx +0 -47
  106. package/src/BaseChordDisplay/components/Loading.tsx +0 -111
  107. package/src/BaseChordDisplay/index.ts +0 -3
  108. package/src/BaseChordDisplay/models/configSchema.ts +0 -30
  109. package/src/BaseChordDisplay/models/model.tsx +0 -314
  110. package/src/BaseChordDisplay/models/renderReaction.ts +0 -75
  111. package/src/CircularView/components/CircularView.tsx +0 -128
  112. package/src/CircularView/components/Controls.tsx +0 -119
  113. package/src/CircularView/components/ExportSvgDialog.tsx +0 -132
  114. package/src/CircularView/components/ImportForm.tsx +0 -68
  115. package/src/CircularView/components/Ruler.tsx +0 -265
  116. package/src/CircularView/index.ts +0 -16
  117. package/src/CircularView/models/CircularView.ts +0 -620
  118. package/src/CircularView/models/__snapshots__/slices.test.js.snap +0 -91
  119. package/src/CircularView/models/slices.test.js +0 -70
  120. package/src/CircularView/models/slices.ts +0 -101
  121. package/src/CircularView/models/viewportVisibleRegion.test.js +0 -168
  122. package/src/CircularView/models/viewportVisibleRegion.ts +0 -272
  123. package/src/CircularView/svgcomponents/SVGBackground.tsx +0 -21
  124. package/src/CircularView/svgcomponents/SVGCircularView.tsx +0 -58
  125. package/src/LaunchCircularView/index.ts +0 -48
  126. package/src/index.ts +0 -43
@@ -1,620 +0,0 @@
1
- import React from 'react'
2
- import PluginManager from '@jbrowse/core/PluginManager'
3
- import {
4
- cast,
5
- getParent,
6
- getRoot,
7
- resolveIdentifier,
8
- types,
9
- SnapshotOrInstance,
10
- Instance,
11
- } from 'mobx-state-tree'
12
- import { Region } from '@jbrowse/core/util/types/mst'
13
- import { transaction } from 'mobx'
14
- import { saveAs } from 'file-saver'
15
- import { renderToSvg } from '../svgcomponents/SVGCircularView'
16
- import {
17
- AnyConfigurationModel,
18
- readConfObject,
19
- } from '@jbrowse/core/configuration'
20
- import { MenuItem } from '@jbrowse/core/ui'
21
- import {
22
- getSession,
23
- clamp,
24
- isSessionModelWithWidgets,
25
- } from '@jbrowse/core/util'
26
- import { BaseViewModel } from '@jbrowse/core/pluggableElementTypes/models'
27
-
28
- // icons
29
- import { TrackSelector as TrackSelectorIcon } from '@jbrowse/core/ui/Icons'
30
- import FolderOpenIcon from '@mui/icons-material/FolderOpen'
31
- import PhotoCameraIcon from '@mui/icons-material/PhotoCamera'
32
-
33
- // locals
34
- import ExportSvgDlg from '../components/ExportSvgDialog'
35
- import { calculateStaticSlices, sliceIsVisible, SliceRegion } from './slices'
36
- import { viewportVisibleSection } from './viewportVisibleRegion'
37
-
38
- export interface ExportSvgOptions {
39
- rasterizeLayers?: boolean
40
- filename?: string
41
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
- Wrapper?: React.FC<any>
43
- themeName?: string
44
- }
45
-
46
- /**
47
- * #stateModel CircularView
48
- * extends `BaseViewModel`
49
- */
50
- function stateModelFactory(pluginManager: PluginManager) {
51
- const minHeight = 40
52
- const minWidth = 100
53
- const defaultHeight = 400
54
- return types
55
- .compose(
56
- BaseViewModel,
57
- types.model('CircularView', {
58
- /**
59
- * #property
60
- */
61
- type: types.literal('CircularView'),
62
- /**
63
- * #property
64
- * similar to offsetPx in linear genome view
65
- */
66
- offsetRadians: -Math.PI / 2,
67
- /**
68
- * #property
69
- */
70
- bpPerPx: 200,
71
- /**
72
- * #property
73
- */
74
- tracks: types.array(
75
- pluginManager.pluggableMstType('track', 'stateModel'),
76
- ),
77
-
78
- /**
79
- * #property
80
- */
81
- hideVerticalResizeHandle: false,
82
- /**
83
- * #property
84
- */
85
- hideTrackSelectorButton: false,
86
- /**
87
- * #property
88
- */
89
- lockedFitToWindow: true,
90
- /**
91
- * #property
92
- */
93
- disableImportForm: false,
94
-
95
- /**
96
- * #property
97
- */
98
- height: types.optional(
99
- types.refinement('trackHeight', types.number, n => n >= minHeight),
100
- defaultHeight,
101
- ),
102
- /**
103
- * #property
104
- */
105
- displayedRegions: types.array(Region),
106
- /**
107
- * #property
108
- */
109
- scrollX: 0,
110
- /**
111
- * #property
112
- */
113
- scrollY: 0,
114
-
115
- minimumRadiusPx: 25,
116
- spacingPx: 10,
117
- paddingPx: 80,
118
- lockedPaddingPx: 100,
119
- minVisibleWidth: 6,
120
- minimumBlockWidth: 20,
121
-
122
- trackSelectorType: 'hierarchical',
123
- }),
124
- )
125
- .volatile(() => ({
126
- volatileWidth: undefined as number | undefined,
127
- error: undefined as unknown,
128
- }))
129
- .views(self => ({
130
- /**
131
- * #getter
132
- */
133
- get width() {
134
- if (self.volatileWidth === undefined) {
135
- throw new Error(
136
- 'wait for view to be initialized first before accessing width',
137
- )
138
- }
139
- return self.volatileWidth
140
- },
141
-
142
- /**
143
- * #getter
144
- */
145
- get visibleSection() {
146
- return viewportVisibleSection(
147
- [
148
- self.scrollX,
149
- self.scrollX + self.width,
150
- self.scrollY,
151
- self.scrollY + self.height,
152
- ],
153
- this.centerXY,
154
- this.radiusPx,
155
- )
156
- },
157
- /**
158
- * #getter
159
- */
160
- get circumferencePx() {
161
- let elidedBp = 0
162
-
163
- for (const r of this.elidedRegions) {
164
- elidedBp += r.widthBp
165
- }
166
- return (
167
- elidedBp / self.bpPerPx + self.spacingPx * this.elidedRegions.length
168
- )
169
- },
170
- /**
171
- * #getter
172
- */
173
- get radiusPx() {
174
- return this.circumferencePx / (2 * Math.PI)
175
- },
176
- /**
177
- * #getter
178
- */
179
- get bpPerRadian() {
180
- return self.bpPerPx * this.radiusPx
181
- },
182
- /**
183
- * #getter
184
- */
185
- get pxPerRadian() {
186
- return this.radiusPx
187
- },
188
- /**
189
- * #getter
190
- */
191
- get centerXY(): [number, number] {
192
- return [this.radiusPx + self.paddingPx, this.radiusPx + self.paddingPx]
193
- },
194
- /**
195
- * #getter
196
- */
197
- get totalBp() {
198
- let total = 0
199
- for (const region of self.displayedRegions) {
200
- total += region.end - region.start
201
- }
202
- return total
203
- },
204
- /**
205
- * #getter
206
- */
207
- get maximumRadiusPx() {
208
- return self.lockedFitToWindow
209
- ? Math.min(self.width, self.height) / 2 - self.lockedPaddingPx
210
- : 1000000
211
- },
212
- /**
213
- * #getter
214
- */
215
- get maxBpPerPx() {
216
- const minCircumferencePx = 2 * Math.PI * self.minimumRadiusPx
217
- return this.totalBp / minCircumferencePx
218
- },
219
- /**
220
- * #getter
221
- */
222
- get minBpPerPx() {
223
- // min depends on window dimensions, clamp between old min(0.01) and max
224
- const maxCircumferencePx = 2 * Math.PI * this.maximumRadiusPx
225
- return clamp(
226
- this.totalBp / maxCircumferencePx,
227
- 0.0000000001,
228
- this.maxBpPerPx,
229
- )
230
- },
231
- /**
232
- * #getter
233
- */
234
- get atMaxBpPerPx() {
235
- return self.bpPerPx >= this.maxBpPerPx
236
- },
237
- /**
238
- * #getter
239
- */
240
- get atMinBpPerPx() {
241
- return self.bpPerPx <= this.minBpPerPx
242
- },
243
- /**
244
- * #getter
245
- */
246
- get tooSmallToLock() {
247
- return this.minBpPerPx <= 0.0000000001
248
- },
249
- /**
250
- * #getter
251
- */
252
- get figureDimensions(): [number, number] {
253
- return [
254
- this.radiusPx * 2 + 2 * self.paddingPx,
255
- this.radiusPx * 2 + 2 * self.paddingPx,
256
- ]
257
- },
258
- /**
259
- * #getter
260
- */
261
- get figureWidth() {
262
- return this.figureDimensions[0]
263
- },
264
- /**
265
- * #getter
266
- */
267
- get figureHeight() {
268
- return this.figureDimensions[1]
269
- },
270
- /**
271
- * #getter
272
- * this is displayedRegions, post-processed to
273
- * elide regions that are too small to see reasonably
274
- */
275
- get elidedRegions() {
276
- const visible: SliceRegion[] = []
277
- self.displayedRegions.forEach(region => {
278
- const widthBp = region.end - region.start
279
- const widthPx = widthBp / self.bpPerPx
280
- if (widthPx < self.minVisibleWidth) {
281
- // too small to see, collapse into a single elision region
282
- const lastVisible = visible[visible.length - 1]
283
- if (lastVisible?.elided) {
284
- lastVisible.regions.push({ ...region })
285
- lastVisible.widthBp += widthBp
286
- } else {
287
- visible.push({
288
- elided: true,
289
- widthBp,
290
- regions: [{ ...region }],
291
- })
292
- }
293
- } else {
294
- // big enough to see, display it
295
- visible.push({ ...region, widthBp, elided: false })
296
- }
297
- })
298
-
299
- // remove any single-region elisions
300
- for (let i = 0; i < visible.length; i += 1) {
301
- const v = visible[i]
302
- if (v.elided && v.regions.length === 1) {
303
- visible[i] = { ...v, ...v.regions[0], elided: false }
304
- }
305
- }
306
- return visible
307
- },
308
- /**
309
- * #getter
310
- */
311
- get assemblyNames() {
312
- const assemblyNames: string[] = []
313
- self.displayedRegions.forEach(displayedRegion => {
314
- if (!assemblyNames.includes(displayedRegion.assemblyName)) {
315
- assemblyNames.push(displayedRegion.assemblyName)
316
- }
317
- })
318
- return assemblyNames
319
- },
320
- /**
321
- * #getter
322
- */
323
- get initialized() {
324
- const { assemblyManager } = getSession(self)
325
- return (
326
- self.volatileWidth !== undefined &&
327
- this.assemblyNames.every(a => assemblyManager.get(a)?.initialized)
328
- )
329
- },
330
- }))
331
- .views(self => ({
332
- /**
333
- * #getter
334
- */
335
- get staticSlices() {
336
- return calculateStaticSlices(self)
337
- },
338
- }))
339
- .views(self => ({
340
- /**
341
- * #getter
342
- */
343
- get visibleStaticSlices() {
344
- return self.staticSlices.filter(s => sliceIsVisible(self, s))
345
- },
346
- }))
347
-
348
- .actions(self => ({
349
- /**
350
- * #action
351
- */
352
- setWidth(newWidth: number) {
353
- self.volatileWidth = Math.max(newWidth, minWidth)
354
- return self.volatileWidth
355
- },
356
- /**
357
- * #action
358
- */
359
- setHeight(newHeight: number) {
360
- self.height = Math.max(newHeight, minHeight)
361
- return self.height
362
- },
363
- /**
364
- * #action
365
- */
366
- resizeHeight(distance: number) {
367
- const oldHeight = self.height
368
- const newHeight = this.setHeight(self.height + distance)
369
- this.setModelViewWhenAdjust(!self.tooSmallToLock)
370
- return newHeight - oldHeight
371
- },
372
- /**
373
- * #action
374
- */
375
- resizeWidth(distance: number) {
376
- const oldWidth = self.width
377
- const newWidth = this.setWidth(self.width + distance)
378
- this.setModelViewWhenAdjust(!self.tooSmallToLock)
379
- return newWidth - oldWidth
380
- },
381
- /**
382
- * #action
383
- */
384
- rotateClockwiseButton() {
385
- this.rotateClockwise(Math.PI / 6)
386
- },
387
-
388
- /**
389
- * #action
390
- */
391
- rotateCounterClockwiseButton() {
392
- this.rotateCounterClockwise(Math.PI / 6)
393
- },
394
-
395
- /**
396
- * #action
397
- */
398
- rotateClockwise(distance = 0.17) {
399
- self.offsetRadians += distance
400
- },
401
-
402
- /**
403
- * #action
404
- */
405
- rotateCounterClockwise(distance = 0.17) {
406
- self.offsetRadians -= distance
407
- },
408
-
409
- /**
410
- * #action
411
- */
412
- zoomInButton() {
413
- this.setBpPerPx(self.bpPerPx / 1.4)
414
- },
415
-
416
- /**
417
- * #action
418
- */
419
- zoomOutButton() {
420
- this.setBpPerPx(self.bpPerPx * 1.4)
421
- },
422
-
423
- /**
424
- * #action
425
- */
426
- setBpPerPx(newVal: number) {
427
- self.bpPerPx = clamp(newVal, self.minBpPerPx, self.maxBpPerPx)
428
- },
429
-
430
- /**
431
- * #action
432
- */
433
- setModelViewWhenAdjust(secondCondition: boolean) {
434
- if (self.lockedFitToWindow && secondCondition) {
435
- this.setBpPerPx(self.minBpPerPx)
436
- }
437
- },
438
-
439
- /**
440
- * #action
441
- */
442
- closeView() {
443
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
444
- getParent<any>(self, 2).removeView(self)
445
- },
446
-
447
- /**
448
- * #action
449
- */
450
- setDisplayedRegions(regions: SnapshotOrInstance<typeof Region>[]) {
451
- const previouslyEmpty = self.displayedRegions.length === 0
452
- self.displayedRegions = cast(regions)
453
-
454
- if (previouslyEmpty) {
455
- this.setBpPerPx(self.minBpPerPx)
456
- } else {
457
- this.setBpPerPx(self.bpPerPx)
458
- }
459
- },
460
-
461
- /**
462
- * #action
463
- */
464
- activateTrackSelector() {
465
- if (self.trackSelectorType === 'hierarchical') {
466
- const session = getSession(self)
467
- if (isSessionModelWithWidgets(session)) {
468
- const selector = session.addWidget(
469
- 'HierarchicalTrackSelectorWidget',
470
- 'hierarchicalTrackSelector',
471
- { view: self },
472
- )
473
- session.showWidget(selector)
474
- return selector
475
- }
476
- }
477
- throw new Error(`invalid track selector type ${self.trackSelectorType}`)
478
- },
479
-
480
- /**
481
- * #action
482
- */
483
- toggleTrack(trackId: string) {
484
- // if we have any tracks with that configuration, turn them off
485
- const hiddenCount = this.hideTrack(trackId)
486
- // if none had that configuration, turn one on
487
- if (!hiddenCount) {
488
- this.showTrack(trackId)
489
- }
490
- },
491
-
492
- /**
493
- * #action
494
- */
495
- setError(error: unknown) {
496
- self.error = error
497
- },
498
-
499
- /**
500
- * #action
501
- */
502
- showTrack(trackId: string, initialSnapshot = {}) {
503
- const schema = pluginManager.pluggableConfigSchemaType('track')
504
- const conf = resolveIdentifier(schema, getRoot(self), trackId)
505
- const trackType = pluginManager.getTrackType(conf.type)
506
- if (!trackType) {
507
- throw new Error(`unknown track type ${conf.type}`)
508
- }
509
- const viewType = pluginManager.getViewType(self.type)
510
- const supportedDisplays = new Set(
511
- viewType.displayTypes.map(d => d.name),
512
- )
513
- const displayConf = conf.displays.find((d: AnyConfigurationModel) =>
514
- supportedDisplays.has(d.type),
515
- )
516
- const track = trackType.stateModel.create({
517
- ...initialSnapshot,
518
- type: conf.type,
519
- configuration: conf,
520
- displays: [{ type: displayConf.type, configuration: displayConf }],
521
- })
522
- self.tracks.push(track)
523
- },
524
-
525
- /**
526
- * #action
527
- */
528
- addTrackConf(configuration: AnyConfigurationModel, initialSnapshot = {}) {
529
- const { type } = configuration
530
- const name = readConfObject(configuration, 'name')
531
- const trackType = pluginManager.getTrackType(type)
532
- if (!trackType) {
533
- throw new Error(`unknown track type ${type}`)
534
- }
535
- const viewType = pluginManager.getViewType(self.type)
536
- const supportedDisplays = new Set(
537
- viewType.displayTypes.map(d => d.name),
538
- )
539
- const displayConf = configuration.displays.find(
540
- (d: AnyConfigurationModel) => supportedDisplays.has(d.type),
541
- )
542
- self.tracks.push(
543
- trackType.stateModel.create({
544
- ...initialSnapshot,
545
- name,
546
- type,
547
- configuration,
548
- displays: [{ type: displayConf.type, configuration: displayConf }],
549
- }),
550
- )
551
- },
552
-
553
- /**
554
- * #action
555
- */
556
- hideTrack(trackId: string) {
557
- const schema = pluginManager.pluggableConfigSchemaType('track')
558
- const conf = resolveIdentifier(schema, getRoot(self), trackId)
559
- const t = self.tracks.filter(t => t.configuration === conf)
560
- transaction(() => t.forEach(t => self.tracks.remove(t)))
561
- return t.length
562
- },
563
-
564
- /**
565
- * #action
566
- */
567
- toggleFitToWindowLock() {
568
- // when going unlocked -> locked and circle is cut off, set to the
569
- // locked minBpPerPx
570
- self.lockedFitToWindow = !self.lockedFitToWindow
571
- this.setModelViewWhenAdjust(self.atMinBpPerPx)
572
- return self.lockedFitToWindow
573
- },
574
- /**
575
- * #action
576
- * creates an svg export and save using FileSaver
577
- */
578
- async exportSvg(opts: ExportSvgOptions = {}) {
579
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
580
- const html = await renderToSvg(self as any, opts)
581
- const blob = new Blob([html], { type: 'image/svg+xml' })
582
- saveAs(blob, opts.filename || 'image.svg')
583
- },
584
- }))
585
- .views(self => ({
586
- /**
587
- * #method
588
- * return the view menu items
589
- */
590
- menuItems(): MenuItem[] {
591
- return [
592
- {
593
- label: 'Return to import form',
594
- onClick: () => self.setDisplayedRegions([]),
595
- icon: FolderOpenIcon,
596
- },
597
- {
598
- label: 'Export SVG',
599
- icon: PhotoCameraIcon,
600
- onClick: () => {
601
- getSession(self).queueDialog(handleClose => [
602
- ExportSvgDlg,
603
- { model: self, handleClose },
604
- ])
605
- },
606
- },
607
- {
608
- label: 'Open track selector',
609
- onClick: self.activateTrackSelector,
610
- icon: TrackSelectorIcon,
611
- },
612
- ]
613
- },
614
- }))
615
- }
616
-
617
- export type CircularViewStateModel = ReturnType<typeof stateModelFactory>
618
- export type CircularViewModel = Instance<CircularViewStateModel>
619
-
620
- export default stateModelFactory
@@ -1,91 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`one slice 1`] = `
4
- {
5
- "bpPerRadian": 1591.5494309189535,
6
- "endRadians": 6.283185307179586,
7
- "flipped": false,
8
- "key": "toast:1..10,000",
9
- "offsetRadians": 0,
10
- "radianWidth": 6.288185307179586,
11
- "region": {
12
- "end": 10000,
13
- "refName": "toast",
14
- "start": 0,
15
- "widthBp": 10000,
16
- },
17
- "startRadians": 0,
18
- }
19
- `;
20
-
21
- exports[`two slices 1`] = `
22
- [
23
- {
24
- "bpPerRadian": 3183.098861837907,
25
- "endRadians": 3.141592653589793,
26
- "flipped": false,
27
- "key": "toast:1..10,000",
28
- "offsetRadians": 0,
29
- "radianWidth": 3.146592653589793,
30
- "region": {
31
- "end": 10000,
32
- "refName": "toast",
33
- "start": 0,
34
- "widthBp": 10000,
35
- },
36
- "startRadians": 0,
37
- },
38
- {
39
- "bpPerRadian": 3183.098861837907,
40
- "endRadians": 6.288185307179586,
41
- "flipped": false,
42
- "key": "teest:1..10,000",
43
- "offsetRadians": 3.146592653589793,
44
- "radianWidth": 3.146592653589793,
45
- "region": {
46
- "end": 10000,
47
- "refName": "teest",
48
- "start": 0,
49
- "widthBp": 10000,
50
- },
51
- "startRadians": 3.146592653589793,
52
- },
53
- ]
54
- `;
55
-
56
- exports[`volvox 1`] = `
57
- [
58
- {
59
- "bpPerRadian": 8925.40920859349,
60
- "endRadians": 5.602096086738348,
61
- "flipped": false,
62
- "key": "{volvox}ctgA:1..50,001",
63
- "offsetRadians": 0,
64
- "radianWidth": 5.6070960867383475,
65
- "region": {
66
- "assemblyName": "volvox",
67
- "end": 50001,
68
- "refName": "ctgA",
69
- "start": 0,
70
- "widthBp": 50001,
71
- },
72
- "startRadians": 0,
73
- },
74
- {
75
- "bpPerRadian": 8925.40920859349,
76
- "endRadians": 6.288185307179587,
77
- "flipped": false,
78
- "key": "{volvox}ctgB:1..6,079",
79
- "offsetRadians": 5.6070960867383475,
80
- "radianWidth": 0.6860892204412394,
81
- "region": {
82
- "assemblyName": "volvox",
83
- "end": 6079,
84
- "refName": "ctgB",
85
- "start": 0,
86
- "widthBp": 6079,
87
- },
88
- "startRadians": 5.6070960867383475,
89
- },
90
- ]
91
- `;