Skip to content

Commit

Permalink
Reduce calculations on change height
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 13, 2024
1 parent d3063e0 commit 92023f8
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 175 deletions.
1 change: 0 additions & 1 deletion plugins/alignments/src/BamAdapter/BamAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ export default class BamAdapter extends BaseFeatureDataAdapter {
if (tagFilter) {
const readVal = record.tags[tagFilter.tag]
const filterVal = tagFilter.value
console.log({ readVal, filterVal })
if (
filterVal === '*'
? readVal === undefined
Expand Down
61 changes: 36 additions & 25 deletions plugins/alignments/src/LinearSNPCoverageDisplay/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function stateModelFactory(
},
}))
.views(self => {
const { renderProps: superRenderProps } = self
const { adapterProps: superAdapterProps } = self
return {
/**
* #getter
Expand Down Expand Up @@ -196,36 +196,16 @@ function stateModelFactory(
)
},

/**
* #getter
*/
get renderReady() {
const superProps = superRenderProps()
return !superProps.notReady && self.modificationsReady
},

/**
* #getter
*/
get ready() {
return this.renderReady
},

/**
* #method
*/
renderProps() {
const superProps = superRenderProps()
const { filters, colorBy, filterBy, visibleModifications } = self
adapterProps() {
const superProps = superAdapterProps()
const { filters, filterBy } = self
return {
...superProps,
notReady: !this.ready,
filters,
colorBy,
filterBy,
visibleModifications: Object.fromEntries(
visibleModifications.toJSON(),
),
}
},
}
Expand Down Expand Up @@ -288,8 +268,39 @@ function stateModelFactory(
}))

.views(self => {
const { trackMenuItems: superTrackMenuItems } = self
const {
renderProps: superRenderProps,
trackMenuItems: superTrackMenuItems,
} = self
return {
/**
* #getter
*/
get renderReady() {
const superProps = superRenderProps()
return !superProps.notReady && self.modificationsReady
},

/**
* #getter
*/
get ready() {
return this.renderReady
},
/**
* #method
*/
renderProps() {
const { colorBy, visibleModifications } = self
return {
...superRenderProps(),
notReady: !this.ready,
colorBy,
visibleModifications: Object.fromEntries(
visibleModifications.toJSON(),
),
}
},
/**
* #getter
*/
Expand Down
132 changes: 73 additions & 59 deletions plugins/wiggle/src/LinearWiggleDisplay/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,98 +71,112 @@ function stateModelFactory(
}
return rendererType
},
}))

.views(self => ({
/**
* #getter
*/
get ticks() {
const { scaleType, domain, height } = self
const minimalTicks = getConf(self, 'minimalTicks')
const inverted = getConf(self, 'inverted')
const range = [height - YSCALEBAR_LABEL_OFFSET, YSCALEBAR_LABEL_OFFSET]
if (!domain) {
return undefined
}
const scale = getScale({
scaleType,
domain,
range,
inverted,
})
const ticks = axisPropsFromTickScale(scale, 4)
return height < 100 || minimalTicks
? { ...ticks, values: domain }
: ticks
},
/**
* #getter
*/
get quantitativeStatsReleventToCurrentZoom() {
get quantitativeStatsRelevantToCurrentZoom() {
const view = getContainingView(self) as LinearGenomeViewModel
return self.stats?.currStatsBpPerPx === view.bpPerPx
},
}))

.views(self => {
const { renderProps: superRenderProps } = self
return {
/**
* #method
*/
renderProps() {
adapterProps() {
const superProps = superRenderProps()
const { filters, ticks, height, resolution, scaleOpts } = self
const { filters, resolution, scaleOpts } = self
return {
...superProps,
notReady:
superProps.notReady ||
!self.quantitativeStatsReleventToCurrentZoom,

rpcDriverName: self.rpcDriverName,
displayModel: self,
config: self.rendererConfig,
displayCrossHatches: self.displayCrossHatchesSetting,
scaleOpts,
resolution,
height,
ticks,
filters,
}
},

/**
* #getter
*/
get needsScalebar() {
const { rendererTypeName: type } = self
return type === 'XYPlotRenderer' || type === 'LinePlotRenderer'
},
/**
* #getter
*/
get fillSetting() {
if (self.filled) {
return 0
} else if (self.minSize === 1) {
return 1
} else {
return 2
get ticks() {
const { scaleType, domain, height } = self
const minimalTicks = getConf(self, 'minimalTicks')
const inverted = getConf(self, 'inverted')
const range = [
height - YSCALEBAR_LABEL_OFFSET,
YSCALEBAR_LABEL_OFFSET,
]
if (!domain) {
return undefined
}
},
/**
* #getter
*/
get quantitativeStatsReady() {
const view = getContainingView(self) as LinearGenomeViewModel
return (
view.initialized &&
self.featureDensityStatsReady &&
!self.regionTooLarge &&
!self.error
)
const scale = getScale({
scaleType,
domain,
range,
inverted,
})
const ticks = axisPropsFromTickScale(scale, 4)
return height < 100 || minimalTicks
? { ...ticks, values: domain }
: ticks
},
}
})
.views(self => ({
/**
* #method
*/
renderProps() {
const { ticks, height } = self
const superProps = self.adapterProps()
return {
...self.adapterProps(),
notReady:
superProps.notReady || !self.quantitativeStatsRelevantToCurrentZoom,
height,
ticks,
}
},

/**
* #getter
*/
get needsScalebar() {
const { rendererTypeName: type } = self
return type === 'XYPlotRenderer' || type === 'LinePlotRenderer'
},
/**
* #getter
*/
get fillSetting() {
if (self.filled) {
return 0
} else if (self.minSize === 1) {
return 1
} else {
return 2
}
},
/**
* #getter
*/
get quantitativeStatsReady() {
const view = getContainingView(self) as LinearGenomeViewModel
return (
view.initialized &&
self.featureDensityStatsReady &&
!self.regionTooLarge &&
!self.error
)
},
}))
.views(self => {
const { trackMenuItems: superTrackMenuItems } = self
const hasRenderings = getConf(self, 'defaultRendering')
Expand Down
Loading

0 comments on commit 92023f8

Please sign in to comment.