@@ -7,7 +7,6 @@ import { AnyConfigurationSchemaType } from '@jbrowse/core/configuration/configur
77import PluginManager from '@jbrowse/core/PluginManager'
88import { MenuItem } from '@jbrowse/core/ui'
99import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
10- import { Theme } from '@mui/material'
1110import { autorun } from 'mobx'
1211import { Instance , addDisposer } from 'mobx-state-tree'
1312import type { CSSProperties } from 'react'
@@ -16,7 +15,6 @@ import { Coord } from '../components'
1615import { Glyph } from '../glyphs/Glyph'
1716import { CanvasMouseEvent } from '../types'
1817import { renderingModelFactory } from './rendering'
19- import { Frame , getFrame } from '@jbrowse/core/util'
2018
2119export interface FeatureAndGlyphUnderMouse {
2220 feature : AnnotationFeature
@@ -55,60 +53,6 @@ function getMousePosition(
5553 return { x, y, refName, bp, regionNumber }
5654}
5755
58- function getTranslationRow ( frame : Frame , bpPerPx : number ) {
59- const offset = bpPerPx <= 1 ? 2 : 0
60- switch ( frame ) {
61- case 3 : {
62- return 0
63- }
64- case 2 : {
65- return 1
66- }
67- case 1 : {
68- return 2
69- }
70- case - 1 : {
71- return 3 + offset
72- }
73- case - 2 : {
74- return 4 + offset
75- }
76- case - 3 : {
77- return 5 + offset
78- }
79- }
80- }
81-
82- function getSeqRow (
83- strand : 1 | - 1 | undefined ,
84- bpPerPx : number ,
85- ) : number | undefined {
86- if ( bpPerPx > 1 || strand === undefined ) {
87- return
88- }
89- return strand === 1 ? 3 : 4
90- }
91-
92- function highlightSeq (
93- seqTrackOverlayctx : CanvasRenderingContext2D ,
94- theme : Theme | undefined ,
95- startPx : number ,
96- sequenceRowHeight : number ,
97- row : number | undefined ,
98- widthPx : number ,
99- ) {
100- if ( row !== undefined ) {
101- seqTrackOverlayctx . fillStyle =
102- theme ?. palette . action . focus ?? 'rgba(0,0,0,0.04)'
103- seqTrackOverlayctx . fillRect (
104- startPx ,
105- sequenceRowHeight * row ,
106- widthPx ,
107- sequenceRowHeight ,
108- )
109- }
110- }
111-
11256export function mouseEventsModelIntermediateFactory (
11357 pluginManager : PluginManager ,
11458 configSchema : AnyConfigurationSchemaType ,
@@ -195,123 +139,12 @@ export function mouseEventsModelIntermediateFactory(
195139 } ) )
196140}
197141
198- export function mouseEventsSeqHightlightModelFactory (
199- pluginManager : PluginManager ,
200- configSchema : AnyConfigurationSchemaType ,
201- ) {
202- const LinearApolloSixFrameDisplayRendering =
203- mouseEventsModelIntermediateFactory ( pluginManager , configSchema )
204-
205- return LinearApolloSixFrameDisplayRendering . actions ( ( self ) => ( {
206- afterAttach ( ) {
207- addDisposer (
208- self ,
209- autorun (
210- ( ) => {
211- // This type is wrong in @jbrowse /core
212- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
213- if ( ! self . lgv . initialized || self . regionCannotBeRendered ( ) ) {
214- return
215- }
216- const seqTrackOverlayctx =
217- self . seqTrackOverlayCanvas ?. getContext ( '2d' )
218- if ( ! seqTrackOverlayctx ) {
219- return
220- }
221-
222- seqTrackOverlayctx . clearRect (
223- 0 ,
224- 0 ,
225- self . lgv . dynamicBlocks . totalWidthPx ,
226- self . lgv . bpPerPx <= 1 ? 125 : 95 ,
227- )
228-
229- const { apolloHover, lgv, regions, sequenceRowHeight, theme } = self
230-
231- if ( ! apolloHover ) {
232- return
233- }
234- const { feature } = apolloHover
235-
236- for ( const [ idx , region ] of regions . entries ( ) ) {
237- if ( feature . type === 'CDS' ) {
238- const parentFeature = feature . parent
239- if ( ! parentFeature ) {
240- continue
241- }
242- const cdsLocs = parentFeature . cdsLocations . find (
243- ( loc ) =>
244- feature . min === loc . at ( 0 ) ?. min &&
245- feature . max === loc . at ( - 1 ) ?. max ,
246- )
247- if ( ! cdsLocs ) {
248- continue
249- }
250- for ( const dl of cdsLocs ) {
251- const frame = getFrame (
252- dl . min ,
253- dl . max ,
254- feature . strand ?? 1 ,
255- dl . phase ,
256- )
257- const row = getTranslationRow ( frame , lgv . bpPerPx )
258- const offset =
259- ( lgv . bpToPx ( {
260- refName : region . refName ,
261- coord : dl . min ,
262- regionNumber : idx ,
263- } ) ?. offsetPx ?? 0 ) - lgv . offsetPx
264- const widthPx = ( dl . max - dl . min ) / lgv . bpPerPx
265- const startPx = lgv . displayedRegions [ idx ] . reversed
266- ? offset - widthPx
267- : offset
268-
269- highlightSeq (
270- seqTrackOverlayctx ,
271- theme ,
272- startPx ,
273- sequenceRowHeight ,
274- row ,
275- widthPx ,
276- )
277- }
278- } else {
279- const row = getSeqRow ( feature . strand , lgv . bpPerPx )
280- const offset =
281- ( lgv . bpToPx ( {
282- refName : region . refName ,
283- coord : feature . min ,
284- regionNumber : idx ,
285- } ) ?. offsetPx ?? 0 ) - lgv . offsetPx
286- const widthPx = feature . length / lgv . bpPerPx
287- const startPx = lgv . displayedRegions [ idx ] . reversed
288- ? offset - widthPx
289- : offset
290-
291- highlightSeq (
292- seqTrackOverlayctx ,
293- theme ,
294- startPx ,
295- sequenceRowHeight ,
296- row ,
297- widthPx ,
298- )
299- }
300- }
301- } ,
302- { name : 'LinearApolloSixFrameDisplayRenderSeqHighlight' } ,
303- ) ,
304- )
305- } ,
306- } ) )
307- }
308-
309142export function mouseEventsModelFactory (
310143 pluginManager : PluginManager ,
311144 configSchema : AnyConfigurationSchemaType ,
312145) {
313146 const LinearApolloSixFrameDisplayMouseEvents =
314- mouseEventsSeqHightlightModelFactory ( pluginManager , configSchema )
147+ mouseEventsModelIntermediateFactory ( pluginManager , configSchema )
315148
316149 return LinearApolloSixFrameDisplayMouseEvents . views ( ( self ) => ( {
317150 contextMenuItems ( contextCoord ?: Coord ) : MenuItem [ ] {
0 commit comments