auto switch spatial off

This commit is contained in:
Colin Megill
2021-12-07 16:32:55 -08:00
parent caa1526eb6
commit b411fca5a3
3 changed files with 43 additions and 25 deletions
+16 -5
View File
@@ -16,10 +16,11 @@ import actions from "../../actions";
import { getDiscreteCellEmbeddingRowIndex } from "../../util/stateManager/viewStackHelpers"; import { getDiscreteCellEmbeddingRowIndex } from "../../util/stateManager/viewStackHelpers";
@connect((state) => ({ @connect((state) => ({
layoutChoice: state.layoutChoice, // TODO: really should clean up naming, s/layout/embedding/g imageUnderlay: state.imageUnderlay,
schema: state.annoMatrix?.schema, layoutChoice: state.layoutChoice, // TODO: really should clean up naming, s/layout/embedding/g
crossfilter: state.obsCrossfilter, schema: state.annoMatrix?.schema,
})) crossfilter: state.obsCrossfilter,
}))
class Embedding extends React.PureComponent { class Embedding extends React.PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -27,8 +28,18 @@ class Embedding extends React.PureComponent {
} }
handleLayoutChoiceChange = (e) => { handleLayoutChoiceChange = (e) => {
const { dispatch } = this.props; const { dispatch, imageUnderlay } = this.props;
dispatch(actions.layoutChoiceAction(e.currentTarget.value)); dispatch(actions.layoutChoiceAction(e.currentTarget.value));
// if we just switched off spatial, if the image is on, turn it off
if (
imageUnderlay.isActive &&
e.target.value !== globals.spatialEmbeddingKeyword
) {
dispatch({
type: "toggle image underlay",
});
}
}; };
render() { render() {
+24 -20
View File
@@ -29,6 +29,7 @@ import { getEmbSubsetView } from "../../util/stateManager/viewStackHelpers";
subsetResetPossible, subsetResetPossible,
graphInteractionMode: state.controls.graphInteractionMode, graphInteractionMode: state.controls.graphInteractionMode,
imageUnderlay: state.imageUnderlay, imageUnderlay: state.imageUnderlay,
layoutChoice: state.layoutChoice, // TODO: really should clean up naming, s/layout/embedding/g
clipPercentileMin: Math.round(100 * (annoMatrix?.clipRange?.[0] ?? 0)), clipPercentileMin: Math.round(100 * (annoMatrix?.clipRange?.[0] ?? 0)),
clipPercentileMax: Math.round(100 * (annoMatrix?.clipRange?.[1] ?? 1)), clipPercentileMax: Math.round(100 * (annoMatrix?.clipRange?.[1] ?? 1)),
userDefinedGenes: state.controls.userDefinedGenes, userDefinedGenes: state.controls.userDefinedGenes,
@@ -208,6 +209,7 @@ class MenuBar extends React.PureComponent {
subsetPossible, subsetPossible,
subsetResetPossible, subsetResetPossible,
imageUnderlay, imageUnderlay,
layoutChoice,
} = this.props; } = this.props;
const { pendingClipPercentiles } = this.state; const { pendingClipPercentiles } = this.state;
@@ -270,26 +272,28 @@ class MenuBar extends React.PureComponent {
disabled={!isColoredByCategorical} disabled={!isColoredByCategorical}
/> />
</Tooltip> </Tooltip>
<ButtonGroup className={styles.menubarButton}> {layoutChoice?.available?.includes(globals.spatialEmbeddingKeyword) && (
<Tooltip <ButtonGroup className={styles.menubarButton}>
content={"Toggle image"} <Tooltip
position="bottom" content={"Toggle image"}
hoverOpenDelay={globals.tooltipHoverOpenDelay} position="bottom"
> hoverOpenDelay={globals.tooltipHoverOpenDelay}
<AnchorButton >
type="button" <AnchorButton
data-testid="toggle-image-underlay" type="button"
icon={"media"} data-testid="toggle-image-underlay"
intent={imageUnderlay.isActive ? "primary" : "none"} icon={"media"}
active={imageUnderlay.isActive} intent={imageUnderlay.isActive ? "primary" : "none"}
onClick={() => { active={imageUnderlay.isActive}
dispatch({ onClick={() => {
type: "toggle image underlay", dispatch({
}); type: "toggle image underlay",
}} });
/> }}
</Tooltip> />
</ButtonGroup> </Tooltip>
</ButtonGroup>
)}
<ButtonGroup className={styles.menubarButton}> <ButtonGroup className={styles.menubarButton}>
<Tooltip <Tooltip
+3
View File
@@ -2,6 +2,9 @@ import { Colors } from "@blueprintjs/core";
import { dispatchNetworkErrorMessageToUser } from "./util/actionHelpers"; import { dispatchNetworkErrorMessageToUser } from "./util/actionHelpers";
import ENV_DEFAULT from "../../environment.default.json"; import ENV_DEFAULT from "../../environment.default.json";
// visium embedding word, spatial image underlay
export const spatialEmbeddingKeyword = "spatial";
/* overflow category values are created using this string */ /* overflow category values are created using this string */
export const overflowCategoryLabel = ": all other labels"; export const overflowCategoryLabel = ": all other labels";