Skip to content

Commit

Permalink
save ROI set visibility to session
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Nov 13, 2023
1 parent 0782f94 commit e155f5c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
15 changes: 15 additions & 0 deletions js/roi/ROIManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class ROIManager {
const records = await this.getTableRecords()
this.roiTable.renderTable(records)

if (this.roiSets.length > 0) {
const isVisible = this.roiSets[ 0 ].isVisible
this.roiTable.setROIVisibility(isVisible)
}

}

async loadROI(config, genome) {
Expand Down Expand Up @@ -122,6 +127,16 @@ class ROIManager {
this.browser.roiTableControl.setVisibility(this.browser.doShowROITableButton)
}

toggleROIs() {

const isVisible = !(this.roiSets[ 0 ].isVisible)
this.roiTable.setROIVisibility(isVisible)

for (const roiSet of this.roiSets) {
roiSet.isVisible = isVisible
}
}

async renderAllROISets() {

for (let roiSet of this.roiSets) {
Expand Down
6 changes: 4 additions & 2 deletions js/roi/ROISet.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class ROISet {
// this.headerColor = `rgba(${ r },${ g },${ b },${ 1.0 })`

}

this.isVisible = config.isVisible || true
}

async getFeatures(chr, start, end) {
Expand Down Expand Up @@ -85,7 +87,7 @@ class ROISet {

toJSON() {
if (this.url) {
return {name: this.name, color: this.color, url: this.url, isUserDefined: this.isUserDefined}
return {name: this.name, color: this.color, url: this.url, isUserDefined: this.isUserDefined, isVisible: this.isVisible}
} else {
const featureMap = this.featureSource.getAllFeatures()
const features = []
Expand All @@ -94,7 +96,7 @@ class ROISet {
features.push(f)
}
}
return {name: this.name, color: this.color, features: features, isUserDefined: this.isUserDefined}
return {name: this.name, color: this.color, features: features, isUserDefined: this.isUserDefined, isVisible: this.isVisible}
}
}

Expand Down
11 changes: 6 additions & 5 deletions js/roi/ROITable.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ROITable extends RegionTableBase {
function toggleROIButtonHandler(event) {
event.preventDefault()
event.stopPropagation()
this.toggleROIs()
this.browser.roiManager.toggleROIs()
}

this.boundToggleDisplayButtonHandler = toggleROIButtonHandler.bind(this)
Expand All @@ -87,16 +87,17 @@ class ROITable extends RegionTableBase {

}

toggleROIs() {
setROIVisibility(isVisible) {

const elements = this.browser.columnContainer.querySelectorAll('.igv-roi-region')
for (const el of elements) {
el.style.display = 'none' === el.style.display ? 'flex' : 'none'
el.style.display = false === isVisible ? 'none' : 'flex'
}

const status = elements[ 0 ].style.display
this.toggleROIButton.textContent = 'none' === status ? 'Show all ROIs' : 'Hide all ROIs'
this.toggleROIButton.textContent = false === isVisible ? 'Show all ROIs' : 'Hide all ROIs'

}

dispose() {

document.removeEventListener('click', this.boundGotoButtonHandler)
Expand Down

0 comments on commit e155f5c

Please sign in to comment.