Put scaling back in the backend

This commit is contained in:
Emanuele Bezzi
2021-12-09 14:12:16 -05:00
parent 2fe9cc4aac
commit cbf3ba240a
3 changed files with 57 additions and 47 deletions
+12 -24
View File
@@ -112,24 +112,20 @@ class Graph extends React.Component {
return !shallowEqual(props.watchProps, prevProps.watchProps);
}
computePointPositions = memoize(
(X, Y, modelTF, spatialMetadata, imageUnderlay) => {
/*
computePointPositions = memoize((X, Y, modelTF) => {
/*
compute the model coordinate for each point
*/
console.log({ X }, { Y });
const positions = new Float32Array(2 * X.length);
for (let i = 0, len = X.length; i < len; i += 1) {
const p = imageUnderlay?.isActive
? this.rescalePointForSpatial(X[i], Y[i], spatialMetadata)
: vec2.fromValues(X[i], Y[i]);
vec2.transformMat3(p, p, modelTF);
positions[2 * i] = p[0];
positions[2 * i + 1] = p[1];
}
return positions;
console.log({ X }, { Y });
const positions = new Float32Array(2 * X.length);
for (let i = 0, len = X.length; i < len; i += 1) {
const p = vec2.fromValues(X[i], Y[i]);
vec2.transformMat3(p, p, modelTF);
positions[2 * i] = p[0];
positions[2 * i + 1] = p[1];
}
);
return positions;
});
computePointColors = memoize((rgb) => {
/*
@@ -585,13 +581,7 @@ class Graph extends React.Component {
const { currentDimNames } = layoutChoice;
const X = layoutDf.col(currentDimNames[0]).asArray();
const Y = layoutDf.col(currentDimNames[1]).asArray();
const positions = this.computePointPositions(
X,
Y,
modelTF,
spatial.data,
imageUnderlay
);
const positions = this.computePointPositions(X, Y, modelTF);
const colorTable = this.updateColorTable(colorsProp, colorDf);
const colors = this.computePointColors(colorTable.rgb);
@@ -809,8 +799,6 @@ class Graph extends React.Component {
const { pointBuffer, colorBuffer, flagBuffer } = this.state;
let needToRenderCanvas = false;
console.log("updateReglAndRender");
if (height !== prevAsyncProps?.height || width !== prevAsyncProps?.width) {
needToRenderCanvas = true;
}