@jbrowse/plugin-linear-comparative-view 2.6.1 → 2.6.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.
Files changed (209) hide show
  1. package/dist/LGVSyntenyDisplay/configSchemaF.d.ts +1 -3
  2. package/dist/LGVSyntenyDisplay/configSchemaF.js +0 -1
  3. package/dist/LGVSyntenyDisplay/index.js +0 -1
  4. package/dist/LGVSyntenyDisplay/model.d.ts +17 -76
  5. package/dist/LGVSyntenyDisplay/model.js +22 -4
  6. package/dist/LaunchLinearSyntenyView.js +0 -1
  7. package/dist/LinearComparativeDisplay/configSchemaF.js +0 -1
  8. package/dist/LinearComparativeDisplay/index.js +0 -1
  9. package/dist/LinearComparativeDisplay/stateModelFactory.js +0 -1
  10. package/dist/LinearComparativeView/components/Header.js +11 -2
  11. package/dist/LinearComparativeView/components/LinearComparativeView.js +0 -1
  12. package/dist/LinearComparativeView/components/Rubberband.js +11 -33
  13. package/dist/LinearComparativeView/components/VerticalGuide.d.ts +8 -0
  14. package/dist/LinearComparativeView/components/VerticalGuide.js +33 -0
  15. package/dist/LinearComparativeView/index.js +0 -1
  16. package/dist/LinearComparativeView/model.d.ts +9 -15
  17. package/dist/LinearComparativeView/model.js +0 -1
  18. package/dist/LinearReadVsRef/LinearReadVsRef.js +0 -1
  19. package/dist/LinearReadVsRef/index.js +0 -1
  20. package/dist/LinearSyntenyDisplay/afterAttach.js +0 -1
  21. package/dist/LinearSyntenyDisplay/components/Component.js +0 -1
  22. package/dist/LinearSyntenyDisplay/components/LinearSyntenyRendering.js +0 -1
  23. package/dist/LinearSyntenyDisplay/components/SyntenyTooltip.js +0 -1
  24. package/dist/LinearSyntenyDisplay/components/util.js +0 -1
  25. package/dist/LinearSyntenyDisplay/configSchemaF.js +0 -1
  26. package/dist/LinearSyntenyDisplay/drawSynteny.js +0 -1
  27. package/dist/LinearSyntenyDisplay/index.js +0 -1
  28. package/dist/LinearSyntenyDisplay/model.js +0 -1
  29. package/dist/LinearSyntenyView/components/ExportSvgDialog.js +0 -1
  30. package/dist/LinearSyntenyView/components/Icons.js +0 -1
  31. package/dist/LinearSyntenyView/components/ImportCustomTrack.js +0 -1
  32. package/dist/LinearSyntenyView/components/ImportForm.js +0 -1
  33. package/dist/LinearSyntenyView/components/ImportSyntenyTrackSelector.js +0 -1
  34. package/dist/LinearSyntenyView/components/LinearSyntenyView.js +0 -1
  35. package/dist/LinearSyntenyView/index.js +0 -1
  36. package/dist/LinearSyntenyView/model.d.ts +9 -9
  37. package/dist/LinearSyntenyView/model.js +0 -1
  38. package/dist/LinearSyntenyView/svgcomponents/SVGBackground.js +2 -2
  39. package/dist/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.js +0 -1
  40. package/dist/SyntenyFeatureDetail/SyntenyFeatureDetail.js +0 -1
  41. package/dist/SyntenyFeatureDetail/index.js +0 -1
  42. package/dist/SyntenyTrack/configSchema.js +0 -1
  43. package/dist/SyntenyTrack/index.js +0 -1
  44. package/dist/index.js +0 -1
  45. package/dist/util.js +0 -1
  46. package/esm/LGVSyntenyDisplay/configSchemaF.d.ts +1 -3
  47. package/esm/LGVSyntenyDisplay/configSchemaF.js +0 -1
  48. package/esm/LGVSyntenyDisplay/index.js +0 -1
  49. package/esm/LGVSyntenyDisplay/model.d.ts +17 -76
  50. package/esm/LGVSyntenyDisplay/model.js +23 -5
  51. package/esm/LaunchLinearSyntenyView.js +0 -1
  52. package/esm/LinearComparativeDisplay/configSchemaF.js +0 -1
  53. package/esm/LinearComparativeDisplay/index.js +0 -1
  54. package/esm/LinearComparativeDisplay/stateModelFactory.js +0 -1
  55. package/esm/LinearComparativeView/components/Header.js +11 -2
  56. package/esm/LinearComparativeView/components/LinearComparativeView.js +0 -1
  57. package/esm/LinearComparativeView/components/Rubberband.js +8 -33
  58. package/esm/LinearComparativeView/components/VerticalGuide.d.ts +8 -0
  59. package/esm/LinearComparativeView/components/VerticalGuide.js +28 -0
  60. package/esm/LinearComparativeView/index.js +0 -1
  61. package/esm/LinearComparativeView/model.d.ts +9 -15
  62. package/esm/LinearComparativeView/model.js +0 -1
  63. package/esm/LinearReadVsRef/LinearReadVsRef.js +0 -1
  64. package/esm/LinearReadVsRef/index.js +0 -1
  65. package/esm/LinearSyntenyDisplay/afterAttach.js +0 -1
  66. package/esm/LinearSyntenyDisplay/components/Component.js +0 -1
  67. package/esm/LinearSyntenyDisplay/components/LinearSyntenyRendering.js +0 -1
  68. package/esm/LinearSyntenyDisplay/components/SyntenyTooltip.js +0 -1
  69. package/esm/LinearSyntenyDisplay/components/util.js +0 -1
  70. package/esm/LinearSyntenyDisplay/configSchemaF.js +0 -1
  71. package/esm/LinearSyntenyDisplay/drawSynteny.js +0 -1
  72. package/esm/LinearSyntenyDisplay/index.js +0 -1
  73. package/esm/LinearSyntenyDisplay/model.js +0 -1
  74. package/esm/LinearSyntenyView/components/ExportSvgDialog.js +0 -1
  75. package/esm/LinearSyntenyView/components/Icons.js +0 -1
  76. package/esm/LinearSyntenyView/components/ImportCustomTrack.js +0 -1
  77. package/esm/LinearSyntenyView/components/ImportForm.js +0 -1
  78. package/esm/LinearSyntenyView/components/ImportSyntenyTrackSelector.js +0 -1
  79. package/esm/LinearSyntenyView/components/LinearSyntenyView.js +0 -1
  80. package/esm/LinearSyntenyView/index.js +0 -1
  81. package/esm/LinearSyntenyView/model.d.ts +9 -9
  82. package/esm/LinearSyntenyView/model.js +0 -1
  83. package/esm/LinearSyntenyView/svgcomponents/SVGBackground.js +2 -2
  84. package/esm/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.js +0 -1
  85. package/esm/SyntenyFeatureDetail/SyntenyFeatureDetail.js +0 -1
  86. package/esm/SyntenyFeatureDetail/index.js +0 -1
  87. package/esm/SyntenyTrack/configSchema.js +0 -1
  88. package/esm/SyntenyTrack/index.js +0 -1
  89. package/esm/index.js +0 -1
  90. package/esm/util.js +0 -1
  91. package/package.json +4 -4
  92. package/dist/LGVSyntenyDisplay/configSchemaF.js.map +0 -1
  93. package/dist/LGVSyntenyDisplay/index.js.map +0 -1
  94. package/dist/LGVSyntenyDisplay/model.js.map +0 -1
  95. package/dist/LaunchLinearSyntenyView.js.map +0 -1
  96. package/dist/LinearComparativeDisplay/configSchemaF.js.map +0 -1
  97. package/dist/LinearComparativeDisplay/index.js.map +0 -1
  98. package/dist/LinearComparativeDisplay/stateModelFactory.js.map +0 -1
  99. package/dist/LinearComparativeView/components/Header.js.map +0 -1
  100. package/dist/LinearComparativeView/components/LinearComparativeView.js.map +0 -1
  101. package/dist/LinearComparativeView/components/Rubberband.js.map +0 -1
  102. package/dist/LinearComparativeView/index.js.map +0 -1
  103. package/dist/LinearComparativeView/model.js.map +0 -1
  104. package/dist/LinearReadVsRef/LinearReadVsRef.js.map +0 -1
  105. package/dist/LinearReadVsRef/index.js.map +0 -1
  106. package/dist/LinearSyntenyDisplay/afterAttach.js.map +0 -1
  107. package/dist/LinearSyntenyDisplay/components/Component.js.map +0 -1
  108. package/dist/LinearSyntenyDisplay/components/LinearSyntenyRendering.js.map +0 -1
  109. package/dist/LinearSyntenyDisplay/components/SyntenyTooltip.js.map +0 -1
  110. package/dist/LinearSyntenyDisplay/components/util.js.map +0 -1
  111. package/dist/LinearSyntenyDisplay/configSchemaF.js.map +0 -1
  112. package/dist/LinearSyntenyDisplay/drawSynteny.js.map +0 -1
  113. package/dist/LinearSyntenyDisplay/index.js.map +0 -1
  114. package/dist/LinearSyntenyDisplay/model.js.map +0 -1
  115. package/dist/LinearSyntenyView/components/ExportSvgDialog.js.map +0 -1
  116. package/dist/LinearSyntenyView/components/Icons.js.map +0 -1
  117. package/dist/LinearSyntenyView/components/ImportCustomTrack.js.map +0 -1
  118. package/dist/LinearSyntenyView/components/ImportForm.js.map +0 -1
  119. package/dist/LinearSyntenyView/components/ImportSyntenyTrackSelector.js.map +0 -1
  120. package/dist/LinearSyntenyView/components/LinearSyntenyView.js.map +0 -1
  121. package/dist/LinearSyntenyView/index.js.map +0 -1
  122. package/dist/LinearSyntenyView/model.js.map +0 -1
  123. package/dist/LinearSyntenyView/svgcomponents/SVGBackground.js.map +0 -1
  124. package/dist/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.js.map +0 -1
  125. package/dist/SyntenyFeatureDetail/SyntenyFeatureDetail.js.map +0 -1
  126. package/dist/SyntenyFeatureDetail/index.js.map +0 -1
  127. package/dist/SyntenyTrack/configSchema.js.map +0 -1
  128. package/dist/SyntenyTrack/index.js.map +0 -1
  129. package/dist/index.js.map +0 -1
  130. package/dist/util.js.map +0 -1
  131. package/esm/LGVSyntenyDisplay/configSchemaF.js.map +0 -1
  132. package/esm/LGVSyntenyDisplay/index.js.map +0 -1
  133. package/esm/LGVSyntenyDisplay/model.js.map +0 -1
  134. package/esm/LaunchLinearSyntenyView.js.map +0 -1
  135. package/esm/LinearComparativeDisplay/configSchemaF.js.map +0 -1
  136. package/esm/LinearComparativeDisplay/index.js.map +0 -1
  137. package/esm/LinearComparativeDisplay/stateModelFactory.js.map +0 -1
  138. package/esm/LinearComparativeView/components/Header.js.map +0 -1
  139. package/esm/LinearComparativeView/components/LinearComparativeView.js.map +0 -1
  140. package/esm/LinearComparativeView/components/Rubberband.js.map +0 -1
  141. package/esm/LinearComparativeView/index.js.map +0 -1
  142. package/esm/LinearComparativeView/model.js.map +0 -1
  143. package/esm/LinearReadVsRef/LinearReadVsRef.js.map +0 -1
  144. package/esm/LinearReadVsRef/index.js.map +0 -1
  145. package/esm/LinearSyntenyDisplay/afterAttach.js.map +0 -1
  146. package/esm/LinearSyntenyDisplay/components/Component.js.map +0 -1
  147. package/esm/LinearSyntenyDisplay/components/LinearSyntenyRendering.js.map +0 -1
  148. package/esm/LinearSyntenyDisplay/components/SyntenyTooltip.js.map +0 -1
  149. package/esm/LinearSyntenyDisplay/components/util.js.map +0 -1
  150. package/esm/LinearSyntenyDisplay/configSchemaF.js.map +0 -1
  151. package/esm/LinearSyntenyDisplay/drawSynteny.js.map +0 -1
  152. package/esm/LinearSyntenyDisplay/index.js.map +0 -1
  153. package/esm/LinearSyntenyDisplay/model.js.map +0 -1
  154. package/esm/LinearSyntenyView/components/ExportSvgDialog.js.map +0 -1
  155. package/esm/LinearSyntenyView/components/Icons.js.map +0 -1
  156. package/esm/LinearSyntenyView/components/ImportCustomTrack.js.map +0 -1
  157. package/esm/LinearSyntenyView/components/ImportForm.js.map +0 -1
  158. package/esm/LinearSyntenyView/components/ImportSyntenyTrackSelector.js.map +0 -1
  159. package/esm/LinearSyntenyView/components/LinearSyntenyView.js.map +0 -1
  160. package/esm/LinearSyntenyView/index.js.map +0 -1
  161. package/esm/LinearSyntenyView/model.js.map +0 -1
  162. package/esm/LinearSyntenyView/svgcomponents/SVGBackground.js.map +0 -1
  163. package/esm/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.js.map +0 -1
  164. package/esm/SyntenyFeatureDetail/SyntenyFeatureDetail.js.map +0 -1
  165. package/esm/SyntenyFeatureDetail/index.js.map +0 -1
  166. package/esm/SyntenyTrack/configSchema.js.map +0 -1
  167. package/esm/SyntenyTrack/index.js.map +0 -1
  168. package/esm/index.js.map +0 -1
  169. package/esm/util.js.map +0 -1
  170. package/src/LGVSyntenyDisplay/configSchemaF.ts +0 -22
  171. package/src/LGVSyntenyDisplay/index.ts +0 -20
  172. package/src/LGVSyntenyDisplay/model.ts +0 -177
  173. package/src/LaunchLinearSyntenyView.ts +0 -86
  174. package/src/LinearComparativeDisplay/configSchemaF.ts +0 -22
  175. package/src/LinearComparativeDisplay/index.ts +0 -21
  176. package/src/LinearComparativeDisplay/stateModelFactory.ts +0 -212
  177. package/src/LinearComparativeView/components/Header.tsx +0 -103
  178. package/src/LinearComparativeView/components/LinearComparativeView.tsx +0 -152
  179. package/src/LinearComparativeView/components/Rubberband.tsx +0 -329
  180. package/src/LinearComparativeView/index.ts +0 -15
  181. package/src/LinearComparativeView/model.ts +0 -395
  182. package/src/LinearReadVsRef/LinearReadVsRef.tsx +0 -360
  183. package/src/LinearReadVsRef/index.ts +0 -58
  184. package/src/LinearSyntenyDisplay/afterAttach.ts +0 -149
  185. package/src/LinearSyntenyDisplay/components/Component.tsx +0 -75
  186. package/src/LinearSyntenyDisplay/components/LinearSyntenyRendering.tsx +0 -200
  187. package/src/LinearSyntenyDisplay/components/SyntenyTooltip.tsx +0 -82
  188. package/src/LinearSyntenyDisplay/components/util.ts +0 -142
  189. package/src/LinearSyntenyDisplay/configSchemaF.ts +0 -38
  190. package/src/LinearSyntenyDisplay/drawSynteny.ts +0 -266
  191. package/src/LinearSyntenyDisplay/index.ts +0 -21
  192. package/src/LinearSyntenyDisplay/model.ts +0 -187
  193. package/src/LinearSyntenyView/components/ExportSvgDialog.tsx +0 -148
  194. package/src/LinearSyntenyView/components/Icons.tsx +0 -24
  195. package/src/LinearSyntenyView/components/ImportCustomTrack.tsx +0 -262
  196. package/src/LinearSyntenyView/components/ImportForm.tsx +0 -221
  197. package/src/LinearSyntenyView/components/ImportSyntenyTrackSelector.tsx +0 -82
  198. package/src/LinearSyntenyView/components/LinearSyntenyView.tsx +0 -20
  199. package/src/LinearSyntenyView/index.ts +0 -15
  200. package/src/LinearSyntenyView/model.test.ts +0 -1605
  201. package/src/LinearSyntenyView/model.ts +0 -169
  202. package/src/LinearSyntenyView/svgcomponents/SVGBackground.tsx +0 -21
  203. package/src/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.tsx +0 -176
  204. package/src/SyntenyFeatureDetail/SyntenyFeatureDetail.tsx +0 -64
  205. package/src/SyntenyFeatureDetail/index.ts +0 -36
  206. package/src/SyntenyTrack/configSchema.ts +0 -23
  207. package/src/SyntenyTrack/index.tsx +0 -15
  208. package/src/index.tsx +0 -42
  209. package/src/util.ts +0 -124
@@ -1,395 +0,0 @@
1
- import { lazy } from 'react'
2
- import {
3
- addDisposer,
4
- cast,
5
- getParent,
6
- getPath,
7
- getRoot,
8
- onAction,
9
- resolveIdentifier,
10
- types,
11
- Instance,
12
- SnapshotIn,
13
- } from 'mobx-state-tree'
14
- import { autorun, transaction } from 'mobx'
15
-
16
- // jbrowse
17
- import BaseViewModel from '@jbrowse/core/pluggableElementTypes/models/BaseViewModel'
18
- import { MenuItem } from '@jbrowse/core/ui'
19
- import { getSession, isSessionModelWithWidgets, avg } from '@jbrowse/core/util'
20
- import PluginManager from '@jbrowse/core/PluginManager'
21
- import { AnyConfigurationModel } from '@jbrowse/core/configuration'
22
- import { ElementId } from '@jbrowse/core/util/types/mst'
23
- import {
24
- LinearGenomeViewModel,
25
- LinearGenomeViewStateModel,
26
- } from '@jbrowse/plugin-linear-genome-view'
27
-
28
- // icons
29
- import { TrackSelector as TrackSelectorIcon } from '@jbrowse/core/ui/Icons'
30
- import FolderOpenIcon from '@mui/icons-material/FolderOpen'
31
-
32
- // lazies
33
- const ReturnToImportFormDialog = lazy(
34
- () => import('@jbrowse/core/ui/ReturnToImportFormDialog'),
35
- )
36
-
37
- /**
38
- * #stateModel LinearComparativeView
39
- */
40
- function stateModelFactory(pluginManager: PluginManager) {
41
- return types
42
- .compose(
43
- 'LinearComparativeView',
44
- BaseViewModel,
45
- types.model({
46
- /**
47
- * #property
48
- */
49
- id: ElementId,
50
- /**
51
- * #property
52
- */
53
- type: types.literal('LinearComparativeView'),
54
- /**
55
- * #property
56
- */
57
- trackSelectorType: 'hierarchical',
58
- /**
59
- * #property
60
- */
61
- showIntraviewLinks: true,
62
- /**
63
- * #property
64
- */
65
- linkViews: false,
66
- /**
67
- * #property
68
- */
69
- interactToggled: false,
70
- /**
71
- * #property
72
- */
73
- middleComparativeHeight: 100,
74
- /**
75
- * #property
76
- */
77
- tracks: types.array(
78
- pluginManager.pluggableMstType('track', 'stateModel'),
79
- ),
80
- /**
81
- * #property
82
- * currently this is limited to an array of two
83
- */
84
- views: types.array(
85
- pluginManager.getViewType('LinearGenomeView')
86
- .stateModel as LinearGenomeViewStateModel,
87
- ),
88
-
89
- /**
90
- * #property
91
- * this represents tracks specific to this view specifically used
92
- * for read vs ref dotplots where this track would not really apply
93
- * elsewhere
94
- */
95
- viewTrackConfigs: types.array(
96
- pluginManager.pluggableConfigSchemaType('track'),
97
- ),
98
- }),
99
- )
100
- .volatile(() => ({
101
- width: undefined as number | undefined,
102
- }))
103
- .views(self => ({
104
- /**
105
- * #getter
106
- */
107
- get highResolutionScaling() {
108
- return 2
109
- },
110
- /**
111
- * #getter
112
- */
113
- get initialized() {
114
- return (
115
- self.width !== undefined &&
116
- self.views.length > 0 &&
117
- self.views.every(view => view.initialized)
118
- )
119
- },
120
-
121
- /**
122
- * #getter
123
- */
124
- get refNames() {
125
- return self.views.map(v => [
126
- ...new Set(v.staticBlocks.map(m => m.refName)),
127
- ])
128
- },
129
-
130
- /**
131
- * #getter
132
- */
133
- get assemblyNames() {
134
- return [...new Set(self.views.flatMap(v => v.assemblyNames))]
135
- },
136
- }))
137
- .actions(self => ({
138
- afterAttach() {
139
- addDisposer(
140
- self,
141
- onAction(self, param => {
142
- if (self.linkViews) {
143
- const { name, path, args } = param
144
-
145
- // doesn't link showTrack/hideTrack, doesn't make sense in
146
- // synteny views most time
147
- const actions = ['horizontalScroll', 'zoomTo', 'setScaleFactor']
148
- if (actions.includes(name) && path) {
149
- this.onSubviewAction(name, path, args)
150
- }
151
- }
152
- }),
153
- )
154
- },
155
-
156
- // automatically removes session assemblies associated with this view
157
- // e.g. read vs ref
158
- beforeDestroy() {
159
- const session = getSession(self)
160
- self.assemblyNames.forEach(asm => session.removeTemporaryAssembly(asm))
161
- },
162
-
163
- onSubviewAction(actionName: string, path: string, args?: unknown[]) {
164
- self.views.forEach(view => {
165
- const ret = getPath(view)
166
- if (ret.lastIndexOf(path) !== ret.length - path.length) {
167
- // @ts-expect-error
168
- view[actionName](args?.[0])
169
- }
170
- })
171
- },
172
-
173
- /**
174
- * #action
175
- */
176
- setWidth(newWidth: number) {
177
- self.width = newWidth
178
- },
179
-
180
- /**
181
- * #action
182
- */
183
- setViews(views: SnapshotIn<LinearGenomeViewModel>[]) {
184
- self.views = cast(views)
185
- },
186
-
187
- /**
188
- * #action
189
- */
190
- removeView(view: LinearGenomeViewModel) {
191
- self.views.remove(view)
192
- },
193
-
194
- /**
195
- * #action
196
- * removes the view itself from the state tree entirely by calling the
197
- * parent removeView
198
- */
199
- closeView() {
200
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
201
- getParent<any>(self, 2).removeView(self)
202
- },
203
-
204
- /**
205
- * #action
206
- */
207
- setMiddleComparativeHeight(n: number) {
208
- self.middleComparativeHeight = n
209
- return self.middleComparativeHeight
210
- },
211
-
212
- /**
213
- * #action
214
- */
215
- toggleLinkViews() {
216
- self.linkViews = !self.linkViews
217
- },
218
-
219
- /**
220
- * #action
221
- */
222
- activateTrackSelector() {
223
- if (self.trackSelectorType === 'hierarchical') {
224
- const session = getSession(self)
225
- if (isSessionModelWithWidgets(session)) {
226
- const selector = session.addWidget(
227
- 'HierarchicalTrackSelectorWidget',
228
- 'hierarchicalTrackSelector',
229
- { view: self },
230
- )
231
- session.showWidget(selector)
232
- return selector
233
- }
234
- return undefined
235
- }
236
- throw new Error(`invalid track selector type ${self.trackSelectorType}`)
237
- },
238
-
239
- /**
240
- * #action
241
- */
242
- toggleTrack(trackId: string) {
243
- // if we have any tracks with that configuration, turn them off
244
- const hiddenCount = this.hideTrack(trackId)
245
-
246
- // if none had that configuration, turn one on
247
- if (!hiddenCount) {
248
- this.showTrack(trackId)
249
- }
250
- },
251
-
252
- /**
253
- * #action
254
- */
255
- showTrack(trackId: string, initialSnapshot = {}) {
256
- const schema = pluginManager.pluggableConfigSchemaType('track')
257
- const configuration = resolveIdentifier(schema, getRoot(self), trackId)
258
- if (!configuration) {
259
- throw new Error(`track not found ${trackId}`)
260
- }
261
- const trackType = pluginManager.getTrackType(configuration.type)
262
- if (!trackType) {
263
- throw new Error(`unknown track type ${configuration.type}`)
264
- }
265
- const viewType = pluginManager.getViewType(self.type)
266
- const supportedDisplays = new Set(
267
- viewType.displayTypes.map(d => d.name),
268
- )
269
- const displayConf = configuration.displays.find(
270
- (d: AnyConfigurationModel) => supportedDisplays.has(d.type),
271
- )
272
- if (!displayConf) {
273
- throw new Error(
274
- `could not find a compatible display for view type ${self.type}`,
275
- )
276
- }
277
- self.tracks.push(
278
- trackType.stateModel.create({
279
- ...initialSnapshot,
280
- type: configuration.type,
281
- configuration,
282
- displays: [{ type: displayConf.type, configuration: displayConf }],
283
- }),
284
- )
285
- },
286
-
287
- /**
288
- * #action
289
- */
290
- hideTrack(trackId: string) {
291
- const schema = pluginManager.pluggableConfigSchemaType('track')
292
- const config = resolveIdentifier(schema, getRoot(self), trackId)
293
- const shownTracks = self.tracks.filter(t => t.configuration === config)
294
- transaction(() => shownTracks.forEach(t => self.tracks.remove(t)))
295
- return shownTracks.length
296
- },
297
- /**
298
- * #action
299
- */
300
- squareView() {
301
- const average = avg(self.views.map(v => v.bpPerPx))
302
- self.views.forEach(view => {
303
- const center = view.pxToBp(view.width / 2)
304
- view.setNewView(average, view.offsetPx)
305
- if (!center.refName) {
306
- return
307
- }
308
- view.centerAt(center.coord, center.refName, center.index)
309
- })
310
- },
311
- /**
312
- * #action
313
- */
314
- clearView() {
315
- self.views = cast([])
316
- self.tracks = cast([])
317
- },
318
- }))
319
- .views(() => ({
320
- /**
321
- * #method
322
- * includes a subset of view menu options because the full list is a
323
- * little overwhelming. overridden by subclasses
324
- */
325
- headerMenuItems(): MenuItem[] {
326
- return []
327
- },
328
- }))
329
- .views(self => ({
330
- /**
331
- * #method
332
- */
333
- menuItems(): MenuItem[] {
334
- return [
335
- ...self.views
336
- .map((view, idx) => [idx, view.menuItems?.()] as const)
337
- .filter(f => !!f[1])
338
- .map(f => ({ label: `View ${f[0] + 1} Menu`, subMenu: f[1] })),
339
- {
340
- label: 'Return to import form',
341
- onClick: () => {
342
- getSession(self).queueDialog(handleClose => [
343
- ReturnToImportFormDialog,
344
- { model: self, handleClose },
345
- ])
346
- },
347
- icon: FolderOpenIcon,
348
- },
349
- {
350
- label: 'Open track selector',
351
- onClick: self.activateTrackSelector,
352
- icon: TrackSelectorIcon,
353
- },
354
- ]
355
- },
356
- /**
357
- * #method
358
- */
359
- rubberBandMenuItems() {
360
- return [
361
- {
362
- label: 'Zoom to region(s)',
363
- onClick: () => {
364
- self.views.forEach(view => {
365
- const { leftOffset, rightOffset } = view
366
- if (leftOffset && rightOffset) {
367
- view.moveTo(leftOffset, rightOffset)
368
- }
369
- })
370
- },
371
- },
372
- ]
373
- },
374
- }))
375
- .actions(self => ({
376
- afterAttach() {
377
- addDisposer(
378
- self,
379
- autorun(() => {
380
- if (self.width) {
381
- self.views.forEach(v => v.setWidth(self.width))
382
- }
383
- }),
384
- )
385
- },
386
- }))
387
- }
388
-
389
- export type LinearComparativeViewStateModel = ReturnType<
390
- typeof stateModelFactory
391
- >
392
- export type LinearComparativeViewModel =
393
- Instance<LinearComparativeViewStateModel>
394
-
395
- export default stateModelFactory