@jbrowse/plugin-dotplot-view 2.6.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/LICENSE +201 -0
- package/dist/ComparativeRenderer/index.d.ts +27 -0
- package/dist/ComparativeRenderer/index.js +59 -0
- package/dist/ComparativeRenderer/index.js.map +1 -0
- package/dist/DotplotDisplay/components/DotplotDisplay.d.ts +8 -0
- package/dist/DotplotDisplay/components/DotplotDisplay.js +24 -0
- package/dist/DotplotDisplay/components/DotplotDisplay.js.map +1 -0
- package/dist/DotplotDisplay/index.d.ts +12 -0
- package/dist/DotplotDisplay/index.js +48 -0
- package/dist/DotplotDisplay/index.js.map +1 -0
- package/dist/DotplotDisplay/renderDotplotBlock.d.ts +11 -0
- package/dist/DotplotDisplay/renderDotplotBlock.js +57 -0
- package/dist/DotplotDisplay/renderDotplotBlock.js.map +1 -0
- package/dist/DotplotDisplay/stateModelFactory.d.ts +138 -0
- package/dist/DotplotDisplay/stateModelFactory.js +165 -0
- package/dist/DotplotDisplay/stateModelFactory.js.map +1 -0
- package/dist/DotplotReadVsRef/DotplotReadVsRef.d.ts +3 -0
- package/dist/DotplotReadVsRef/DotplotReadVsRef.js +102 -0
- package/dist/DotplotReadVsRef/DotplotReadVsRef.js.map +1 -0
- package/dist/DotplotReadVsRef/index.d.ts +2 -0
- package/dist/DotplotReadVsRef/index.js +42 -0
- package/dist/DotplotReadVsRef/index.js.map +1 -0
- package/dist/DotplotRenderer/ComparativeRenderRpc.d.ts +27 -0
- package/dist/DotplotRenderer/ComparativeRenderRpc.js +59 -0
- package/dist/DotplotRenderer/ComparativeRenderRpc.js.map +1 -0
- package/dist/DotplotRenderer/DotplotRenderer.d.ts +69 -0
- package/dist/DotplotRenderer/DotplotRenderer.js +274 -0
- package/dist/DotplotRenderer/DotplotRenderer.js.map +1 -0
- package/dist/DotplotRenderer/components/DotplotRendering.d.ts +5 -0
- package/dist/DotplotRenderer/components/DotplotRendering.js +13 -0
- package/dist/DotplotRenderer/components/DotplotRendering.js.map +1 -0
- package/dist/DotplotRenderer/configSchema.d.ts +61 -0
- package/dist/DotplotRenderer/configSchema.js +83 -0
- package/dist/DotplotRenderer/configSchema.js.map +1 -0
- package/dist/DotplotRenderer/index.d.ts +3 -0
- package/dist/DotplotRenderer/index.js +17 -0
- package/dist/DotplotRenderer/index.js.map +1 -0
- package/dist/DotplotView/1dview.d.ts +307 -0
- package/dist/DotplotView/1dview.js +95 -0
- package/dist/DotplotView/1dview.js.map +1 -0
- package/dist/DotplotView/blockTypes.d.ts +61 -0
- package/dist/DotplotView/blockTypes.js +117 -0
- package/dist/DotplotView/blockTypes.js.map +1 -0
- package/dist/DotplotView/components/Axes.d.ts +14 -0
- package/dist/DotplotView/components/Axes.js +127 -0
- package/dist/DotplotView/components/Axes.js.map +1 -0
- package/dist/DotplotView/components/CursorIcon.d.ts +4 -0
- package/dist/DotplotView/components/CursorIcon.js +19 -0
- package/dist/DotplotView/components/CursorIcon.js.map +1 -0
- package/dist/DotplotView/components/DotplotTooltip.d.ts +19 -0
- package/dist/DotplotView/components/DotplotTooltip.js +128 -0
- package/dist/DotplotView/components/DotplotTooltip.js.map +1 -0
- package/dist/DotplotView/components/DotplotView.d.ts +6 -0
- package/dist/DotplotView/components/DotplotView.js +272 -0
- package/dist/DotplotView/components/DotplotView.js.map +1 -0
- package/dist/DotplotView/components/DotplotWarnings.d.ts +6 -0
- package/dist/DotplotView/components/DotplotWarnings.js +40 -0
- package/dist/DotplotView/components/DotplotWarnings.js.map +1 -0
- package/dist/DotplotView/components/ExportSvgDialog.d.ts +8 -0
- package/dist/DotplotView/components/ExportSvgDialog.js +76 -0
- package/dist/DotplotView/components/ExportSvgDialog.js.map +1 -0
- package/dist/DotplotView/components/Grid.d.ts +10 -0
- package/dist/DotplotView/components/Grid.js +60 -0
- package/dist/DotplotView/components/Grid.js.map +1 -0
- package/dist/DotplotView/components/Header.d.ts +10 -0
- package/dist/DotplotView/components/Header.js +168 -0
- package/dist/DotplotView/components/Header.js.map +1 -0
- package/dist/DotplotView/components/ImportCustomTrack.d.ts +11 -0
- package/dist/DotplotView/components/ImportCustomTrack.js +180 -0
- package/dist/DotplotView/components/ImportCustomTrack.js.map +1 -0
- package/dist/DotplotView/components/ImportForm.d.ts +6 -0
- package/dist/DotplotView/components/ImportForm.js +121 -0
- package/dist/DotplotView/components/ImportForm.js.map +1 -0
- package/dist/DotplotView/components/ImportSyntenyTrackSelector.d.ts +9 -0
- package/dist/DotplotView/components/ImportSyntenyTrackSelector.js +69 -0
- package/dist/DotplotView/components/ImportSyntenyTrackSelector.js.map +1 -0
- package/dist/DotplotView/components/PanButtons.d.ts +6 -0
- package/dist/DotplotView/components/PanButtons.js +60 -0
- package/dist/DotplotView/components/PanButtons.js.map +1 -0
- package/dist/DotplotView/components/WarningDialog.d.ts +16 -0
- package/dist/DotplotView/components/WarningDialog.js +41 -0
- package/dist/DotplotView/components/WarningDialog.js.map +1 -0
- package/dist/DotplotView/components/util.d.ts +19 -0
- package/dist/DotplotView/components/util.js +90 -0
- package/dist/DotplotView/components/util.js.map +1 -0
- package/dist/DotplotView/index.d.ts +2 -0
- package/dist/DotplotView/index.js +44 -0
- package/dist/DotplotView/index.js.map +1 -0
- package/dist/DotplotView/model.d.ts +616 -0
- package/dist/DotplotView/model.js +647 -0
- package/dist/DotplotView/model.js.map +1 -0
- package/dist/DotplotView/svgcomponents/SVGBackground.d.ts +5 -0
- package/dist/DotplotView/svgcomponents/SVGBackground.js +13 -0
- package/dist/DotplotView/svgcomponents/SVGBackground.js.map +1 -0
- package/dist/DotplotView/svgcomponents/SVGDotplotView.d.ts +2 -0
- package/dist/DotplotView/svgcomponents/SVGDotplotView.js +47 -0
- package/dist/DotplotView/svgcomponents/SVGDotplotView.js.map +1 -0
- package/dist/LaunchDotplotView.d.ts +2 -0
- package/dist/LaunchDotplotView.js +45 -0
- package/dist/LaunchDotplotView.js.map +1 -0
- package/dist/ServerSideRenderedBlockContent.d.ts +12 -0
- package/dist/ServerSideRenderedBlockContent.js +87 -0
- package/dist/ServerSideRenderedBlockContent.js.map +1 -0
- package/dist/ServerSideSyntenyRendering.d.ts +23 -0
- package/dist/ServerSideSyntenyRendering.js +54 -0
- package/dist/ServerSideSyntenyRendering.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/util.d.ts +9 -0
- package/dist/util.js +9 -0
- package/dist/util.js.map +1 -0
- package/esm/ComparativeRenderer/index.d.ts +27 -0
- package/esm/ComparativeRenderer/index.js +53 -0
- package/esm/ComparativeRenderer/index.js.map +1 -0
- package/esm/DotplotDisplay/components/DotplotDisplay.d.ts +8 -0
- package/esm/DotplotDisplay/components/DotplotDisplay.js +19 -0
- package/esm/DotplotDisplay/components/DotplotDisplay.js.map +1 -0
- package/esm/DotplotDisplay/index.d.ts +12 -0
- package/esm/DotplotDisplay/index.js +41 -0
- package/esm/DotplotDisplay/index.js.map +1 -0
- package/esm/DotplotDisplay/renderDotplotBlock.d.ts +11 -0
- package/esm/DotplotDisplay/renderDotplotBlock.js +49 -0
- package/esm/DotplotDisplay/renderDotplotBlock.js.map +1 -0
- package/esm/DotplotDisplay/stateModelFactory.d.ts +138 -0
- package/esm/DotplotDisplay/stateModelFactory.js +158 -0
- package/esm/DotplotDisplay/stateModelFactory.js.map +1 -0
- package/esm/DotplotReadVsRef/DotplotReadVsRef.d.ts +3 -0
- package/esm/DotplotReadVsRef/DotplotReadVsRef.js +98 -0
- package/esm/DotplotReadVsRef/DotplotReadVsRef.js.map +1 -0
- package/esm/DotplotReadVsRef/index.d.ts +2 -0
- package/esm/DotplotReadVsRef/index.js +36 -0
- package/esm/DotplotReadVsRef/index.js.map +1 -0
- package/esm/DotplotRenderer/ComparativeRenderRpc.d.ts +27 -0
- package/esm/DotplotRenderer/ComparativeRenderRpc.js +53 -0
- package/esm/DotplotRenderer/ComparativeRenderRpc.js.map +1 -0
- package/esm/DotplotRenderer/DotplotRenderer.d.ts +69 -0
- package/esm/DotplotRenderer/DotplotRenderer.js +268 -0
- package/esm/DotplotRenderer/DotplotRenderer.js.map +1 -0
- package/esm/DotplotRenderer/components/DotplotRendering.d.ts +5 -0
- package/esm/DotplotRenderer/components/DotplotRendering.js +8 -0
- package/esm/DotplotRenderer/components/DotplotRendering.js.map +1 -0
- package/esm/DotplotRenderer/configSchema.d.ts +61 -0
- package/esm/DotplotRenderer/configSchema.js +81 -0
- package/esm/DotplotRenderer/configSchema.js.map +1 -0
- package/esm/DotplotRenderer/index.d.ts +3 -0
- package/esm/DotplotRenderer/index.js +12 -0
- package/esm/DotplotRenderer/index.js.map +1 -0
- package/esm/DotplotView/1dview.d.ts +307 -0
- package/esm/DotplotView/1dview.js +87 -0
- package/esm/DotplotView/1dview.js.map +1 -0
- package/esm/DotplotView/blockTypes.d.ts +61 -0
- package/esm/DotplotView/blockTypes.js +109 -0
- package/esm/DotplotView/blockTypes.js.map +1 -0
- package/esm/DotplotView/components/Axes.d.ts +14 -0
- package/esm/DotplotView/components/Axes.js +121 -0
- package/esm/DotplotView/components/Axes.js.map +1 -0
- package/esm/DotplotView/components/CursorIcon.d.ts +4 -0
- package/esm/DotplotView/components/CursorIcon.js +11 -0
- package/esm/DotplotView/components/CursorIcon.js.map +1 -0
- package/esm/DotplotView/components/DotplotTooltip.d.ts +19 -0
- package/esm/DotplotView/components/DotplotTooltip.js +101 -0
- package/esm/DotplotView/components/DotplotTooltip.js.map +1 -0
- package/esm/DotplotView/components/DotplotView.d.ts +6 -0
- package/esm/DotplotView/components/DotplotView.js +244 -0
- package/esm/DotplotView/components/DotplotView.js.map +1 -0
- package/esm/DotplotView/components/DotplotWarnings.d.ts +6 -0
- package/esm/DotplotView/components/DotplotWarnings.js +15 -0
- package/esm/DotplotView/components/DotplotWarnings.js.map +1 -0
- package/esm/DotplotView/components/ExportSvgDialog.d.ts +8 -0
- package/esm/DotplotView/components/ExportSvgDialog.js +50 -0
- package/esm/DotplotView/components/ExportSvgDialog.js.map +1 -0
- package/esm/DotplotView/components/Grid.d.ts +10 -0
- package/esm/DotplotView/components/Grid.js +53 -0
- package/esm/DotplotView/components/Grid.js.map +1 -0
- package/esm/DotplotView/components/Header.d.ts +10 -0
- package/esm/DotplotView/components/Header.js +140 -0
- package/esm/DotplotView/components/Header.js.map +1 -0
- package/esm/DotplotView/components/ImportCustomTrack.d.ts +11 -0
- package/esm/DotplotView/components/ImportCustomTrack.js +152 -0
- package/esm/DotplotView/components/ImportCustomTrack.js.map +1 -0
- package/esm/DotplotView/components/ImportForm.d.ts +6 -0
- package/esm/DotplotView/components/ImportForm.js +93 -0
- package/esm/DotplotView/components/ImportForm.js.map +1 -0
- package/esm/DotplotView/components/ImportSyntenyTrackSelector.d.ts +9 -0
- package/esm/DotplotView/components/ImportSyntenyTrackSelector.js +44 -0
- package/esm/DotplotView/components/ImportSyntenyTrackSelector.js.map +1 -0
- package/esm/DotplotView/components/PanButtons.d.ts +6 -0
- package/esm/DotplotView/components/PanButtons.js +55 -0
- package/esm/DotplotView/components/PanButtons.js.map +1 -0
- package/esm/DotplotView/components/WarningDialog.d.ts +16 -0
- package/esm/DotplotView/components/WarningDialog.js +36 -0
- package/esm/DotplotView/components/WarningDialog.js.map +1 -0
- package/esm/DotplotView/components/util.d.ts +19 -0
- package/esm/DotplotView/components/util.js +83 -0
- package/esm/DotplotView/components/util.js.map +1 -0
- package/esm/DotplotView/index.d.ts +2 -0
- package/esm/DotplotView/index.js +15 -0
- package/esm/DotplotView/index.js.map +1 -0
- package/esm/DotplotView/model.d.ts +616 -0
- package/esm/DotplotView/model.js +616 -0
- package/esm/DotplotView/model.js.map +1 -0
- package/esm/DotplotView/svgcomponents/SVGBackground.d.ts +5 -0
- package/esm/DotplotView/svgcomponents/SVGBackground.js +7 -0
- package/esm/DotplotView/svgcomponents/SVGBackground.js.map +1 -0
- package/esm/DotplotView/svgcomponents/SVGDotplotView.d.ts +2 -0
- package/esm/DotplotView/svgcomponents/SVGDotplotView.js +40 -0
- package/esm/DotplotView/svgcomponents/SVGDotplotView.js.map +1 -0
- package/esm/LaunchDotplotView.d.ts +2 -0
- package/esm/LaunchDotplotView.js +42 -0
- package/esm/LaunchDotplotView.js.map +1 -0
- package/esm/ServerSideRenderedBlockContent.d.ts +12 -0
- package/esm/ServerSideRenderedBlockContent.js +62 -0
- package/esm/ServerSideRenderedBlockContent.js.map +1 -0
- package/esm/ServerSideSyntenyRendering.d.ts +23 -0
- package/esm/ServerSideSyntenyRendering.js +29 -0
- package/esm/ServerSideSyntenyRendering.js.map +1 -0
- package/esm/index.d.ts +7 -0
- package/esm/index.js +38 -0
- package/esm/index.js.map +1 -0
- package/esm/util.d.ts +9 -0
- package/esm/util.js +5 -0
- package/esm/util.js.map +1 -0
- package/package.json +69 -0
- package/src/ComparativeRenderer/index.ts +87 -0
- package/src/DotplotDisplay/components/DotplotDisplay.tsx +34 -0
- package/src/DotplotDisplay/index.ts +48 -0
- package/src/DotplotDisplay/renderDotplotBlock.ts +60 -0
- package/src/DotplotDisplay/stateModelFactory.tsx +196 -0
- package/src/DotplotReadVsRef/DotplotReadVsRef.ts +115 -0
- package/src/DotplotReadVsRef/index.ts +50 -0
- package/src/DotplotRenderer/ComparativeRenderRpc.ts +87 -0
- package/src/DotplotRenderer/DotplotRenderer.ts +328 -0
- package/src/DotplotRenderer/__image_snapshots__/linear-synteny-renderer-test-ts-test-rendering-a-simple-synteny-from-fake-data-1-snap.png +0 -0
- package/src/DotplotRenderer/components/DotplotRendering.tsx +12 -0
- package/src/DotplotRenderer/configSchema.ts +92 -0
- package/src/DotplotRenderer/index.ts +16 -0
- package/src/DotplotView/1dview.ts +98 -0
- package/src/DotplotView/blockTypes.ts +140 -0
- package/src/DotplotView/components/Axes.tsx +246 -0
- package/src/DotplotView/components/CursorIcon.tsx +24 -0
- package/src/DotplotView/components/DotplotTooltip.tsx +163 -0
- package/src/DotplotView/components/DotplotView.tsx +348 -0
- package/src/DotplotView/components/DotplotWarnings.tsx +26 -0
- package/src/DotplotView/components/ExportSvgDialog.tsx +129 -0
- package/src/DotplotView/components/Grid.tsx +112 -0
- package/src/DotplotView/components/Header.tsx +182 -0
- package/src/DotplotView/components/ImportCustomTrack.tsx +262 -0
- package/src/DotplotView/components/ImportForm.tsx +209 -0
- package/src/DotplotView/components/ImportSyntenyTrackSelector.tsx +90 -0
- package/src/DotplotView/components/PanButtons.tsx +93 -0
- package/src/DotplotView/components/WarningDialog.tsx +74 -0
- package/src/DotplotView/components/util.ts +118 -0
- package/src/DotplotView/index.ts +16 -0
- package/src/DotplotView/model.test.ts +17 -0
- package/src/DotplotView/model.ts +719 -0
- package/src/DotplotView/svgcomponents/SVGBackground.tsx +21 -0
- package/src/DotplotView/svgcomponents/SVGDotplotView.tsx +68 -0
- package/src/LaunchDotplotView.ts +63 -0
- package/src/ServerSideRenderedBlockContent.tsx +86 -0
- package/src/ServerSideSyntenyRendering.tsx +54 -0
- package/src/index.ts +41 -0
- package/src/util.ts +14 -0
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react'
|
|
2
|
+
import { LoadingEllipses, Menu, ResizeHandle } from '@jbrowse/core/ui'
|
|
3
|
+
import { observer } from 'mobx-react'
|
|
4
|
+
import { transaction } from 'mobx'
|
|
5
|
+
import { makeStyles } from 'tss-react/mui'
|
|
6
|
+
import normalizeWheel from 'normalize-wheel'
|
|
7
|
+
|
|
8
|
+
// locals
|
|
9
|
+
import { DotplotViewModel } from '../model'
|
|
10
|
+
import ImportForm from './ImportForm'
|
|
11
|
+
import Header from './Header'
|
|
12
|
+
import Grid from './Grid'
|
|
13
|
+
import { HorizontalAxis, VerticalAxis } from './Axes'
|
|
14
|
+
import { TooltipWhereClicked, TooltipWhereMouseovered } from './DotplotTooltip'
|
|
15
|
+
|
|
16
|
+
const blank = { left: 0, top: 0, width: 0, height: 0 }
|
|
17
|
+
|
|
18
|
+
const useStyles = makeStyles()(theme => ({
|
|
19
|
+
spacer: {
|
|
20
|
+
gridColumn: '1/2',
|
|
21
|
+
gridRow: '2/2',
|
|
22
|
+
},
|
|
23
|
+
root: {
|
|
24
|
+
position: 'relative',
|
|
25
|
+
marginBottom: theme.spacing(1),
|
|
26
|
+
overflow: 'hidden',
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
container: {
|
|
30
|
+
display: 'grid',
|
|
31
|
+
padding: 5,
|
|
32
|
+
position: 'relative',
|
|
33
|
+
},
|
|
34
|
+
overlay: {
|
|
35
|
+
pointerEvents: 'none',
|
|
36
|
+
overflow: 'hidden',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
width: '100%',
|
|
39
|
+
gridRow: '1/2',
|
|
40
|
+
gridColumn: '2/2',
|
|
41
|
+
zIndex: 100, // needs to be below controls
|
|
42
|
+
'& path': {
|
|
43
|
+
cursor: 'crosshair',
|
|
44
|
+
fill: 'none',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
content: {
|
|
49
|
+
position: 'relative',
|
|
50
|
+
gridColumn: '2/2',
|
|
51
|
+
gridRow: '1/2',
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
resizeHandle: {
|
|
55
|
+
height: 4,
|
|
56
|
+
background: '#ccc',
|
|
57
|
+
boxSizing: 'border-box',
|
|
58
|
+
borderTop: '1px solid #fafafa',
|
|
59
|
+
},
|
|
60
|
+
}))
|
|
61
|
+
|
|
62
|
+
type Coord = [number, number] | undefined
|
|
63
|
+
type Rect = { left: number; top: number }
|
|
64
|
+
|
|
65
|
+
// produces offsetX/offsetY coordinates from a clientX and an element's
|
|
66
|
+
// getBoundingClientRect
|
|
67
|
+
function getOffset(coord: Coord, rect: Rect) {
|
|
68
|
+
return coord && ([coord[0] - rect.left, coord[1] - rect.top] as Coord)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const RenderedComponent = observer(({ model }: { model: DotplotViewModel }) => {
|
|
72
|
+
const { classes } = useStyles()
|
|
73
|
+
return (
|
|
74
|
+
<div className={classes.overlay}>
|
|
75
|
+
{model.tracks.map(track => {
|
|
76
|
+
const [display] = track.displays
|
|
77
|
+
const { RenderingComponent } = display
|
|
78
|
+
return RenderingComponent ? (
|
|
79
|
+
<RenderingComponent
|
|
80
|
+
key={track.configuration.trackId}
|
|
81
|
+
model={display}
|
|
82
|
+
/>
|
|
83
|
+
) : null
|
|
84
|
+
})}
|
|
85
|
+
</div>
|
|
86
|
+
)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const DotplotViewInternal = observer(function ({
|
|
90
|
+
model,
|
|
91
|
+
}: {
|
|
92
|
+
model: DotplotViewModel
|
|
93
|
+
}) {
|
|
94
|
+
const { classes } = useStyles()
|
|
95
|
+
const [mousecurrClient, setMouseCurrClient] = useState<Coord>()
|
|
96
|
+
const [mousedownClient, setMouseDownClient] = useState<Coord>()
|
|
97
|
+
const [mouseOvered, setMouseOvered] = useState(false)
|
|
98
|
+
const [mouseupClient, setMouseUpClient] = useState<Coord>()
|
|
99
|
+
const ref = useRef<HTMLDivElement>(null)
|
|
100
|
+
const root = useRef<HTMLDivElement>(null)
|
|
101
|
+
const distanceX = useRef(0)
|
|
102
|
+
const distanceY = useRef(0)
|
|
103
|
+
const scheduled = useRef(false)
|
|
104
|
+
const [ctrlKeyWasUsed, setCtrlKeyWasUsed] = useState(false)
|
|
105
|
+
const svg = ref.current?.getBoundingClientRect() || blank
|
|
106
|
+
const rootRect = ref.current?.getBoundingClientRect() || blank
|
|
107
|
+
const mousedown = getOffset(mousedownClient, svg)
|
|
108
|
+
const mousecurr = getOffset(mousecurrClient, svg)
|
|
109
|
+
const mouseup = getOffset(mouseupClient, svg)
|
|
110
|
+
const mouserectClient = mouseupClient || mousecurrClient
|
|
111
|
+
const mouserect = mouseup || mousecurr
|
|
112
|
+
const xdistance = mousedown && mouserect ? mouserect[0] - mousedown[0] : 0
|
|
113
|
+
const ydistance = mousedown && mouserect ? mouserect[1] - mousedown[1] : 0
|
|
114
|
+
const { hview, vview, wheelMode, cursorMode } = model
|
|
115
|
+
|
|
116
|
+
const validPan =
|
|
117
|
+
(cursorMode === 'move' && !ctrlKeyWasUsed) ||
|
|
118
|
+
(cursorMode === 'crosshair' && ctrlKeyWasUsed)
|
|
119
|
+
|
|
120
|
+
const validSelect =
|
|
121
|
+
(cursorMode === 'move' && ctrlKeyWasUsed) ||
|
|
122
|
+
(cursorMode === 'crosshair' && !ctrlKeyWasUsed)
|
|
123
|
+
|
|
124
|
+
// use non-React wheel handler to properly prevent body scrolling
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
function onWheel(origEvent: WheelEvent) {
|
|
127
|
+
const event = normalizeWheel(origEvent)
|
|
128
|
+
origEvent.preventDefault()
|
|
129
|
+
|
|
130
|
+
distanceX.current += event.pixelX
|
|
131
|
+
distanceY.current -= event.pixelY
|
|
132
|
+
if (!scheduled.current) {
|
|
133
|
+
scheduled.current = true
|
|
134
|
+
|
|
135
|
+
window.requestAnimationFrame(() => {
|
|
136
|
+
transaction(() => {
|
|
137
|
+
if (wheelMode === 'pan') {
|
|
138
|
+
hview.scroll(distanceX.current / 3)
|
|
139
|
+
vview.scroll(distanceY.current / 10)
|
|
140
|
+
} else if (wheelMode === 'zoom') {
|
|
141
|
+
if (
|
|
142
|
+
Math.abs(distanceY.current) > Math.abs(distanceX.current) * 2 &&
|
|
143
|
+
mousecurr
|
|
144
|
+
) {
|
|
145
|
+
const val = distanceY.current < 0 ? 1.1 : 0.9
|
|
146
|
+
hview.zoomTo(hview.bpPerPx * val, mousecurr[0])
|
|
147
|
+
vview.zoomTo(
|
|
148
|
+
vview.bpPerPx * val,
|
|
149
|
+
rootRect.height - mousecurr[1],
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
scheduled.current = false
|
|
155
|
+
distanceX.current = 0
|
|
156
|
+
distanceY.current = 0
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (ref.current) {
|
|
161
|
+
const curr = ref.current
|
|
162
|
+
curr.addEventListener('wheel', onWheel)
|
|
163
|
+
return () => curr.removeEventListener('wheel', onWheel)
|
|
164
|
+
}
|
|
165
|
+
return () => {}
|
|
166
|
+
}, [hview, vview, wheelMode, mousecurr, rootRect.height])
|
|
167
|
+
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
function globalMouseMove(event: MouseEvent) {
|
|
170
|
+
setMouseCurrClient([event.clientX, event.clientY])
|
|
171
|
+
|
|
172
|
+
if (mousecurrClient && mousedownClient && validPan && !mouseupClient) {
|
|
173
|
+
hview.scroll(-event.clientX + mousecurrClient[0])
|
|
174
|
+
vview.scroll(event.clientY - mousecurrClient[1])
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
window.addEventListener('mousemove', globalMouseMove)
|
|
179
|
+
return () => window.removeEventListener('mousemove', globalMouseMove)
|
|
180
|
+
}, [
|
|
181
|
+
validPan,
|
|
182
|
+
mousecurrClient,
|
|
183
|
+
mousedownClient,
|
|
184
|
+
cursorMode,
|
|
185
|
+
ctrlKeyWasUsed,
|
|
186
|
+
mouseupClient,
|
|
187
|
+
hview,
|
|
188
|
+
vview,
|
|
189
|
+
])
|
|
190
|
+
|
|
191
|
+
// detect a mouseup after a mousedown was submitted, autoremoves mouseup
|
|
192
|
+
// once that single mouseup is set
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
function globalMouseUp(event: MouseEvent) {
|
|
195
|
+
if (Math.abs(xdistance) > 3 && Math.abs(ydistance) > 3 && validSelect) {
|
|
196
|
+
setMouseUpClient([event.clientX, event.clientY])
|
|
197
|
+
} else {
|
|
198
|
+
setMouseDownClient(undefined)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (mousedown && !mouseup) {
|
|
203
|
+
window.addEventListener('mouseup', globalMouseUp, true)
|
|
204
|
+
return () => window.removeEventListener('mouseup', globalMouseUp, true)
|
|
205
|
+
}
|
|
206
|
+
return () => {}
|
|
207
|
+
}, [
|
|
208
|
+
validSelect,
|
|
209
|
+
mousedown,
|
|
210
|
+
mousecurr,
|
|
211
|
+
mouseup,
|
|
212
|
+
xdistance,
|
|
213
|
+
ydistance,
|
|
214
|
+
ctrlKeyWasUsed,
|
|
215
|
+
cursorMode,
|
|
216
|
+
])
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<div>
|
|
220
|
+
<Header
|
|
221
|
+
model={model}
|
|
222
|
+
selection={
|
|
223
|
+
!validSelect || !(mousedown && mouserect)
|
|
224
|
+
? undefined
|
|
225
|
+
: {
|
|
226
|
+
width: Math.abs(xdistance),
|
|
227
|
+
height: Math.abs(ydistance),
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/>
|
|
231
|
+
<div
|
|
232
|
+
ref={root}
|
|
233
|
+
className={classes.root}
|
|
234
|
+
onMouseLeave={() => setMouseOvered(false)}
|
|
235
|
+
onMouseEnter={() => setMouseOvered(true)}
|
|
236
|
+
>
|
|
237
|
+
<div className={classes.container}>
|
|
238
|
+
<VerticalAxis model={model} />
|
|
239
|
+
<HorizontalAxis model={model} />
|
|
240
|
+
<div ref={ref} className={classes.content}>
|
|
241
|
+
{mouseOvered && validSelect ? (
|
|
242
|
+
<TooltipWhereMouseovered
|
|
243
|
+
model={model}
|
|
244
|
+
mouserect={mouserect}
|
|
245
|
+
mouserectClient={mouserectClient}
|
|
246
|
+
xdistance={xdistance}
|
|
247
|
+
ydistance={ydistance}
|
|
248
|
+
/>
|
|
249
|
+
) : null}
|
|
250
|
+
{validSelect ? (
|
|
251
|
+
<TooltipWhereClicked
|
|
252
|
+
model={model}
|
|
253
|
+
mousedown={mousedown}
|
|
254
|
+
mousedownClient={mousedownClient}
|
|
255
|
+
xdistance={xdistance}
|
|
256
|
+
ydistance={ydistance}
|
|
257
|
+
/>
|
|
258
|
+
) : null}
|
|
259
|
+
<div
|
|
260
|
+
style={{ cursor: ctrlKeyWasUsed ? 'pointer' : cursorMode }}
|
|
261
|
+
onMouseDown={event => {
|
|
262
|
+
if (event.button === 0) {
|
|
263
|
+
const { clientX, clientY } = event
|
|
264
|
+
setMouseDownClient([clientX, clientY])
|
|
265
|
+
setMouseCurrClient([clientX, clientY])
|
|
266
|
+
setCtrlKeyWasUsed(event.ctrlKey)
|
|
267
|
+
}
|
|
268
|
+
}}
|
|
269
|
+
>
|
|
270
|
+
<Grid model={model}>
|
|
271
|
+
{validSelect && mousedown && mouserect ? (
|
|
272
|
+
<rect
|
|
273
|
+
fill="rgba(255,0,0,0.3)"
|
|
274
|
+
x={Math.min(mouserect[0], mousedown[0])}
|
|
275
|
+
y={Math.min(mouserect[1], mousedown[1])}
|
|
276
|
+
width={Math.abs(xdistance)}
|
|
277
|
+
height={Math.abs(ydistance)}
|
|
278
|
+
/>
|
|
279
|
+
) : null}
|
|
280
|
+
</Grid>
|
|
281
|
+
</div>
|
|
282
|
+
<div className={classes.spacer} />
|
|
283
|
+
</div>
|
|
284
|
+
<RenderedComponent model={model} />
|
|
285
|
+
<Menu
|
|
286
|
+
open={Boolean(mouseup)}
|
|
287
|
+
onMenuItemClick={(_, callback) => {
|
|
288
|
+
callback()
|
|
289
|
+
setMouseUpClient(undefined)
|
|
290
|
+
setMouseDownClient(undefined)
|
|
291
|
+
}}
|
|
292
|
+
onClose={() => {
|
|
293
|
+
setMouseUpClient(undefined)
|
|
294
|
+
setMouseDownClient(undefined)
|
|
295
|
+
}}
|
|
296
|
+
anchorReference="anchorPosition"
|
|
297
|
+
anchorPosition={
|
|
298
|
+
mouseupClient
|
|
299
|
+
? {
|
|
300
|
+
top: mouseupClient[1] + 50,
|
|
301
|
+
left: mouseupClient[0] + 50,
|
|
302
|
+
}
|
|
303
|
+
: undefined
|
|
304
|
+
}
|
|
305
|
+
style={{ zIndex: 10000 }}
|
|
306
|
+
menuItems={[
|
|
307
|
+
{
|
|
308
|
+
label: 'Zoom in',
|
|
309
|
+
onClick: () => {
|
|
310
|
+
if (mousedown && mouseup) {
|
|
311
|
+
model.zoomIn(mousedown, mouseup)
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
label: 'Open linear synteny view',
|
|
317
|
+
onClick: () => {
|
|
318
|
+
if (mousedown && mouseup) {
|
|
319
|
+
model.onDotplotView(mousedown, mouseup)
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
]}
|
|
324
|
+
/>
|
|
325
|
+
</div>
|
|
326
|
+
<ResizeHandle
|
|
327
|
+
onDrag={n => model.setHeight(model.height + n)}
|
|
328
|
+
className={classes.resizeHandle}
|
|
329
|
+
/>
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
)
|
|
333
|
+
})
|
|
334
|
+
const DotplotView = observer(({ model }: { model: DotplotViewModel }) => {
|
|
335
|
+
const { initialized, loading, error } = model
|
|
336
|
+
|
|
337
|
+
if ((!initialized && !loading) || error) {
|
|
338
|
+
return <ImportForm model={model} />
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (loading) {
|
|
342
|
+
return <LoadingEllipses variant="h6" />
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return <DotplotViewInternal model={model} />
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
export default DotplotView
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { lazy, useState } from 'react'
|
|
2
|
+
import { Alert, Button } from '@mui/material'
|
|
3
|
+
import { observer } from 'mobx-react'
|
|
4
|
+
|
|
5
|
+
// locals
|
|
6
|
+
import { DotplotViewModel } from '../model'
|
|
7
|
+
|
|
8
|
+
// lazy components
|
|
9
|
+
const WarningDialog = lazy(() => import('./WarningDialog'))
|
|
10
|
+
|
|
11
|
+
export default observer(function ({ model }: { model: DotplotViewModel }) {
|
|
12
|
+
const trackWarnings = model.tracks.filter(t => t.displays[0].warnings?.length)
|
|
13
|
+
const [shown, setShown] = useState(false)
|
|
14
|
+
return trackWarnings.length ? (
|
|
15
|
+
<Alert severity="warning">
|
|
16
|
+
Warnings during render{' '}
|
|
17
|
+
<Button onClick={() => setShown(true)}>More info</Button>
|
|
18
|
+
{shown ? (
|
|
19
|
+
<WarningDialog
|
|
20
|
+
trackWarnings={trackWarnings}
|
|
21
|
+
handleClose={() => setShown(false)}
|
|
22
|
+
/>
|
|
23
|
+
) : null}
|
|
24
|
+
</Alert>
|
|
25
|
+
) : null
|
|
26
|
+
})
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Checkbox,
|
|
5
|
+
CircularProgress,
|
|
6
|
+
DialogActions,
|
|
7
|
+
DialogContent,
|
|
8
|
+
FormControlLabel,
|
|
9
|
+
MenuItem,
|
|
10
|
+
TextField,
|
|
11
|
+
Typography,
|
|
12
|
+
} from '@mui/material'
|
|
13
|
+
import { Dialog, ErrorMessage } from '@jbrowse/core/ui'
|
|
14
|
+
import { ExportSvgOptions } from '../model'
|
|
15
|
+
import { getSession, useLocalStorage } from '@jbrowse/core/util'
|
|
16
|
+
|
|
17
|
+
function LoadingMessage() {
|
|
18
|
+
return (
|
|
19
|
+
<div>
|
|
20
|
+
<CircularProgress size={20} style={{ marginRight: 20 }} />
|
|
21
|
+
<Typography display="inline">Creating SVG</Typography>
|
|
22
|
+
</div>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function useSvgLocal<T>(key: string, val: T) {
|
|
27
|
+
return useLocalStorage('svg-' + key, val)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function ExportSvgDlg({
|
|
31
|
+
model,
|
|
32
|
+
handleClose,
|
|
33
|
+
}: {
|
|
34
|
+
model: { exportSvg(opts: ExportSvgOptions): Promise<void> }
|
|
35
|
+
handleClose: () => void
|
|
36
|
+
}) {
|
|
37
|
+
const session = getSession(model)
|
|
38
|
+
const offscreenCanvas = typeof OffscreenCanvas !== 'undefined'
|
|
39
|
+
const [rasterizeLayers, setRasterizeLayers] = useState(offscreenCanvas)
|
|
40
|
+
const [loading, setLoading] = useState(false)
|
|
41
|
+
const [error, setError] = useState<unknown>()
|
|
42
|
+
const [filename, setFilename] = useSvgLocal('file', 'jbrowse.svg')
|
|
43
|
+
const [themeName, setThemeName] = useSvgLocal(
|
|
44
|
+
'theme',
|
|
45
|
+
session.themeName || 'default',
|
|
46
|
+
)
|
|
47
|
+
return (
|
|
48
|
+
<Dialog open onClose={handleClose} title="Export SVG">
|
|
49
|
+
<DialogContent>
|
|
50
|
+
{error ? (
|
|
51
|
+
<ErrorMessage error={error} />
|
|
52
|
+
) : loading ? (
|
|
53
|
+
<LoadingMessage />
|
|
54
|
+
) : null}
|
|
55
|
+
<TextField
|
|
56
|
+
helperText="filename"
|
|
57
|
+
value={filename}
|
|
58
|
+
onChange={event => setFilename(event.target.value)}
|
|
59
|
+
/>
|
|
60
|
+
<br />
|
|
61
|
+
{session.allThemes ? (
|
|
62
|
+
<TextField
|
|
63
|
+
select
|
|
64
|
+
label="Theme"
|
|
65
|
+
value={themeName}
|
|
66
|
+
onChange={event => setThemeName(event.target.value)}
|
|
67
|
+
>
|
|
68
|
+
{Object.entries(session.allThemes()).map(([key, val]) => (
|
|
69
|
+
<MenuItem key={key} value={key}>
|
|
70
|
+
{
|
|
71
|
+
// @ts-expect-error
|
|
72
|
+
val.name || '(Unknown name)'
|
|
73
|
+
}
|
|
74
|
+
</MenuItem>
|
|
75
|
+
))}
|
|
76
|
+
</TextField>
|
|
77
|
+
) : null}
|
|
78
|
+
{offscreenCanvas ? (
|
|
79
|
+
<FormControlLabel
|
|
80
|
+
control={
|
|
81
|
+
<Checkbox
|
|
82
|
+
checked={rasterizeLayers}
|
|
83
|
+
onChange={() => setRasterizeLayers(val => !val)}
|
|
84
|
+
/>
|
|
85
|
+
}
|
|
86
|
+
label="Rasterize canvas based tracks? File may be much larger if this is turned off"
|
|
87
|
+
/>
|
|
88
|
+
) : (
|
|
89
|
+
<Typography>
|
|
90
|
+
Note: rasterizing layers not yet supported in this browser, so SVG
|
|
91
|
+
size may be large
|
|
92
|
+
</Typography>
|
|
93
|
+
)}
|
|
94
|
+
</DialogContent>
|
|
95
|
+
<DialogActions>
|
|
96
|
+
<Button
|
|
97
|
+
variant="contained"
|
|
98
|
+
color="secondary"
|
|
99
|
+
onClick={() => handleClose()}
|
|
100
|
+
>
|
|
101
|
+
Cancel
|
|
102
|
+
</Button>
|
|
103
|
+
<Button
|
|
104
|
+
variant="contained"
|
|
105
|
+
color="primary"
|
|
106
|
+
type="submit"
|
|
107
|
+
onClick={async () => {
|
|
108
|
+
setLoading(true)
|
|
109
|
+
setError(undefined)
|
|
110
|
+
try {
|
|
111
|
+
await model.exportSvg({
|
|
112
|
+
rasterizeLayers,
|
|
113
|
+
filename,
|
|
114
|
+
themeName,
|
|
115
|
+
})
|
|
116
|
+
handleClose()
|
|
117
|
+
} catch (e) {
|
|
118
|
+
console.error(e)
|
|
119
|
+
setError(e)
|
|
120
|
+
setLoading(false)
|
|
121
|
+
}
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
Submit
|
|
125
|
+
</Button>
|
|
126
|
+
</DialogActions>
|
|
127
|
+
</Dialog>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { observer } from 'mobx-react'
|
|
3
|
+
import { useTheme } from '@mui/material'
|
|
4
|
+
|
|
5
|
+
// locals
|
|
6
|
+
import { DotplotViewModel } from '../model'
|
|
7
|
+
|
|
8
|
+
export const GridRaw = observer(function ({
|
|
9
|
+
model,
|
|
10
|
+
children,
|
|
11
|
+
}: {
|
|
12
|
+
model: DotplotViewModel
|
|
13
|
+
children?: React.ReactNode
|
|
14
|
+
}) {
|
|
15
|
+
const { viewWidth, viewHeight, hview, vview } = model
|
|
16
|
+
const hblocks = hview.dynamicBlocks.contentBlocks
|
|
17
|
+
const vblocks = vview.dynamicBlocks.contentBlocks
|
|
18
|
+
if (!hblocks.length || !vblocks.length) {
|
|
19
|
+
return null
|
|
20
|
+
}
|
|
21
|
+
const htop = hview.displayedRegionsTotalPx - hview.offsetPx
|
|
22
|
+
const vtop = vview.displayedRegionsTotalPx - vview.offsetPx
|
|
23
|
+
const hbottom = hblocks[0].offsetPx - hview.offsetPx
|
|
24
|
+
const vbottom = vblocks[0].offsetPx - vview.offsetPx
|
|
25
|
+
const theme = useTheme()
|
|
26
|
+
const stroke = theme.palette.divider
|
|
27
|
+
|
|
28
|
+
// Uses math.max/min avoid making very large SVG rect offscreen element,
|
|
29
|
+
// which can sometimes fail to draw
|
|
30
|
+
const rx = Math.max(hbottom, 0)
|
|
31
|
+
const ry = Math.max(viewHeight - vtop, 0)
|
|
32
|
+
const w = Math.min(htop - hbottom, viewWidth)
|
|
33
|
+
const h = Math.min(viewHeight - vbottom - ry, viewHeight)
|
|
34
|
+
|
|
35
|
+
let lastx = Infinity
|
|
36
|
+
let lasty = Infinity
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<rect
|
|
40
|
+
x={rx}
|
|
41
|
+
y={ry}
|
|
42
|
+
width={w}
|
|
43
|
+
height={h}
|
|
44
|
+
fill={theme.palette.background.default}
|
|
45
|
+
/>
|
|
46
|
+
<g>
|
|
47
|
+
{hblocks.map(region => {
|
|
48
|
+
const x = region.offsetPx - hview.offsetPx
|
|
49
|
+
const render = Math.floor(x) !== Math.floor(lastx)
|
|
50
|
+
if (render) {
|
|
51
|
+
lastx = x
|
|
52
|
+
}
|
|
53
|
+
return render ? (
|
|
54
|
+
<line
|
|
55
|
+
key={JSON.stringify(region)}
|
|
56
|
+
x1={x}
|
|
57
|
+
y1={0}
|
|
58
|
+
x2={x}
|
|
59
|
+
y2={viewHeight}
|
|
60
|
+
stroke={stroke}
|
|
61
|
+
/>
|
|
62
|
+
) : null
|
|
63
|
+
})}
|
|
64
|
+
{vblocks.map(region => {
|
|
65
|
+
const y = viewHeight - (region.offsetPx - vview.offsetPx)
|
|
66
|
+
const render = Math.floor(y) !== Math.floor(lasty)
|
|
67
|
+
if (render) {
|
|
68
|
+
lasty = y
|
|
69
|
+
}
|
|
70
|
+
return render ? (
|
|
71
|
+
<line
|
|
72
|
+
key={JSON.stringify(region)}
|
|
73
|
+
x1={0}
|
|
74
|
+
y1={y}
|
|
75
|
+
x2={viewWidth}
|
|
76
|
+
y2={y}
|
|
77
|
+
stroke={stroke}
|
|
78
|
+
/>
|
|
79
|
+
) : null
|
|
80
|
+
})}
|
|
81
|
+
<line x1={htop} y1={0} x2={htop} y2={viewHeight} stroke={stroke} />
|
|
82
|
+
<line
|
|
83
|
+
x1={0}
|
|
84
|
+
y1={viewHeight - vtop}
|
|
85
|
+
x2={viewWidth}
|
|
86
|
+
y2={viewHeight - vtop}
|
|
87
|
+
stroke={stroke}
|
|
88
|
+
/>
|
|
89
|
+
</g>
|
|
90
|
+
{children}
|
|
91
|
+
</>
|
|
92
|
+
)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
export default function Grid({
|
|
96
|
+
model,
|
|
97
|
+
children,
|
|
98
|
+
}: {
|
|
99
|
+
model: DotplotViewModel
|
|
100
|
+
children?: React.ReactNode
|
|
101
|
+
}) {
|
|
102
|
+
const { viewWidth, viewHeight } = model
|
|
103
|
+
return (
|
|
104
|
+
<svg
|
|
105
|
+
width={viewWidth}
|
|
106
|
+
height={viewHeight}
|
|
107
|
+
style={{ background: 'rgba(0,0,0,0.12)' }}
|
|
108
|
+
>
|
|
109
|
+
<GridRaw model={model}>{children}</GridRaw>
|
|
110
|
+
</svg>
|
|
111
|
+
)
|
|
112
|
+
}
|