diff --git a/client/src/components/embedding/index.js b/client/src/components/embedding/index.js
index a36d3256..7522017a 100644
--- a/client/src/components/embedding/index.js
+++ b/client/src/components/embedding/index.js
@@ -16,10 +16,11 @@ import actions from "../../actions";
import { getDiscreteCellEmbeddingRowIndex } from "../../util/stateManager/viewStackHelpers";
@connect((state) => ({
- layoutChoice: state.layoutChoice, // TODO: really should clean up naming, s/layout/embedding/g
- schema: state.annoMatrix?.schema,
- crossfilter: state.obsCrossfilter,
- }))
+ imageUnderlay: state.imageUnderlay,
+ layoutChoice: state.layoutChoice, // TODO: really should clean up naming, s/layout/embedding/g
+ schema: state.annoMatrix?.schema,
+ crossfilter: state.obsCrossfilter,
+}))
class Embedding extends React.PureComponent {
constructor(props) {
super(props);
@@ -27,8 +28,18 @@ class Embedding extends React.PureComponent {
}
handleLayoutChoiceChange = (e) => {
- const { dispatch } = this.props;
+ const { dispatch, imageUnderlay } = this.props;
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() {
diff --git a/client/src/components/menubar/index.js b/client/src/components/menubar/index.js
index 03b41659..37ac57c5 100644
--- a/client/src/components/menubar/index.js
+++ b/client/src/components/menubar/index.js
@@ -28,6 +28,8 @@ import { getEmbSubsetView } from "../../util/stateManager/viewStackHelpers";
subsetPossible,
subsetResetPossible,
graphInteractionMode: state.controls.graphInteractionMode,
+ imageUnderlay: state.imageUnderlay,
+ layoutChoice: state.layoutChoice, // TODO: really should clean up naming, s/layout/embedding/g
clipPercentileMin: Math.round(100 * (annoMatrix?.clipRange?.[0] ?? 0)),
clipPercentileMax: Math.round(100 * (annoMatrix?.clipRange?.[1] ?? 1)),
userDefinedGenes: state.controls.userDefinedGenes,
@@ -206,6 +208,8 @@ class MenuBar extends React.PureComponent {
colorAccessor,
subsetPossible,
subsetResetPossible,
+ imageUnderlay,
+ layoutChoice,
} = this.props;
const { pendingClipPercentiles } = this.state;
@@ -268,6 +272,29 @@ class MenuBar extends React.PureComponent {
disabled={!isColoredByCategorical}
/>
+ {layoutChoice?.available?.includes(globals.spatialEmbeddingKeyword) && (
+
+
+ {
+ dispatch({
+ type: "toggle image underlay",
+ });
+ }}
+ />
+
+
+ )}
+
{
+ switch (action.type) {
+ case "toggle image underlay":
+ return {
+ ...state,
+ isActive: !state.isActive,
+ };
+
+ default:
+ return state;
+ }
+};
+
+export default imageUnderlay;
diff --git a/client/src/reducers/index.js b/client/src/reducers/index.js
index 05da1b88..a940329c 100644
--- a/client/src/reducers/index.js
+++ b/client/src/reducers/index.js
@@ -20,6 +20,7 @@ import genesetsUI from "./genesetsUI";
import autosave from "./autosave";
import centroidLabels from "./centroidLabels";
import pointDialation from "./pointDilation";
+import imageUnderlay from "./imageUnderlay";
import { gcMiddleware as annoMatrixGC } from "../annoMatrix";
import undoableConfig from "./undoableConfig";
@@ -41,6 +42,7 @@ const Reducer = undoable(
["differential", differential],
["spatial", spatial],
["centroidLabels", centroidLabels],
+ ["imageUnderlay", imageUnderlay],
["pointDilation", pointDialation],
["autosave", autosave],
]),