mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-10 02:00:56 +08:00
Merge pull request #46 from chanzuckerberg/freeman-lab-brushing-fix
fix scale inversion for brushing
This commit is contained in:
@@ -95,17 +95,7 @@ class Graph extends React.Component {
|
|||||||
scale: viewportHeight / viewportWidth
|
scale: viewportHeight / viewportWidth
|
||||||
});
|
});
|
||||||
|
|
||||||
// var view = camera.view(); // get the camera matrix
|
this.setState({camera})
|
||||||
// var projection = mat4.perspective(
|
|
||||||
// [],
|
|
||||||
// Math.PI / 2,
|
|
||||||
// context.viewportWidth * props.scale / context.viewportHeight,
|
|
||||||
// 0.01,
|
|
||||||
// 1000
|
|
||||||
// ); // get the projection matrix
|
|
||||||
// var combined = mat.multiply([], projection, view); // this is the matrix applied to the transform
|
|
||||||
// this.inverse = mat.invert([], combined); // this is the inverse
|
|
||||||
|
|
||||||
camera.tick();
|
camera.tick();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -170,15 +160,22 @@ class Graph extends React.Component {
|
|||||||
| |
|
| |
|
||||||
|-------@
|
|-------@
|
||||||
*/
|
*/
|
||||||
const brushCoords = {
|
|
||||||
northwestX: s[0][0],
|
// compute inverse view matrix
|
||||||
northwestY: s[0][1],
|
const inverse = mat4.invert([], this.state.camera.view());
|
||||||
southeastX: s[1][0],
|
|
||||||
southeastY: s[1][1]
|
// transform screen coordinates -> cell coordinates
|
||||||
|
const invert = (pin) => {
|
||||||
|
const x = 2 * pin[0] / globals.graphWidth - 1;
|
||||||
|
const y = 2 * (1 - pin[1] / globals.graphHeight) - 1;
|
||||||
|
const pout = [x + inverse[12], y + inverse[13]];
|
||||||
|
return [(pout[0] + 1) / 2, (pout[1] + 1) / 2];
|
||||||
};
|
};
|
||||||
|
|
||||||
brushCoords.dx = brushCoords.southeastX - brushCoords.northwestX;
|
const brushCoords = {
|
||||||
brushCoords.dy = brushCoords.southeastY - brushCoords.northwestY;
|
northwest: invert([s[0][0], s[0][1]]),
|
||||||
|
southeast: invert([s[1][0], s[1][1]])
|
||||||
|
};
|
||||||
|
|
||||||
this.props.dispatch({
|
this.props.dispatch({
|
||||||
type: "graph brush selection change",
|
type: "graph brush selection change",
|
||||||
|
|||||||
+2
-22
@@ -47,8 +47,8 @@ export const bolder = 700;
|
|||||||
|
|
||||||
export let API = {
|
export let API = {
|
||||||
// prefix: "http://api.clustering.czi.technology/api/",
|
// prefix: "http://api.clustering.czi.technology/api/",
|
||||||
prefix: "http://tabulamuris.cxg.czi.technology/api/",
|
//prefix: "http://tabulamuris.cxg.czi.technology/api/",
|
||||||
// prefix: "http://pbmc3k.cxg.czi.technology/api/",
|
prefix: "http://pbmc3k.cxg.czi.technology/api/",
|
||||||
// prefix: "http://pbmc33k.cxg.czi.technology/api/",
|
// prefix: "http://pbmc33k.cxg.czi.technology/api/",
|
||||||
|
|
||||||
// prefix: "http://api-staging.clustering.czi.technology/api/",
|
// prefix: "http://api-staging.clustering.czi.technology/api/",
|
||||||
@@ -72,26 +72,6 @@ export const graphMargin = { top: 20, right: 10, bottom: 30, left: 40 };
|
|||||||
export const graphWidth = 700;
|
export const graphWidth = 700;
|
||||||
export const graphHeight = 700;
|
export const graphHeight = 700;
|
||||||
|
|
||||||
import { scaleLinear } from "./util/scaleLinear";
|
|
||||||
// d3.scaleLinear().domain([0,1]).range([0 + graphMargin.left, graphWidth - graphMargin.right])
|
|
||||||
export const graphXScale = scaleLinear(
|
|
||||||
[0, 1],
|
|
||||||
[0 + graphMargin.left, graphWidth - graphMargin.right]
|
|
||||||
);
|
|
||||||
graphXScale.invert = scaleLinear(
|
|
||||||
[0 + graphMargin.left, graphWidth - graphMargin.right],
|
|
||||||
[0, 1]
|
|
||||||
);
|
|
||||||
// d3.scaleLinear().domain([0,1]).range([graphHeight - graphMargin.bottom, 0 + graphMargin.top])
|
|
||||||
export const graphYScale = scaleLinear(
|
|
||||||
[0, 1],
|
|
||||||
[graphHeight - graphMargin.bottom, 0 + graphMargin.top]
|
|
||||||
);
|
|
||||||
graphYScale.invert = scaleLinear(
|
|
||||||
[graphHeight - graphMargin.bottom, 0 + graphMargin.top],
|
|
||||||
[0, 1]
|
|
||||||
);
|
|
||||||
|
|
||||||
export const ordinalColors = [
|
export const ordinalColors = [
|
||||||
"#0ac115",
|
"#0ac115",
|
||||||
"#c10ab6",
|
"#c10ab6",
|
||||||
|
|||||||
@@ -73,19 +73,6 @@ const updateCellSelectionMiddleware = store => {
|
|||||||
? action.brushCoords
|
? action.brushCoords
|
||||||
: s.controls.graphBrushSelection;
|
: s.controls.graphBrushSelection;
|
||||||
|
|
||||||
const northwestX = globals.graphXScale.invert(
|
|
||||||
graphBrushSelection.northwestX
|
|
||||||
);
|
|
||||||
const southeastX = globals.graphXScale.invert(
|
|
||||||
graphBrushSelection.southeastX
|
|
||||||
);
|
|
||||||
const northwestY = globals.graphYScale.invert(
|
|
||||||
graphBrushSelection.northwestY
|
|
||||||
);
|
|
||||||
const southeastY = globals.graphYScale.invert(
|
|
||||||
graphBrushSelection.southeastY
|
|
||||||
);
|
|
||||||
|
|
||||||
const graphVec = s.controls.graphVec;
|
const graphVec = s.controls.graphVec;
|
||||||
for (let i = 0; i < newSelection.length; i++) {
|
for (let i = 0; i < newSelection.length; i++) {
|
||||||
const cell = newSelection[i];
|
const cell = newSelection[i];
|
||||||
@@ -94,10 +81,10 @@ const updateCellSelectionMiddleware = store => {
|
|||||||
const y = graphVec[2 * cellId + 1];
|
const y = graphVec[2 * cellId + 1];
|
||||||
|
|
||||||
const pointIsInsideBrushBounds =
|
const pointIsInsideBrushBounds =
|
||||||
x >= northwestX &&
|
x >= graphBrushSelection.northwest[0] &&
|
||||||
x <= southeastX &&
|
x <= graphBrushSelection.southeast[0] &&
|
||||||
y <= northwestY &&
|
y <= graphBrushSelection.northwest[1] &&
|
||||||
y >= southeastY;
|
y >= graphBrushSelection.southeast[1];
|
||||||
|
|
||||||
if (!pointIsInsideBrushBounds) {
|
if (!pointIsInsideBrushBounds) {
|
||||||
cell.__selected__ = false;
|
cell.__selected__ = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user