@jbrowse/plugin-circular-view 2.3.3 → 2.4.0
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/dist/BaseChordDisplay/components/Loading.js.map +1 -1
- package/dist/BaseChordDisplay/index.d.ts +2 -2
- package/dist/BaseChordDisplay/index.js +4 -4
- package/dist/BaseChordDisplay/index.js.map +1 -1
- package/dist/BaseChordDisplay/models/{baseChordDisplayConfig.js → configSchema.js} +1 -1
- package/dist/BaseChordDisplay/models/configSchema.js.map +1 -0
- package/dist/BaseChordDisplay/models/{BaseChordDisplayModel.d.ts → model.d.ts} +12 -0
- package/dist/BaseChordDisplay/models/{BaseChordDisplayModel.js → model.js} +32 -22
- package/dist/BaseChordDisplay/models/model.js.map +1 -0
- package/dist/BaseChordDisplay/models/renderReaction.d.ts +1 -1
- package/dist/BaseChordDisplay/models/renderReaction.js +4 -5
- package/dist/BaseChordDisplay/models/renderReaction.js.map +1 -1
- package/dist/CircularView/components/CircularView.js +8 -17
- package/dist/CircularView/components/CircularView.js.map +1 -1
- package/dist/CircularView/components/Controls.d.ts +2 -2
- package/dist/CircularView/components/Controls.js +60 -24
- package/dist/CircularView/components/Controls.js.map +1 -1
- package/dist/CircularView/components/ExportSvgDialog.d.ts +8 -0
- package/dist/CircularView/components/ExportSvgDialog.js +76 -0
- package/dist/CircularView/components/ExportSvgDialog.js.map +1 -0
- package/dist/CircularView/components/Ruler.d.ts +2 -2
- package/dist/CircularView/components/Ruler.js +10 -14
- package/dist/CircularView/components/Ruler.js.map +1 -1
- package/dist/CircularView/models/CircularView.d.ts +30 -26
- package/dist/CircularView/models/CircularView.js +61 -17
- package/dist/CircularView/models/CircularView.js.map +1 -1
- package/dist/CircularView/models/slices.d.ts +23 -10
- package/dist/CircularView/models/slices.js +10 -7
- package/dist/CircularView/models/slices.js.map +1 -1
- package/dist/CircularView/svgcomponents/SVGBackground.d.ts +6 -0
- package/dist/CircularView/svgcomponents/SVGBackground.js +13 -0
- package/dist/CircularView/svgcomponents/SVGBackground.js.map +1 -0
- package/dist/CircularView/svgcomponents/SVGCircularView.d.ts +4 -0
- package/dist/CircularView/svgcomponents/SVGCircularView.js +40 -0
- package/dist/CircularView/svgcomponents/SVGCircularView.js.map +1 -0
- package/esm/BaseChordDisplay/components/Loading.js.map +1 -1
- package/esm/BaseChordDisplay/index.d.ts +2 -2
- package/esm/BaseChordDisplay/index.js +2 -2
- package/esm/BaseChordDisplay/index.js.map +1 -1
- package/esm/BaseChordDisplay/models/{baseChordDisplayConfig.js → configSchema.js} +1 -1
- package/esm/BaseChordDisplay/models/configSchema.js.map +1 -0
- package/esm/BaseChordDisplay/models/{BaseChordDisplayModel.d.ts → model.d.ts} +12 -0
- package/esm/BaseChordDisplay/models/{BaseChordDisplayModel.js → model.js} +33 -23
- package/esm/BaseChordDisplay/models/model.js.map +1 -0
- package/esm/BaseChordDisplay/models/renderReaction.d.ts +1 -1
- package/esm/BaseChordDisplay/models/renderReaction.js +4 -5
- package/esm/BaseChordDisplay/models/renderReaction.js.map +1 -1
- package/esm/CircularView/components/CircularView.js +8 -17
- package/esm/CircularView/components/CircularView.js.map +1 -1
- package/esm/CircularView/components/Controls.d.ts +2 -2
- package/esm/CircularView/components/Controls.js +37 -24
- package/esm/CircularView/components/Controls.js.map +1 -1
- package/esm/CircularView/components/ExportSvgDialog.d.ts +8 -0
- package/esm/CircularView/components/ExportSvgDialog.js +50 -0
- package/esm/CircularView/components/ExportSvgDialog.js.map +1 -0
- package/esm/CircularView/components/Ruler.d.ts +2 -2
- package/esm/CircularView/components/Ruler.js +10 -14
- package/esm/CircularView/components/Ruler.js.map +1 -1
- package/esm/CircularView/models/CircularView.d.ts +30 -26
- package/esm/CircularView/models/CircularView.js +58 -17
- package/esm/CircularView/models/CircularView.js.map +1 -1
- package/esm/CircularView/models/slices.d.ts +23 -10
- package/esm/CircularView/models/slices.js +10 -7
- package/esm/CircularView/models/slices.js.map +1 -1
- package/esm/CircularView/svgcomponents/SVGBackground.d.ts +6 -0
- package/esm/CircularView/svgcomponents/SVGBackground.js +7 -0
- package/esm/CircularView/svgcomponents/SVGBackground.js.map +1 -0
- package/esm/CircularView/svgcomponents/SVGCircularView.d.ts +4 -0
- package/esm/CircularView/svgcomponents/SVGCircularView.js +33 -0
- package/esm/CircularView/svgcomponents/SVGCircularView.js.map +1 -0
- package/package.json +5 -3
- package/src/BaseChordDisplay/components/Loading.tsx +1 -0
- package/src/BaseChordDisplay/index.ts +2 -2
- package/src/BaseChordDisplay/models/{BaseChordDisplayModel.ts → model.tsx} +46 -24
- package/src/BaseChordDisplay/models/renderReaction.ts +4 -7
- package/src/CircularView/components/CircularView.tsx +11 -25
- package/src/CircularView/components/Controls.tsx +41 -28
- package/src/CircularView/components/ExportSvgDialog.tsx +132 -0
- package/src/CircularView/components/Ruler.tsx +193 -182
- package/src/CircularView/models/CircularView.ts +78 -40
- package/src/CircularView/models/slices.ts +32 -12
- package/src/CircularView/svgcomponents/SVGBackground.tsx +21 -0
- package/src/CircularView/svgcomponents/SVGCircularView.tsx +58 -0
- package/dist/BaseChordDisplay/models/BaseChordDisplayModel.js.map +0 -1
- package/dist/BaseChordDisplay/models/baseChordDisplayConfig.js.map +0 -1
- package/esm/BaseChordDisplay/models/BaseChordDisplayModel.js.map +0 -1
- package/esm/BaseChordDisplay/models/baseChordDisplayConfig.js.map +0 -1
- /package/dist/BaseChordDisplay/models/{baseChordDisplayConfig.d.ts → configSchema.d.ts} +0 -0
- /package/esm/BaseChordDisplay/models/{baseChordDisplayConfig.d.ts → configSchema.d.ts} +0 -0
- /package/src/BaseChordDisplay/models/{baseChordDisplayConfig.ts → configSchema.ts} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
2
|
import { observer } from 'mobx-react'
|
|
3
3
|
import { IconButton } from '@mui/material'
|
|
4
4
|
import { makeStyles } from 'tss-react/mui'
|
|
5
|
-
import
|
|
5
|
+
import JBrowseMenu from '@jbrowse/core/ui/Menu'
|
|
6
6
|
|
|
7
7
|
// icons
|
|
8
8
|
import ZoomOutIcon from '@mui/icons-material/ZoomOut'
|
|
@@ -11,96 +11,109 @@ import RotateLeftIcon from '@mui/icons-material/RotateLeft'
|
|
|
11
11
|
import RotateRightIcon from '@mui/icons-material/RotateRight'
|
|
12
12
|
import LockOpenIcon from '@mui/icons-material/LockOpen'
|
|
13
13
|
import LockIcon from '@mui/icons-material/Lock'
|
|
14
|
+
import PhotoCamera from '@mui/icons-material/PhotoCamera'
|
|
15
|
+
import MoreVert from '@mui/icons-material/MoreVert'
|
|
14
16
|
import { TrackSelector as TrackSelectorIcon } from '@jbrowse/core/ui/Icons'
|
|
15
17
|
|
|
16
18
|
// locals
|
|
17
19
|
import { CircularViewModel } from '../models/CircularView'
|
|
20
|
+
import { getSession } from '@jbrowse/core/util'
|
|
21
|
+
import ExportSvgDlg from './ExportSvgDialog'
|
|
18
22
|
|
|
19
|
-
const useStyles = makeStyles()({
|
|
20
|
-
iconButton: {
|
|
21
|
-
padding: '4px',
|
|
22
|
-
margin: '0 2px 0 2px',
|
|
23
|
-
},
|
|
23
|
+
const useStyles = makeStyles()(theme => ({
|
|
24
24
|
controls: {
|
|
25
|
-
overflow: 'hidden',
|
|
26
|
-
whiteSpace: 'nowrap',
|
|
27
25
|
position: 'absolute',
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
borderRight: '1px solid #a2a2a2',
|
|
31
|
-
borderBottom: '1px solid #a2a2a2',
|
|
26
|
+
borderRight: `1px solid ${theme.palette.divider}`,
|
|
27
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
32
28
|
left: 0,
|
|
33
29
|
top: 0,
|
|
34
30
|
},
|
|
35
|
-
})
|
|
31
|
+
}))
|
|
36
32
|
|
|
37
|
-
|
|
33
|
+
export default observer(function ({ model }: { model: CircularViewModel }) {
|
|
38
34
|
const { classes } = useStyles()
|
|
35
|
+
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)
|
|
39
36
|
return (
|
|
40
37
|
<div className={classes.controls}>
|
|
41
38
|
<IconButton
|
|
42
39
|
onClick={model.zoomOutButton}
|
|
43
|
-
className={classes.iconButton}
|
|
44
40
|
title={model.lockedFitToWindow ? 'unlock to zoom out' : 'zoom out'}
|
|
45
41
|
disabled={model.atMaxBpPerPx || model.lockedFitToWindow}
|
|
46
|
-
color="secondary"
|
|
47
42
|
>
|
|
48
43
|
<ZoomOutIcon />
|
|
49
44
|
</IconButton>
|
|
50
45
|
|
|
51
46
|
<IconButton
|
|
52
47
|
onClick={model.zoomInButton}
|
|
53
|
-
className={classes.iconButton}
|
|
54
|
-
title="zoom in"
|
|
55
48
|
disabled={model.atMinBpPerPx}
|
|
56
|
-
|
|
49
|
+
title="zoom in"
|
|
57
50
|
>
|
|
58
51
|
<ZoomInIcon />
|
|
59
52
|
</IconButton>
|
|
60
53
|
|
|
61
54
|
<IconButton
|
|
62
55
|
onClick={model.rotateCounterClockwiseButton}
|
|
63
|
-
className={classes.iconButton}
|
|
64
56
|
title="rotate counter-clockwise"
|
|
65
|
-
color="secondary"
|
|
66
57
|
>
|
|
67
58
|
<RotateLeftIcon />
|
|
68
59
|
</IconButton>
|
|
69
60
|
|
|
70
61
|
<IconButton
|
|
71
62
|
onClick={model.rotateClockwiseButton}
|
|
72
|
-
className={classes.iconButton}
|
|
73
63
|
title="rotate clockwise"
|
|
74
|
-
color="secondary"
|
|
75
64
|
>
|
|
76
65
|
<RotateRightIcon />
|
|
77
66
|
</IconButton>
|
|
78
67
|
|
|
79
68
|
<IconButton
|
|
80
69
|
onClick={model.toggleFitToWindowLock}
|
|
81
|
-
className={classes.iconButton}
|
|
82
70
|
title={
|
|
83
71
|
model.lockedFitToWindow
|
|
84
72
|
? 'locked model to window size'
|
|
85
73
|
: 'unlocked model to zoom further'
|
|
86
74
|
}
|
|
87
75
|
disabled={model.tooSmallToLock}
|
|
88
|
-
color="secondary"
|
|
89
76
|
>
|
|
90
77
|
{model.lockedFitToWindow ? <LockIcon /> : <LockOpenIcon />}
|
|
91
78
|
</IconButton>
|
|
92
79
|
|
|
80
|
+
<IconButton onClick={event => setAnchorEl(event.currentTarget)}>
|
|
81
|
+
<MoreVert />
|
|
82
|
+
</IconButton>
|
|
83
|
+
|
|
93
84
|
{model.hideTrackSelectorButton ? null : (
|
|
94
85
|
<IconButton
|
|
95
86
|
onClick={model.activateTrackSelector}
|
|
96
87
|
title="Open track selector"
|
|
97
88
|
data-testid="circular_track_select"
|
|
98
|
-
color="secondary"
|
|
99
89
|
>
|
|
100
90
|
<TrackSelectorIcon />
|
|
101
91
|
</IconButton>
|
|
102
92
|
)}
|
|
93
|
+
|
|
94
|
+
{anchorEl ? (
|
|
95
|
+
<JBrowseMenu
|
|
96
|
+
anchorEl={anchorEl}
|
|
97
|
+
menuItems={[
|
|
98
|
+
{
|
|
99
|
+
label: 'Export SVG',
|
|
100
|
+
icon: PhotoCamera,
|
|
101
|
+
onClick: () => {
|
|
102
|
+
getSession(model).queueDialog(handleClose => [
|
|
103
|
+
ExportSvgDlg,
|
|
104
|
+
{ model, handleClose },
|
|
105
|
+
])
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
]}
|
|
109
|
+
onMenuItemClick={(_event, callback) => {
|
|
110
|
+
callback()
|
|
111
|
+
setAnchorEl(null)
|
|
112
|
+
}}
|
|
113
|
+
open={Boolean(anchorEl)}
|
|
114
|
+
onClose={() => setAnchorEl(null)}
|
|
115
|
+
/>
|
|
116
|
+
) : null}
|
|
103
117
|
</div>
|
|
104
118
|
)
|
|
105
119
|
})
|
|
106
|
-
export default Controls
|
|
@@ -0,0 +1,132 @@
|
|
|
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
|
+
|
|
15
|
+
// locals
|
|
16
|
+
import { ExportSvgOptions } from '../models/CircularView'
|
|
17
|
+
import { getSession, useLocalStorage } from '@jbrowse/core/util'
|
|
18
|
+
|
|
19
|
+
function LoadingMessage() {
|
|
20
|
+
return (
|
|
21
|
+
<div>
|
|
22
|
+
<CircularProgress size={20} style={{ marginRight: 20 }} />
|
|
23
|
+
<Typography display="inline">Creating SVG</Typography>
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function useSvgLocal<T>(key: string, val: T) {
|
|
29
|
+
return useLocalStorage('svg-' + key, val)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default function ExportSvgDlg({
|
|
33
|
+
model,
|
|
34
|
+
handleClose,
|
|
35
|
+
}: {
|
|
36
|
+
model: { exportSvg(opts: ExportSvgOptions): Promise<void> }
|
|
37
|
+
handleClose: () => void
|
|
38
|
+
}) {
|
|
39
|
+
const session = getSession(model)
|
|
40
|
+
const offscreenCanvas = typeof OffscreenCanvas !== 'undefined'
|
|
41
|
+
const [rasterizeLayers, setRasterizeLayers] = useState(offscreenCanvas)
|
|
42
|
+
const [loading, setLoading] = useState(false)
|
|
43
|
+
const [error, setError] = useState<unknown>()
|
|
44
|
+
const [filename, setFilename] = useSvgLocal('file', 'jbrowse.svg')
|
|
45
|
+
const [themeName, setThemeName] = useSvgLocal(
|
|
46
|
+
'theme',
|
|
47
|
+
session.themeName || 'default',
|
|
48
|
+
)
|
|
49
|
+
return (
|
|
50
|
+
<Dialog open onClose={handleClose} title="Export SVG">
|
|
51
|
+
<DialogContent>
|
|
52
|
+
{error ? (
|
|
53
|
+
<ErrorMessage error={error} />
|
|
54
|
+
) : loading ? (
|
|
55
|
+
<LoadingMessage />
|
|
56
|
+
) : null}
|
|
57
|
+
<TextField
|
|
58
|
+
helperText="filename"
|
|
59
|
+
value={filename}
|
|
60
|
+
onChange={event => setFilename(event.target.value)}
|
|
61
|
+
/>
|
|
62
|
+
<br />
|
|
63
|
+
|
|
64
|
+
{session.allThemes ? (
|
|
65
|
+
<TextField
|
|
66
|
+
select
|
|
67
|
+
label="Theme"
|
|
68
|
+
value={themeName}
|
|
69
|
+
onChange={event => setThemeName(event.target.value)}
|
|
70
|
+
>
|
|
71
|
+
{Object.entries(session.allThemes()).map(([key, val]) => (
|
|
72
|
+
<MenuItem key={key} value={key}>
|
|
73
|
+
{
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
val.name || '(Unknown name)'
|
|
76
|
+
}
|
|
77
|
+
</MenuItem>
|
|
78
|
+
))}
|
|
79
|
+
</TextField>
|
|
80
|
+
) : null}
|
|
81
|
+
{offscreenCanvas ? (
|
|
82
|
+
<FormControlLabel
|
|
83
|
+
control={
|
|
84
|
+
<Checkbox
|
|
85
|
+
checked={rasterizeLayers}
|
|
86
|
+
onChange={() => setRasterizeLayers(val => !val)}
|
|
87
|
+
/>
|
|
88
|
+
}
|
|
89
|
+
label="Rasterize canvas based tracks? File may be much larger if this is turned off"
|
|
90
|
+
/>
|
|
91
|
+
) : (
|
|
92
|
+
<Typography>
|
|
93
|
+
Note: rasterizing layers not yet supported in this browser, so SVG
|
|
94
|
+
size may be large
|
|
95
|
+
</Typography>
|
|
96
|
+
)}
|
|
97
|
+
</DialogContent>
|
|
98
|
+
<DialogActions>
|
|
99
|
+
<Button
|
|
100
|
+
variant="contained"
|
|
101
|
+
color="secondary"
|
|
102
|
+
onClick={() => handleClose()}
|
|
103
|
+
>
|
|
104
|
+
Cancel
|
|
105
|
+
</Button>
|
|
106
|
+
<Button
|
|
107
|
+
variant="contained"
|
|
108
|
+
color="primary"
|
|
109
|
+
type="submit"
|
|
110
|
+
onClick={async () => {
|
|
111
|
+
setLoading(true)
|
|
112
|
+
setError(undefined)
|
|
113
|
+
try {
|
|
114
|
+
await model.exportSvg({
|
|
115
|
+
rasterizeLayers,
|
|
116
|
+
filename,
|
|
117
|
+
themeName,
|
|
118
|
+
})
|
|
119
|
+
handleClose()
|
|
120
|
+
} catch (e) {
|
|
121
|
+
console.error(e)
|
|
122
|
+
setError(e)
|
|
123
|
+
setLoading(false)
|
|
124
|
+
}
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
Submit
|
|
128
|
+
</Button>
|
|
129
|
+
</DialogActions>
|
|
130
|
+
</Dialog>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
@@ -11,7 +11,11 @@ import { useTheme } from '@mui/material/styles'
|
|
|
11
11
|
import { makeStyles } from 'tss-react/mui'
|
|
12
12
|
|
|
13
13
|
// locals
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
Slice,
|
|
16
|
+
SliceElidedRegion,
|
|
17
|
+
SliceNonElidedRegion,
|
|
18
|
+
} from '../models/slices'
|
|
15
19
|
import { CircularViewModel } from '../models/CircularView'
|
|
16
20
|
|
|
17
21
|
const useStyles = makeStyles()({
|
|
@@ -51,128 +55,116 @@ function sliceArcPath(
|
|
|
51
55
|
].join(' ')
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
const ElisionRulerArc = observer(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
58
|
+
const ElisionRulerArc = observer(function ({
|
|
59
|
+
model,
|
|
60
|
+
slice,
|
|
61
|
+
region,
|
|
62
|
+
}: {
|
|
63
|
+
model: CircularViewModel
|
|
64
|
+
slice: Slice
|
|
65
|
+
region: SliceElidedRegion
|
|
66
|
+
}) {
|
|
67
|
+
const theme = useTheme()
|
|
68
|
+
const { radiusPx: modelRadiusPx } = model
|
|
69
|
+
const radiusPx = modelRadiusPx + 1
|
|
70
|
+
const { endRadians, startRadians } = slice
|
|
71
|
+
const startXY = polarToCartesian(radiusPx, startRadians)
|
|
72
|
+
const endXY = polarToCartesian(radiusPx, endRadians)
|
|
73
|
+
const widthPx = (endRadians - startRadians) * radiusPx
|
|
74
|
+
const largeArc = endRadians - startRadians > Math.PI ? '1' : '0'
|
|
75
|
+
// TODO: draw the elision
|
|
76
|
+
const centerRadians = (endRadians + startRadians) / 2
|
|
77
|
+
const regionCountString = `[${Number(
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
region.regions.length,
|
|
80
|
+
).toLocaleString()}]`
|
|
81
|
+
return (
|
|
82
|
+
<>
|
|
83
|
+
<RulerLabel
|
|
84
|
+
text={regionCountString}
|
|
85
|
+
view={model}
|
|
86
|
+
maxWidthPx={widthPx}
|
|
87
|
+
radians={centerRadians}
|
|
88
|
+
radiusPx={radiusPx}
|
|
89
|
+
title={`${Number(
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
region.regions.length,
|
|
92
|
+
).toLocaleString()} more regions`}
|
|
93
|
+
color={theme.palette.text.primary}
|
|
94
|
+
/>
|
|
95
|
+
<path
|
|
96
|
+
d={[
|
|
97
|
+
'M',
|
|
98
|
+
...startXY,
|
|
99
|
+
'A',
|
|
100
|
+
radiusPx,
|
|
101
|
+
radiusPx,
|
|
102
|
+
'0',
|
|
103
|
+
largeArc,
|
|
104
|
+
'1',
|
|
105
|
+
...endXY,
|
|
106
|
+
].join(' ')}
|
|
107
|
+
stroke={theme.palette.text.secondary}
|
|
108
|
+
strokeWidth={2}
|
|
109
|
+
strokeDasharray="2,2"
|
|
110
|
+
fill="none"
|
|
111
|
+
/>
|
|
112
|
+
</>
|
|
113
|
+
)
|
|
114
|
+
})
|
|
105
115
|
|
|
106
|
-
const RulerLabel = observer(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
116
|
+
const RulerLabel = observer(function ({
|
|
117
|
+
view,
|
|
118
|
+
text,
|
|
119
|
+
maxWidthPx,
|
|
120
|
+
radians,
|
|
121
|
+
radiusPx,
|
|
122
|
+
title,
|
|
123
|
+
color,
|
|
124
|
+
}: {
|
|
125
|
+
view: CircularViewModel
|
|
126
|
+
text: string
|
|
127
|
+
maxWidthPx: number
|
|
128
|
+
radiusPx: number
|
|
129
|
+
radians: number
|
|
130
|
+
title?: string
|
|
131
|
+
color: string
|
|
132
|
+
}) {
|
|
133
|
+
const { classes } = useStyles()
|
|
134
|
+
const textXY = polarToCartesian(radiusPx + 5, radians)
|
|
135
|
+
if (!text) {
|
|
136
|
+
return null
|
|
137
|
+
}
|
|
129
138
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
)
|
|
152
|
-
if (overallRotation >= 180) {
|
|
153
|
-
return (
|
|
154
|
-
<text
|
|
155
|
-
x={0}
|
|
156
|
-
y={0}
|
|
157
|
-
className={classes.rulerLabel}
|
|
158
|
-
textAnchor="start"
|
|
159
|
-
dominantBaseline="middle"
|
|
160
|
-
transform={`translate(${textXY}) rotate(${radToDeg(radians)})`}
|
|
161
|
-
style={{ fill: color }}
|
|
162
|
-
>
|
|
163
|
-
{text}
|
|
164
|
-
<title>{title || text}</title>
|
|
165
|
-
</text>
|
|
166
|
-
)
|
|
167
|
-
}
|
|
139
|
+
if (text.length * 6.5 < maxWidthPx) {
|
|
140
|
+
// text is rotated parallel to the ruler arc
|
|
141
|
+
return (
|
|
142
|
+
<text
|
|
143
|
+
x={0}
|
|
144
|
+
y={0}
|
|
145
|
+
className={classes.rulerLabel}
|
|
146
|
+
textAnchor="middle"
|
|
147
|
+
dominantBaseline="baseline"
|
|
148
|
+
transform={`translate(${textXY}) rotate(${radToDeg(radians) + 90})`}
|
|
149
|
+
style={{ fill: color }}
|
|
150
|
+
>
|
|
151
|
+
{text}
|
|
152
|
+
<title>{title || text}</title>
|
|
153
|
+
</text>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
if (maxWidthPx > 4) {
|
|
157
|
+
// text is rotated perpendicular to the ruler arc
|
|
158
|
+
const overallRotation = radToDeg(radians + view.offsetRadians - Math.PI / 2)
|
|
159
|
+
if (overallRotation >= 180) {
|
|
168
160
|
return (
|
|
169
161
|
<text
|
|
170
162
|
x={0}
|
|
171
163
|
y={0}
|
|
172
164
|
className={classes.rulerLabel}
|
|
173
|
-
textAnchor="
|
|
165
|
+
textAnchor="start"
|
|
174
166
|
dominantBaseline="middle"
|
|
175
|
-
transform={`translate(${textXY}) rotate(${radToDeg(radians)
|
|
167
|
+
transform={`translate(${textXY}) rotate(${radToDeg(radians)})`}
|
|
176
168
|
style={{ fill: color }}
|
|
177
169
|
>
|
|
178
170
|
{text}
|
|
@@ -180,81 +172,100 @@ const RulerLabel = observer(
|
|
|
180
172
|
</text>
|
|
181
173
|
)
|
|
182
174
|
}
|
|
175
|
+
return (
|
|
176
|
+
<text
|
|
177
|
+
x={0}
|
|
178
|
+
y={0}
|
|
179
|
+
className={classes.rulerLabel}
|
|
180
|
+
textAnchor="end"
|
|
181
|
+
dominantBaseline="middle"
|
|
182
|
+
transform={`translate(${textXY}) rotate(${radToDeg(radians) + 180})`}
|
|
183
|
+
style={{ fill: color }}
|
|
184
|
+
>
|
|
185
|
+
{text}
|
|
186
|
+
<title>{title || text}</title>
|
|
187
|
+
</text>
|
|
188
|
+
)
|
|
189
|
+
}
|
|
183
190
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
)
|
|
191
|
+
// if you get here there is no room for the text at all
|
|
192
|
+
return null
|
|
193
|
+
})
|
|
188
194
|
|
|
189
|
-
const RegionRulerArc = observer(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
195
|
+
const RegionRulerArc = observer(function ({
|
|
196
|
+
model,
|
|
197
|
+
slice,
|
|
198
|
+
region,
|
|
199
|
+
}: {
|
|
200
|
+
model: CircularViewModel
|
|
201
|
+
slice: Slice
|
|
202
|
+
region: SliceNonElidedRegion
|
|
203
|
+
}) {
|
|
204
|
+
const theme = useTheme()
|
|
205
|
+
const { radiusPx } = model
|
|
206
|
+
const { endRadians, startRadians } = slice
|
|
207
|
+
const centerRadians = (endRadians + startRadians) / 2
|
|
208
|
+
const widthPx = (endRadians - startRadians) * radiusPx
|
|
209
|
+
const session = getSession(model)
|
|
210
|
+
let color
|
|
211
|
+
const assembly = session.assemblyManager.get(region.assemblyName)
|
|
212
|
+
if (assembly) {
|
|
213
|
+
color = assembly.getRefNameColor(region.refName)
|
|
214
|
+
}
|
|
215
|
+
if (color) {
|
|
216
|
+
try {
|
|
217
|
+
color = makeContrasting(color, theme.palette.background.paper)
|
|
218
|
+
} catch (error) {
|
|
209
219
|
color = theme.palette.text.primary
|
|
210
220
|
}
|
|
221
|
+
} else {
|
|
222
|
+
color = theme.palette.text.primary
|
|
223
|
+
}
|
|
211
224
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
)
|
|
233
|
-
},
|
|
234
|
-
)
|
|
225
|
+
// TODO: slice flipping
|
|
226
|
+
return (
|
|
227
|
+
<>
|
|
228
|
+
<RulerLabel
|
|
229
|
+
text={region.refName}
|
|
230
|
+
view={model}
|
|
231
|
+
maxWidthPx={widthPx}
|
|
232
|
+
radians={centerRadians}
|
|
233
|
+
radiusPx={radiusPx}
|
|
234
|
+
color={color}
|
|
235
|
+
/>
|
|
236
|
+
<path
|
|
237
|
+
d={sliceArcPath(slice, radiusPx + 1, region.start, region.end)}
|
|
238
|
+
stroke={color}
|
|
239
|
+
strokeWidth={2}
|
|
240
|
+
fill="none"
|
|
241
|
+
/>
|
|
242
|
+
</>
|
|
243
|
+
)
|
|
244
|
+
})
|
|
235
245
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
model={model}
|
|
246
|
-
slice={slice}
|
|
247
|
-
/>
|
|
248
|
-
)
|
|
249
|
-
}
|
|
246
|
+
export default observer(function ({
|
|
247
|
+
model,
|
|
248
|
+
slice,
|
|
249
|
+
}: {
|
|
250
|
+
model: CircularViewModel
|
|
251
|
+
slice: Slice
|
|
252
|
+
}) {
|
|
253
|
+
if (slice.region.elided) {
|
|
250
254
|
return (
|
|
251
|
-
<
|
|
252
|
-
key={assembleLocString(slice.region)}
|
|
255
|
+
<ElisionRulerArc
|
|
256
|
+
key={assembleLocString(slice.region.regions[0])}
|
|
253
257
|
model={model}
|
|
258
|
+
region={slice.region}
|
|
254
259
|
slice={slice}
|
|
255
260
|
/>
|
|
256
261
|
)
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
262
|
+
}
|
|
263
|
+
return (
|
|
264
|
+
<RegionRulerArc
|
|
265
|
+
key={assembleLocString(slice.region)}
|
|
266
|
+
region={slice.region}
|
|
267
|
+
model={model}
|
|
268
|
+
slice={slice}
|
|
269
|
+
/>
|
|
270
|
+
)
|
|
271
|
+
})
|