Skip to content

Commit

Permalink
fix ROI shift issue when saving svg (#1742)
Browse files Browse the repository at this point in the history
* fix ROI shift issue when saving svg

* cleaner solution suggested by Turner
  • Loading branch information
wilsonGen authored Dec 15, 2023
1 parent af99de9 commit 7213932
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion js/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class Browser {
*/
toSVG() {

const {y, width, height} = this.columnContainer.getBoundingClientRect()
const {x, y, width, height} = this.columnContainer.getBoundingClientRect()

const h_render = 8000

Expand Down Expand Up @@ -412,6 +412,8 @@ class Browser {
trackView.renderSVGContext(context, delta)
}

// ROI -> SVG
delta.deltaX = x
this.roiManager.renderSVGContext(context, delta)

// reset height to trim away unneeded svg canvas real estate. Yes, a bit of a hack.
Expand Down
4 changes: 2 additions & 2 deletions js/roi/ROIManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,13 @@ class ROIManager {
// body
const { x, y, width, height } = regionElement.getBoundingClientRect()
context.fillStyle = regionElement.style.backgroundColor
context.fillRect(x+deltaX, y+deltaY, width, height)
context.fillRect(x-deltaX, y+deltaY, width, height)

// header
const header = regionElement.querySelector('div')
const { x:xx, y:yy, width:ww, height:hh } = header.getBoundingClientRect()
context.fillStyle = header.style.backgroundColor
context.fillRect(xx+deltaX, yy+deltaY, ww, hh)
context.fillRect(xx-deltaX, yy+deltaY, ww, hh)
}
}

Expand Down

0 comments on commit 7213932

Please sign in to comment.