Skip to content

Commit

Permalink
Fix segmentation opacity in recommended tasktype (#4545)
Browse files Browse the repository at this point in the history
* restore segmentationOpacity functionality as part of recommended task configuration
* clean up
* update changelog
* clean up
* Update frontend/javascripts/admin/tasktype/recommended_configuration_view.js

Co-Authored-By: Daniel <[email protected]>
  • Loading branch information
philippotto and daniel-wer authored Apr 14, 2020
1 parent 994bc0c commit 39e03a3
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
- Fixed the import of datasets which was temporarily broken. [#4497](https://github.com/scalableminds/webknossos/pull/4497)
- Fixed the displayed segment ids in segmentation tab when "Render Missing Data Black" is turned off. [#4480](https://github.com/scalableminds/webknossos/pull/4480)
- The datastore checks if a organization folder can be created before creating a new organization. [#4501](https://github.com/scalableminds/webknossos/pull/4501)
- Fixed that `segmentationOpacity` could not be set anymore as part of the recommended settings for a task type. [#4545](https://github.com/scalableminds/webknossos/pull/4545)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const recommendedConfigByCategory = {
dataset: {
fourBit: false,
interpolation: true,
segmentationOpacity: 0,
highlightHoveredCellId: false,
zoom: 0.8,
renderMissingDataBlack: false,
Expand All @@ -51,6 +52,7 @@ const recommendedConfigByCategory = {
export const DEFAULT_RECOMMENDED_CONFIGURATION: $Shape<{|
...UserConfiguration,
...DatasetConfiguration,
segmentationOpacity: number,
|}> = {
...recommendedConfigByCategory.orthogonal,
...recommendedConfigByCategory.all,
Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/libs/user_settings.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const userSettings = {
fourBit: { type: "boolean" },
interpolation: { type: "boolean" },
loadingStrategy: { enum: ["BEST_QUALITY_FIRST", "PROGRESSIVE_QUALITY"] },
segmentationOpacity: { type: "number", minimum: 0, maximum: 100 },
highlightHoveredCellId: { type: "boolean" },
zoom: { type: "number", minimum: 0.005 },
renderMissingDataBlack: { type: "boolean" },
Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const settings = {
fourBit: "4 Bit",
interpolation: "Interpolation",
quality: "Quality",
segmentationOpacity: "Segmentation Opacity",
highlightHoveredCellId: "Highlight Hovered Cells",
zoom: "Zoom",
renderMissingDataBlack: "Render Missing Data Black",
Expand Down
8 changes: 0 additions & 8 deletions frontend/javascripts/oxalis/geometries/plane.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,6 @@ class Plane {
this.crosshair[1].visible = visible && this.displayCrosshair;
};

setSegmentationAlpha(alpha: number): void {
this.plane.material.setSegmentationAlpha(alpha);
}

setSegmentationVisibility(isVisible: boolean): void {
this.plane.material.setSegmentationVisibility(isVisible);
}

getMeshes = () => [this.plane, this.TDViewBorders, this.crosshair[0], this.crosshair[1]];

setLinearInterpolationEnabled = (enabled: boolean) => {
Expand Down
16 changes: 16 additions & 0 deletions frontend/javascripts/oxalis/model/sagas/task_saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { setZoomStepAction } from "oxalis/model/actions/flycam_actions";
import {
updateDatasetSettingAction,
updateUserSettingAction,
updateLayerSettingAction,
} from "oxalis/model/actions/settings_actions";
import { setActiveUserAction } from "oxalis/model/actions/user_actions";
import { setMergerModeEnabledAction } from "oxalis/model/actions/skeletontracing_actions";
Expand All @@ -17,6 +18,7 @@ import RecommendedConfigurationModal from "oxalis/view/recommended_configuration
import Toast from "libs/toast";
import messages from "messages";
import renderIndependently from "libs/render_independently";
import Model from "oxalis/model";

function* maybeShowNewTaskTypeModal(taskType: APITaskType): Saga<void> {
// Users can acquire new tasks directly in the tracing view. Occasionally,
Expand All @@ -41,11 +43,16 @@ function* maybeShowRecommendedConfiguration(taskType: APITaskType): Saga<void> {
const userConfiguration = yield* select(state => state.userConfiguration);
const datasetConfiguration = yield* select(state => state.datasetConfiguration);
const zoomStep = yield* select(state => state.flycam.zoomStep);
const segmentationLayerName = yield* call([Model, Model.getSegmentationLayerName]);
const segmentationOpacity =
segmentationLayerName != null ? datasetConfiguration.layers[segmentationLayerName].alpha : 0;

// $FlowFixMe Cannot call `_.find` because number [1] is incompatible with boolean [2] in property `brushSize` of type argument `T`.
const configurationDifference = _.find(recommendedConfiguration, (value, key: string) => {
if (key === "zoom" && zoomStep !== value) {
return true;
} else if (key === "segmentationOpacity" && segmentationOpacity !== value) {
return true;
} else if (key in userConfiguration && userConfiguration[key] !== value) {
return true;
} else if (key in datasetConfiguration && datasetConfiguration[key] !== value) {
Expand All @@ -72,12 +79,21 @@ function* maybeShowRecommendedConfiguration(taskType: APITaskType): Saga<void> {
for (const key of Object.keys(recommendedConfiguration)) {
if (key === "zoom") {
yield* put(setZoomStepAction(recommendedConfiguration[key]));
} else if (key === "segmentationOpacity" && segmentationLayerName != null) {
yield* put(
updateLayerSettingAction(segmentationLayerName, "alpha", recommendedConfiguration[key]),
);
} else if (key in userConfiguration) {
// $FlowFixMe Cannot call updateUserSettingAction with key bound to propertyName because an indexer property is missing in UserConfiguration
yield* put(updateUserSettingAction(key, recommendedConfiguration[key]));
} else if (key in datasetConfiguration) {
// $FlowFixMe Cannot call updateDatasetSettingAction with key bound to propertyName because an indexer property is missing in DatasetConfiguration
yield* put(updateDatasetSettingAction(key, recommendedConfiguration[key]));
} else {
console.warn(
// $FlowIgnore
`Cannot apply recommended default for key/value: ${key}/${recommendedConfiguration[key]}`,
);
}
}
Toast.success("You are using the recommended settings now.");
Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/oxalis/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export type RecommendedConfiguration = $Shape<{
...UserConfiguration,
...DatasetConfiguration,
zoom: number,
segmentationOpacity: number,
}>;

export type Mapping = { [key: number]: number };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ export default class NewTaskDescriptionModal extends React.Component<Props, Stat
};

componentDidMount() {
this.timeoutId = setTimeout(() => {
this.allowClose();
}, 10000);
this.timeoutId = setTimeout(
() => {
this.allowClose();
},
process.env.NODE_ENV === "production" ? 10000 : 2000,
);
}

componentWillUnmount() {
Expand Down

0 comments on commit 39e03a3

Please sign in to comment.