Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed bug where pointSize was wrong #151

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@
const removeTracksUponNewData = () => {
dispatchCanvas({ type: ActionType.REMOVE_ALL_TRACKS });
};
const resetCamera = () => {
const actionsUponNewData = () => {
dispatchCanvas({ type: ActionType.RESET_CAMERA });
dispatchCanvas({ type: ActionType.RESET_POINT_SIZE });
};

// this function fetches the entire lineage for each track
Expand Down Expand Up @@ -180,7 +181,6 @@

// update the array when the dataUrl changes
useEffect(() => {
console.log("load data from %s", dataUrl);
const trackManager = loadTrackManager(dataUrl);
// TODO: add clean-up by returning another closure
trackManager.then((tm: TrackManager | null) => {
Expand Down Expand Up @@ -275,7 +275,7 @@
}

// TODO: add missing dependencies
}, [trackManager, dispatchCanvas, canvas.selectedPointIds]);

Check warning on line 278 in src/components/App.tsx

View workflow job for this annotation

GitHub Actions / lint-and-test

React Hook useEffect has missing dependencies: 'canvas.fetchedPointIds' and 'updateTracks'. Either include them or remove the dependency array

// playback time points
// TODO: this is basic and may drop frames
Expand Down Expand Up @@ -468,7 +468,7 @@
initialDataUrl={initialViewerState.dataUrl}
setDataUrl={setDataUrl}
removeTracksUponNewData={removeTracksUponNewData}
resetCamera={resetCamera}
actionsUponNewData={actionsUponNewData}
copyShareableUrlToClipboard={copyShareableUrlToClipboard}
refreshPage={refreshPage}
trackManager={trackManager}
Expand Down
8 changes: 4 additions & 4 deletions src/components/DataControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface DataControlsProps {
copyShareableUrlToClipboard: () => void;
refreshPage: () => void;
removeTracksUponNewData: () => void;
resetCamera: () => void;
actionsUponNewData: () => void;
trackManager: TrackManager | null;
}

Expand Down Expand Up @@ -53,21 +53,21 @@ export default function DataControls(props: DataControlsProps) {

const setDataUrl = props.setDataUrl;
const removeTracksUponNewData = props.removeTracksUponNewData;
const resetCamera = props.resetCamera;
const actionsUponNewData = props.actionsUponNewData;
const handleDataUrlSubmit = useCallback(
(event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
const urlInput = document.getElementById("data-url-input") as HTMLInputElement;
if (urlInput && urlInput.value) {
setDataUrl(urlInput.value);
removeTracksUponNewData();
resetCamera();
actionsUponNewData();
} else {
// set to the initial URL if the input is empty or can't be found
setDataUrl(props.initialDataUrl);
}
},
[props.initialDataUrl, setDataUrl, removeTracksUponNewData, resetCamera],
[props.initialDataUrl, setDataUrl, removeTracksUponNewData, actionsUponNewData],
);

// only close the popover if the URL gives a valid track manager
Expand Down
9 changes: 9 additions & 0 deletions src/hooks/usePointCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum ActionType {
CUR_TIME = "CUR_TIME",
CHECK_CAMERA_LOCK = "CHECK_CAMERA_LOCK",
RESET_CAMERA = "RESET_CAMERA",
RESET_POINT_SIZE = "RESET_POINT_SIZE",
INIT_POINTS_GEOMETRY = "INIT_POINTS_GEOMETRY",
TRACK_WIDTH = "TRACK_WIDTH",
POINT_BRIGHTNESS = "POINT_BRIGHTNESS",
Expand Down Expand Up @@ -50,6 +51,10 @@ interface ResetCamera {
type: ActionType.RESET_CAMERA;
}

interface ResetPointSize {
type: ActionType.RESET_POINT_SIZE;
}

interface InitPointsGeometry {
type: ActionType.INIT_POINTS_GEOMETRY;
maxPointsPerTimepoint: number;
Expand Down Expand Up @@ -153,6 +158,7 @@ type PointCanvasAction =
| CurTime
| CheckCameraLock
| ResetCamera
| ResetPointSize
| InitPointsGeometry
| TrackWidth
| PointBrightness
Expand Down Expand Up @@ -186,6 +192,9 @@ function reducer(canvas: PointCanvas, action: PointCanvasAction): PointCanvas {
case ActionType.RESET_CAMERA:
newCanvas.resetCamera();
break;
case ActionType.RESET_POINT_SIZE:
newCanvas.resetPointSize();
break;
case ActionType.CUR_TIME: {
// if curTime is a function, call it with the current time
if (typeof action.curTime === "function") {
Expand Down
6 changes: 6 additions & 0 deletions src/lib/PointCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ export class PointCanvas {
this.camera.position.set(cameraPosition[0], cameraPosition[1], cameraPosition[2]);
this.controls.target.set(cameraTarget[0], cameraTarget[1], cameraTarget[2]);
this.curTime = 0;
console.debug("Camera resetted");
}

resetPointSize() {
this.pointSize = initialPointSize;
console.debug("point size resetted to: ", this.pointSize);
}

updateSelectedPointIndices() {
Expand Down
Loading