Skip to content

Commit

Permalink
bug: SVG rendering of ideogram is not happening
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Aug 5, 2024
1 parent e199a16 commit f75cad9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
4 changes: 2 additions & 2 deletions dev/misc/png.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

<script type="module">

// import igv from '../../js/index.js'
import igv from '../../dist/igv.esm.js'
import igv from '../../js/index.js'
// import igv from '../../dist/igv.esm.js'

const bedgraph_options = {
locus: '19:49301000-49305700',
Expand Down
8 changes: 7 additions & 1 deletion js/ideogramTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,13 @@ async function drawIdeogram({ctx, chr, referenceFrame, genome, width, height, st

IGVGraphics.fillRect(ctx, 0, 0, width, height, {fillStyle: IGVColor.greyScale(255)})

const cytobands = await genome.getCytobands(chr)
let cytobands
if (0 === genome.cytobandSource.cytobands.size) {
cytobands = await genome.getCytobands(chr)
} else {
cytobands = genome.cytobandSource.cytobands.get(chr)
}

if (cytobands) {

const center = (ideogramTop + height / 2)
Expand Down
45 changes: 26 additions & 19 deletions js/ideogramViewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import $ from "./vendor/jquery-3.3.1.slim.js"
import IGVGraphics from './igv-canvas.js'
import * as DOMUtils from "./ui/utils/dom-utils.js"
import TrackViewport from "./trackViewport.js"
import {appleCrayonRGB} from "./util/colorPalletes.js"

class IdeogramViewport extends TrackViewport {

Expand Down Expand Up @@ -87,34 +88,40 @@ class IdeogramViewport extends TrackViewport {
this.$viewport.width(width)
}

drawSVGWithContext(context, width, height, id, x, y, yClipOffset) {
renderSVGContext(context, {deltaX, deltaY}, includeLabel = true) {

context.saveWithTranslationAndClipRect(id, x, y, width, height, yClipOffset)
const {width, height} = this.$viewport.get(0).getBoundingClientRect()

const str = 'ideogram'
const index = this.browser.referenceFrameList.indexOf(this.referenceFrame)
const id = `${str}_referenceFrame_${index}_guid_${DOMUtils.guid()}`

this.trackView.track.draw({
context,
referenceFrame: this.referenceFrame,
pixelWidth: width,
pixelHeight: height
})
const x = deltaX
const y = deltaY + this.contentTop
const yClipOffset = -this.contentTop

context.saveWithTranslationAndClipRect(id, x, y, width, height, yClipOffset)
this.trackView.track.draw({ context, pixelWidth:width, pixelHeight:height, referenceFrame:this.referenceFrame })
context.restore()
}

repaint() {
this.draw({referenceFrame: this.referenceFrame})
}

async draw({referenceFrame}) {
repaint() {
const {width, height} = this.$viewport.get(0).getBoundingClientRect()
const config =
{
context:this.ideogram_ctx,
pixelWidth: width,
pixelHeight: height,
referenceFrame: this.referenceFrame
}

IGVGraphics.configureHighDPICanvas(this.ideogram_ctx, this.$viewport.width(), this.$viewport.height())
this.draw(config)
}

this.trackView.track.draw({
context: this.ideogram_ctx,
referenceFrame,
pixelWidth: this.$viewport.width(),
pixelHeight: this.$viewport.height()
})
async draw({ context, pixelWidth, pixelHeight, referenceFrame }) {
IGVGraphics.configureHighDPICanvas(context, pixelWidth, pixelHeight)
this.trackView.track.draw({ context, pixelWidth, pixelHeight, referenceFrame })
}

startSpinner() {
Expand Down

0 comments on commit f75cad9

Please sign in to comment.