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

Display warning when resolution gets too low during zooming #6255

Merged
merged 8 commits into from
Jun 2, 2022
2 changes: 2 additions & 0 deletions frontend/javascripts/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ instead. Only enable this option if you understand its effect. All layers will n
"This dataset location is marked as 'scratch' and meant for testing only. Please move this dataset to a permanent storage location and reimport it.",
"dataset.resolution_mismatch":
"This dataset contains multiple layers which differ in their resolution. Please convert the layers to make their resolutions match. Otherwise, rendering errors cannot be avoided.",
"dataset.z1_downsampling_hint":
"The currently rendered quality is not optimal due to the available magnifications and the viewport arrangement. To improve the quality try to increase the size of the XY viewport (e.g., by maximizing it).",
"annotation.finish": "Are you sure you want to permanently finish this annotation?",
"annotation.was_finished": "Annotation was archived",
"annotation.no_fallback_data_included":
Expand Down
31 changes: 29 additions & 2 deletions frontend/javascripts/oxalis/model/sagas/dataset_saga.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* eslint-disable import/prefer-default-export */
import type { Saga } from "oxalis/model/sagas/effect-generators";
import { select } from "oxalis/model/sagas/effect-generators";
import { takeEvery } from "typed-redux-saga";
import { call, takeEvery } from "typed-redux-saga";
import { sleep } from "libs/utils";
import { getEnabledLayers } from "oxalis/model/accessors/dataset_accessor";
import Toast from "libs/toast";
import messages from "messages";
import { getCurrentResolution } from "../accessors/flycam_accessor";
export function* watchMaximumRenderableLayers(): Saga<void> {
function* warnMaybe(): Saga<void> {
const maximumLayerCountToRender = yield* select(
Expand All @@ -31,3 +32,29 @@ export function* watchMaximumRenderableLayers(): Saga<void> {

yield* takeEvery(["WK_READY", "UPDATE_LAYER_SETTING", "UPDATE_DATASET_SETTING"], warnMaybe);
}

let downsamplingWarningDidShow = false;
export function* watchZ1Downsampling(): Saga<void> {
function* maybeShowWarning(): Saga<void> {
const currentRes = yield* select((state) => getCurrentResolution(state));
const currentZoomStep = yield* select((state) => state.flycam.zoomStep);
Dagobert42 marked this conversation as resolved.
Show resolved Hide resolved
const minVoxelPerPixel = 0.5;
Dagobert42 marked this conversation as resolved.
Show resolved Hide resolved

if (!downsamplingWarningDidShow) {
// checking the downsampled dimensions x and y
for (let i = 0; i < 2; i++) {
const voxelPerPixelXY = currentZoomStep / currentRes[i];
if (voxelPerPixelXY < minVoxelPerPixel) {
Toast.warning(messages["dataset.z1_downsampling_hint"]);
Dagobert42 marked this conversation as resolved.
Show resolved Hide resolved
downsamplingWarningDidShow = false;
Dagobert42 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}
yield* takeEvery("WK_READY", maybeShowWarning);
yield* call(sleep, 2000);
Dagobert42 marked this conversation as resolved.
Show resolved Hide resolved
yield* takeEvery(
["ZOOM_IN", "ZOOM_OUT", "ZOOM_BY_DELTA", "SET_ZOOM_STEP", "SET_STORED_LAYOUTS"],
maybeShowWarning,
);
}
3 changes: 2 additions & 1 deletion frontend/javascripts/oxalis/model/sagas/root_saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SkeletontracingSagas from "oxalis/model/sagas/skeletontracing_saga";
import ErrorHandling from "libs/error_handling";
import handleMeshChanges from "oxalis/model/sagas/handle_mesh_changes";
import isosurfaceSaga from "oxalis/model/sagas/isosurface_saga";
import { watchMaximumRenderableLayers } from "oxalis/model/sagas/dataset_saga";
import { watchMaximumRenderableLayers, watchZ1Downsampling } from "oxalis/model/sagas/dataset_saga";
import { watchToolDeselection } from "oxalis/model/sagas/annotation_tool_saga";
import SettingsSaga from "oxalis/model/sagas/settings_saga";
import watchTasksAsync, { warnAboutMagRestriction } from "oxalis/model/sagas/task_saga";
Expand Down Expand Up @@ -47,6 +47,7 @@ function* restartableSaga(): Saga<void> {
...AnnotationSagas.map((saga) => call(saga)),
...SaveSagas.map((saga) => call(saga)),
...VolumetracingSagas.map((saga) => call(saga)),
call(watchZ1Downsampling),
]);
} catch (err) {
rootSagaCrashed = true;
Expand Down