Skip to content

Commit

Permalink
click and drag canonical gene glyph
Browse files Browse the repository at this point in the history
  • Loading branch information
shashankbrgowda committed Sep 4, 2023
1 parent 864af01 commit 4be9ed8
Show file tree
Hide file tree
Showing 6 changed files with 360 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,31 @@ export class BoxGlyph extends Glyph {
return false
}

continueDrag(
stateModel: LinearApolloDisplay,
currentMousePosition: MousePosition,
) {
const { feature, glyph, mousePosition, topLevelFeature } =
stateModel.apolloDragging?.start ?? {}
if (!(currentMousePosition && mousePosition)) {
return
}
stateModel.setDragging({
start: {
feature,
topLevelFeature,
glyph,
mousePosition,
},
current: {
feature,
topLevelFeature,
glyph,
mousePosition: currentMousePosition,
},
})
}

executeDrag(stateModel: LinearApolloDisplay) {
const {
apolloDragging,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AnnotationFeatureI } from 'apollo-mst'

import { LinearApolloDisplay } from '../stateModel'
import { MousePosition } from '../stateModel/mouseEvents'
import { CanvasMouseEvent } from '../types'
import { Glyph } from './Glyph'

Expand Down Expand Up @@ -446,6 +447,13 @@ export class CanonicalGeneGlyph extends Glyph {
}
}

continueDrag(
_display: LinearApolloDisplay,
_currentMousePosition: MousePosition,
): void {
// pass
}

getFeatureFromLayout(
feature: AnnotationFeatureI,
bp: number,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AnnotationFeatureI } from 'apollo-mst'

import { LinearApolloDisplay } from '../stateModel'
import { MousePosition } from '../stateModel/mouseEvents'
import { CanvasMouseEvent } from '../types'
import { Glyph } from './Glyph'

Expand Down Expand Up @@ -136,6 +137,13 @@ export class GenericChildGlyph extends Glyph {
}
}

continueDrag(
_display: LinearApolloDisplay,
_currentMousePosition: MousePosition,
): void {
// pass
}

getFeatureFromLayout(feature: AnnotationFeatureI, bp: number, row: number) {
const layoutRow = this.featuresForRow(feature)[row]
return layoutRow?.find((f) => bp >= f.start && bp <= f.end)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
DeleteFeature,
ModifyFeatureAttribute,
} from '../../components'
import { LinearApolloDisplayMouseEvents } from '../stateModel/mouseEvents'
import {
LinearApolloDisplayMouseEvents,
MousePosition,
} from '../stateModel/mouseEvents'
import { LinearApolloDisplayRendering } from '../stateModel/rendering'
import { CanvasMouseEvent } from '../types'

Expand All @@ -32,6 +35,11 @@ export abstract class Glyph {
row: number,
): AnnotationFeatureI | undefined

abstract continueDrag(
display: LinearApolloDisplayRendering,
currentMousePosition: MousePosition,
): void

drawHover(
_display: LinearApolloDisplayMouseEvents,
_overlayCtx: CanvasRenderingContext2D,
Expand Down Expand Up @@ -99,13 +107,44 @@ export abstract class Glyph {
return
}

getAdjacentFeatures(
feature?: AnnotationFeatureI,
parentFeature?: AnnotationFeatureI,
): {
prevFeature?: AnnotationFeatureI
nextFeature?: AnnotationFeatureI
} {
let prevFeature: AnnotationFeatureI | undefined
let nextFeature: AnnotationFeatureI | undefined
let i = 0
if (!feature || !(parentFeature && parentFeature.children)) {
return { prevFeature, nextFeature }
}
for (const [, f] of parentFeature.children) {
if (f._id === feature._id) {
break
}
i++
}
const keys = [...parentFeature.children.keys()]
if (i > 0) {
const key = keys[i - 1]
prevFeature = parentFeature.children.get(key)
}
if (i < keys.length - 1) {
const key = keys[i + 1]
nextFeature = parentFeature.children.get(key)
}
return { prevFeature, nextFeature }
}

getParentFeature(
feature: AnnotationFeatureI,
feature?: AnnotationFeatureI,
topLevelFeature?: AnnotationFeatureI,
) {
let parentFeature

if (!(topLevelFeature && topLevelFeature.children)) {
if (!feature || !(topLevelFeature && topLevelFeature.children)) {
return parentFeature
}

Expand Down
Loading

0 comments on commit 4be9ed8

Please sign in to comment.