Skip to content

Commit

Permalink
CELE-107 Fix color change on EM viewer neuron click
Browse files Browse the repository at this point in the history
  • Loading branch information
dvcorreia committed Oct 30, 2024
1 parent 9697279 commit 1882a6a
Showing 1 changed file with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box } from "@mui/material";
import "ol/ol.css";
import { Feature, Map as OLMap, View } from "ol";
import { Feature, MapBrowserEvent, Map as OLMap, View } from "ol";
import ScaleLine from "ol/control/ScaleLine";
import { shiftKeyOnly } from "ol/events/condition";
import { getCenter } from "ol/extent";
Expand Down Expand Up @@ -185,6 +185,26 @@ const EMStackViewer = () => {
[currentWorkspace],
);

const onClick = useCallback(
(evt: MapBrowserEvent<any>) => {
if (!currSegLayer.current) return;

const features = currSegLayer.current.getSource().getFeaturesAtCoordinate(evt.coordinate);
if (features.length === 0) return;

const feature = features[0];
if (feature) {
onSelectNeuron(feature);
}
},
[onSelectNeuron],
);

useEffect(() => {
if (!mapRef.current) return;
mapRef.current.on("click", onClick);
}, [onClick]);

useEffect(() => {
if (mapRef.current) {
return;
Expand Down Expand Up @@ -248,18 +268,7 @@ const EMStackViewer = () => {
});

refreshNeuronProperties();

map.on("click", (evt) => {
if (!currSegLayer.current) return;

const features = currSegLayer.current.getSource().getFeaturesAtCoordinate(evt.coordinate);
if (features.length === 0) return;

const feature = features[0];
if (feature) {
onSelectNeuron(feature);
}
});
map.on("click", onClick);

function handleSliceScroll(e: WheelEvent) {
const scrollUp = e.deltaY < 0;
Expand Down

0 comments on commit 1882a6a

Please sign in to comment.