mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-06 02:18:12 +08:00
undable config and conditional graph render of image
This commit is contained in:
@@ -79,6 +79,7 @@ function createModelTF() {
|
|||||||
pointDilation: state.pointDilation,
|
pointDilation: state.pointDilation,
|
||||||
genesets: state.genesets.genesets,
|
genesets: state.genesets.genesets,
|
||||||
spatial: state.spatial.metadata,
|
spatial: state.spatial.metadata,
|
||||||
|
imageUnderlay: state.imageUnderlay,
|
||||||
}))
|
}))
|
||||||
class Graph extends React.Component {
|
class Graph extends React.Component {
|
||||||
static createReglState(canvas) {
|
static createReglState(canvas) {
|
||||||
@@ -112,15 +113,16 @@ class Graph extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
computePointPositions = memoize((X, Y, modelTF, spatialMetadata) => {
|
computePointPositions = memoize((X, Y, modelTF, spatialMetadata) => {
|
||||||
|
const { imageUnderlay } = this.props;
|
||||||
/*
|
/*
|
||||||
compute the model coordinate for each point
|
compute the model coordinate for each point
|
||||||
*/
|
*/
|
||||||
console.log({ X }, { Y });
|
console.log({ X }, { Y });
|
||||||
const positions = new Float32Array(2 * X.length);
|
const positions = new Float32Array(2 * X.length);
|
||||||
for (let i = 0, len = X.length; i < len; i += 1) {
|
for (let i = 0, len = X.length; i < len; i += 1) {
|
||||||
// TODO: Introduce the feature flag here
|
const p = imageUnderlay?.isActive
|
||||||
// const p = vec2.fromValues(X[i], Y[i]);
|
? this.rescalePointForSpatial(X[i], Y[i], spatialMetadata)
|
||||||
const p = this.rescalePointForSpatial(X[i], Y[i], spatialMetadata);
|
: vec2.fromValues(X[i], Y[i]);
|
||||||
vec2.transformMat3(p, p, modelTF);
|
vec2.transformMat3(p, p, modelTF);
|
||||||
positions[2 * i] = p[0];
|
positions[2 * i] = p[0];
|
||||||
positions[2 * i + 1] = p[1];
|
positions[2 * i + 1] = p[1];
|
||||||
@@ -855,7 +857,8 @@ class Graph extends React.Component {
|
|||||||
flagBuffer,
|
flagBuffer,
|
||||||
camera,
|
camera,
|
||||||
projectionTF,
|
projectionTF,
|
||||||
drawSpatialImage
|
drawSpatialImage,
|
||||||
|
imageUnderlay
|
||||||
) {
|
) {
|
||||||
const { annoMatrix, spatial } = this.props;
|
const { annoMatrix, spatial } = this.props;
|
||||||
if (!this.reglCanvas || !annoMatrix) return;
|
if (!this.reglCanvas || !annoMatrix) return;
|
||||||
@@ -872,6 +875,7 @@ class Graph extends React.Component {
|
|||||||
depth: 1,
|
depth: 1,
|
||||||
color: [0, 0, 0, 0],
|
color: [0, 0, 0, 0],
|
||||||
});
|
});
|
||||||
|
|
||||||
drawPoints({
|
drawPoints({
|
||||||
distance: camera.distance(),
|
distance: camera.distance(),
|
||||||
color: colorBuffer,
|
color: colorBuffer,
|
||||||
@@ -882,17 +886,19 @@ class Graph extends React.Component {
|
|||||||
nPoints: schema.dataframe.nObs,
|
nPoints: schema.dataframe.nObs,
|
||||||
minViewportDimension: Math.min(width, height),
|
minViewportDimension: Math.min(width, height),
|
||||||
});
|
});
|
||||||
drawSpatialImage({
|
if (imageUnderlay?.isActive) {
|
||||||
projView,
|
drawSpatialImage({
|
||||||
imageWidth: imW,
|
projView,
|
||||||
imageHeight: imH,
|
imageWidth: imW,
|
||||||
rectCoords: [0, 0, imW, 0, 0, imH, 0, imH, imW, 0, imW, imH],
|
imageHeight: imH,
|
||||||
spatialImageAsTexture: regl.texture({
|
rectCoords: [0, 0, imW, 0, 0, imH, 0, imH, imW, 0, imW, imH],
|
||||||
data: this.spatialImage,
|
spatialImageAsTexture: regl.texture({
|
||||||
wrapS: "clamp",
|
data: this.spatialImage,
|
||||||
wrapT: "clamp",
|
wrapS: "clamp",
|
||||||
}),
|
wrapT: "clamp",
|
||||||
});
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
regl._gl.flush();
|
regl._gl.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ const skipOnActions = new Set([
|
|||||||
"geneset: disable add new genes mode",
|
"geneset: disable add new genes mode",
|
||||||
"geneset: activate rename geneset mode",
|
"geneset: activate rename geneset mode",
|
||||||
"geneset: disable rename geneset mode",
|
"geneset: disable rename geneset mode",
|
||||||
|
|
||||||
|
/* spatial */
|
||||||
|
"toggle image underlay",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user