mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-05 22:48:11 +08:00
Connect button
This commit is contained in:
@@ -112,23 +112,24 @@ class Graph extends React.Component {
|
|||||||
return !shallowEqual(props.watchProps, prevProps.watchProps);
|
return !shallowEqual(props.watchProps, prevProps.watchProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
computePointPositions = memoize((X, Y, modelTF, spatialMetadata) => {
|
computePointPositions = memoize(
|
||||||
const { imageUnderlay } = this.props;
|
(X, Y, modelTF, spatialMetadata, imageUnderlay) => {
|
||||||
/*
|
/*
|
||||||
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) {
|
||||||
const p = imageUnderlay?.isActive
|
const p = imageUnderlay?.isActive
|
||||||
? this.rescalePointForSpatial(X[i], Y[i], spatialMetadata)
|
? this.rescalePointForSpatial(X[i], Y[i], spatialMetadata)
|
||||||
: vec2.fromValues(X[i], Y[i]);
|
: 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];
|
||||||
|
}
|
||||||
|
return positions;
|
||||||
}
|
}
|
||||||
return positions;
|
);
|
||||||
});
|
|
||||||
|
|
||||||
computePointColors = memoize((rgb) => {
|
computePointColors = memoize((rgb) => {
|
||||||
/*
|
/*
|
||||||
@@ -567,6 +568,7 @@ class Graph extends React.Component {
|
|||||||
pointDilation,
|
pointDilation,
|
||||||
viewport,
|
viewport,
|
||||||
spatial,
|
spatial,
|
||||||
|
imageUnderlay,
|
||||||
} = props.watchProps;
|
} = props.watchProps;
|
||||||
const { modelTF } = this.state;
|
const { modelTF } = this.state;
|
||||||
|
|
||||||
@@ -576,13 +578,20 @@ class Graph extends React.Component {
|
|||||||
annoMatrix,
|
annoMatrix,
|
||||||
layoutChoice,
|
layoutChoice,
|
||||||
colorsProp,
|
colorsProp,
|
||||||
pointDilation
|
pointDilation,
|
||||||
|
imageUnderlay
|
||||||
);
|
);
|
||||||
|
|
||||||
const { currentDimNames } = layoutChoice;
|
const { currentDimNames } = layoutChoice;
|
||||||
const X = layoutDf.col(currentDimNames[0]).asArray();
|
const X = layoutDf.col(currentDimNames[0]).asArray();
|
||||||
const Y = layoutDf.col(currentDimNames[1]).asArray();
|
const Y = layoutDf.col(currentDimNames[1]).asArray();
|
||||||
const positions = this.computePointPositions(X, Y, modelTF, spatial.data);
|
const positions = this.computePointPositions(
|
||||||
|
X,
|
||||||
|
Y,
|
||||||
|
modelTF,
|
||||||
|
spatial.data,
|
||||||
|
imageUnderlay
|
||||||
|
);
|
||||||
|
|
||||||
const colorTable = this.updateColorTable(colorsProp, colorDf);
|
const colorTable = this.updateColorTable(colorsProp, colorDf);
|
||||||
const colors = this.computePointColors(colorTable.rgb);
|
const colors = this.computePointColors(colorTable.rgb);
|
||||||
@@ -615,6 +624,7 @@ class Graph extends React.Component {
|
|||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
spatial,
|
spatial,
|
||||||
|
imageUnderlay,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -796,7 +806,9 @@ class Graph extends React.Component {
|
|||||||
const { positions, colors, flags, height, width } = asyncProps;
|
const { positions, colors, flags, height, width } = asyncProps;
|
||||||
this.cachedAsyncProps = asyncProps;
|
this.cachedAsyncProps = asyncProps;
|
||||||
const { pointBuffer, colorBuffer, flagBuffer } = this.state;
|
const { pointBuffer, colorBuffer, flagBuffer } = this.state;
|
||||||
let needToRenderCanvas = false;
|
let needToRenderCanvas = true;
|
||||||
|
|
||||||
|
console.log("updateReglAndRender");
|
||||||
|
|
||||||
if (height !== prevAsyncProps?.height || width !== prevAsyncProps?.width) {
|
if (height !== prevAsyncProps?.height || width !== prevAsyncProps?.width) {
|
||||||
needToRenderCanvas = true;
|
needToRenderCanvas = true;
|
||||||
@@ -857,10 +869,9 @@ class Graph extends React.Component {
|
|||||||
flagBuffer,
|
flagBuffer,
|
||||||
camera,
|
camera,
|
||||||
projectionTF,
|
projectionTF,
|
||||||
drawSpatialImage,
|
drawSpatialImage
|
||||||
imageUnderlay
|
|
||||||
) {
|
) {
|
||||||
const { annoMatrix, spatial } = this.props;
|
const { annoMatrix, spatial, imageUnderlay } = this.props;
|
||||||
if (!this.reglCanvas || !annoMatrix) return;
|
if (!this.reglCanvas || !annoMatrix) return;
|
||||||
|
|
||||||
const { schema } = annoMatrix;
|
const { schema } = annoMatrix;
|
||||||
@@ -870,6 +881,8 @@ class Graph extends React.Component {
|
|||||||
const imW = spatial.data.imageWidth;
|
const imW = spatial.data.imageWidth;
|
||||||
const imH = spatial.data.imageHeight;
|
const imH = spatial.data.imageHeight;
|
||||||
|
|
||||||
|
console.log({ imageUnderlay });
|
||||||
|
|
||||||
regl.poll();
|
regl.poll();
|
||||||
regl.clear({
|
regl.clear({
|
||||||
depth: 1,
|
depth: 1,
|
||||||
@@ -911,6 +924,7 @@ class Graph extends React.Component {
|
|||||||
pointDilation,
|
pointDilation,
|
||||||
crossfilter,
|
crossfilter,
|
||||||
spatial,
|
spatial,
|
||||||
|
imageUnderlay,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { modelTF, projectionTF, camera, viewport, regl } = this.state;
|
const { modelTF, projectionTF, camera, viewport, regl } = this.state;
|
||||||
const cameraTF = camera?.view()?.slice();
|
const cameraTF = camera?.view()?.slice();
|
||||||
@@ -985,6 +999,7 @@ class Graph extends React.Component {
|
|||||||
crossfilter,
|
crossfilter,
|
||||||
viewport,
|
viewport,
|
||||||
spatial,
|
spatial,
|
||||||
|
imageUnderlay,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Async.Pending initial>
|
<Async.Pending initial>
|
||||||
|
|||||||
Reference in New Issue
Block a user