Skip to content

Commit

Permalink
Prevent mag warning from showing in 3D viewport (#6412)
Browse files Browse the repository at this point in the history
* fixed warning toast whn in fullscreen 3D viewport

* updated changelog

* fix CI

* apply pr feedback

* linting
  • Loading branch information
hotzenklotz authored Aug 23, 2022
1 parent 675f7ef commit fedc337
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed a regression which caused that uint16 and uint8 segmentations could not be rendered. [#6406](https://github.com/scalableminds/webknossos/pull/6406)
- Fixed a bug which prevented keyboard shortcuts from taking affect after expanding/collapsing the sidebar panels using the button icons.[#6410](https://github.com/scalableminds/webknossos/pull/6410)
- Fixed a bug with the clip histogram button to prevent it from showing a loading spinner forever in some cases. [#6407](https://github.com/scalableminds/webknossos/pull/6407)
- Fixed an issue whereby a warning toast would be triggered every time the 3D viewport is put into fullscreen mode. [#6412](https://github.com/scalableminds/webknossos/pull/6412)



### Removed
Expand Down
20 changes: 16 additions & 4 deletions frontend/javascripts/oxalis/model/sagas/dataset_saga.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { call, take, takeEvery, takeLatest } from "typed-redux-saga";
import { sum } from "lodash";
import type { Saga } from "oxalis/model/sagas/effect-generators";
import { select } from "oxalis/model/sagas/effect-generators";
import { call, take, takeEvery, takeLatest } 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 { getEnabledLayers } from "../accessors/dataset_accessor";
import { getCurrentResolution } from "../accessors/flycam_accessor";
import { getViewportExtents } from "../accessors/view_mode_accessor";

export function* watchMaximumRenderableLayers(): Saga<void> {
function* warnMaybe(): Saga<void> {
const maximumLayerCountToRender = yield* select(
Expand Down Expand Up @@ -50,9 +54,17 @@ export function* watchZ1Downsampling(): Saga<void> {
const minVoxelPerPixel = 0.1;
if (!userClosedWarning) {
// checking only the downsampled dimensions x and y
const extents = yield* select((state) => getViewportExtents(state));
const areas = [extents.PLANE_XY, extents.PLANE_YZ, extents.PLANE_XZ].map(
([width, height]) => width * height,
);
const areDataviewportsInvisible = sum(areas) === 0;

const showWarning =
currentZoomStep / currentRes[0] < minVoxelPerPixel ||
currentZoomStep / currentRes[1] < minVoxelPerPixel;
(currentZoomStep / currentRes[0] < minVoxelPerPixel ||
currentZoomStep / currentRes[1] < minVoxelPerPixel) &&
!areDataviewportsInvisible;

if (showWarning) {
Toast.warning(messages["dataset.z1_downsampling_hint"], {
sticky: true,
Expand Down

0 comments on commit fedc337

Please sign in to comment.