Skip to content

Commit

Permalink
Add ability to toggle "Show track outlines" (#4497)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin authored Jul 26, 2024
1 parent b6b98a4 commit 04781e9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ const TrackContainer = observer(function ({
}) {
const { classes } = useStyles()
const display = track.displays[0]
const { draggingTrackId } = model
const { draggingTrackId, showTrackOutlines } = model
const ref = useRef<HTMLDivElement>(null)

return (
<Paper
ref={ref}
className={classes.root}
variant="outlined"
variant={showTrackOutlines ? 'outlined' : undefined}
elevation={showTrackOutlines ? undefined : 0}
onClick={event => {
if (event.detail === 2 && !track.displays[0].featureIdUnderMouse) {
const left = ref.current?.getBoundingClientRect().left || 0
Expand Down
23 changes: 23 additions & 0 deletions plugins/linear-genome-view/src/LinearGenomeView/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,16 @@ export function stateModelFactory(pluginManager: PluginManager) {
colorByCDS: types.optional(types.boolean, () =>
Boolean(JSON.parse(localStorageGetItem('lgv-colorByCDS') || 'false')),
),

/**
* #property
* color by CDS
*/
showTrackOutlines: types.optional(types.boolean, () =>
Boolean(
JSON.parse(localStorageGetItem('lgv-showTrackOutlines') || 'true'),
),
),
}),
)
.volatile(() => ({
Expand Down Expand Up @@ -560,6 +570,12 @@ export function stateModelFactory(pluginManager: PluginManager) {
},
}))
.actions(self => ({
/**
* #action
*/
setShowTrackOutlines(arg: boolean) {
self.showTrackOutlines = arg
},
/**
* #action
*/
Expand Down Expand Up @@ -1210,6 +1226,13 @@ export function stateModelFactory(pluginManager: PluginManager) {
onClick: () => self.setHideHeader(!self.hideHeader),
},

{
label: 'Show track outlines',
type: 'checkbox',
checked: self.showTrackOutlines,
onClick: () =>
self.setShowTrackOutlines(!self.showTrackOutlines),
},
{
label: 'Show header overview',
type: 'checkbox',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import { drawDensity } from '../drawDensity'
export default class MultiXYPlotRenderer extends WiggleBaseRenderer {
// @ts-expect-error
async draw(ctx: CanvasRenderingContext2D, props: MultiArgs) {
const { bpPerPx, sources, regions, features } = props
const [region] = regions
const { sources, features } = props
const groups = groupBy(features.values(), f => f.get('source'))
const height = props.height / sources.length
const width = (region.end - region.start) / bpPerPx
let feats = [] as Feature[]
ctx.save()
sources.forEach(source => {
Expand All @@ -21,11 +19,6 @@ export default class MultiXYPlotRenderer extends WiggleBaseRenderer {
features,
height,
})
ctx.strokeStyle = 'rgba(200,200,200,0.8)'
ctx.beginPath()
ctx.moveTo(0, height)
ctx.lineTo(width, height)
ctx.stroke()
ctx.translate(0, height)
feats = feats.concat(reducedFeatures)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { observer } from 'mobx-react'
import { WiggleDisplayModel } from '../models/model'
import YScaleBars from './YScaleBars'

const MultiLinearWiggleDisplayComponent = observer(
(props: { model: WiggleDisplayModel }) => {
const { model } = props
const MultiLinearWiggleDisplayComponent = observer(function (props: {
model: WiggleDisplayModel
}) {
const { model } = props

return (
<div>
<BaseLinearDisplayComponent {...props} />
<YScaleBars model={model} />
</div>
)
},
)
return (
<div>
<BaseLinearDisplayComponent {...props} />
<YScaleBars model={model} />
</div>
)
})

export default MultiLinearWiggleDisplayComponent

0 comments on commit 04781e9

Please sign in to comment.