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

Allow to make a layer exclusively visible by pressing ctrl when changing visibility #4061

Merged
merged 5 commits into from
May 8, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
### Added
- BossDB datasets can now be added to webKnossos using the webknossos-connect service. [#4036](https://github.com/scalableminds/webknossos/pull/4036)
- Added an auto-brush feature for selected datasets. [#4053](https://github.com/scalableminds/webknossos/pull/4053)
- When holding CTRL while toggling the visibility of a layer, that layer will be made exclusively visible. This change makes it easier to quickly compare different data layers against each other. [#4061](https://github.com/scalableminds/webknossos/pull/4061)

### Changed
- The NML parser now rounds floating point values in node coordinates. [#4045](https://github.com/scalableminds/webknossos/pull/4045)
Expand Down
2 changes: 1 addition & 1 deletion docs/tracing_ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ For multi-layer datasets, each layer can be adjusted separately.
- `Contrast`: Increase / Decrease the contrast of the data layer.
- `Opacity`: Increase / Decrease the opacity of the data layer.
- `Color`: Every data layer can be colored to make them easily identifiable. By default, all layers have a white overlay, showing the true, raw black & white data.
- `Visibility`: Use the eye icon on the right side of the name of the data layer to enable/disable this layer.
- `Visibility`: Use the eye icon on the right side of the name of the data layer to enable/disable this layer. If you hold CTRL while toggling the visibility of a layer, that layer will be made exclusively visible.

#### Segmentation
- `Segmentation Opacity`: Increases / Decreases the opacity of the segmentation layer. A low value will make the segmentation almost transparent letting you see the underlying data layers more clearly. A high value will make the segmentation opaque which is useful for adjusting and reviewing the exact fit of the segmentation layer. Only possible if your dataset has a segmentation layer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps> {
</Tooltip>
);

setVisibilityForAllLayers = (isVisible: boolean) => {
const { layers } = this.props.datasetConfiguration;
Object.keys(layers).forEach(otherLayerName =>
this.props.onChangeLayer(otherLayerName, "isDisabled", !isVisible),
);
};

isLayerExclusivelyVisible = (layerName: string): boolean => {
const { layers } = this.props.datasetConfiguration;
return Object.keys(layers).every(otherLayerName => {
const { isDisabled } = layers[otherLayerName];
return layerName === otherLayerName ? !isDisabled : isDisabled;
});
};

getColorSettings = (
[layerName, layer]: [string, DatasetLayerConfiguration],
layerIndex: number,
Expand All @@ -96,7 +111,20 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps> {
<div style={{ display: "inline-block", marginRight: 8 }}>
<Switch
size="small"
onChange={val => this.props.onChangeLayer(layerName, "isDisabled", !val)}
onChange={(val, event) => {
if (!event.ctrlKey) {
this.props.onChangeLayer(layerName, "isDisabled", !val);
return;
}
// If ctrl is pressed, toggle between "all layers visible" and
// "only selected layer visible".
if (this.isLayerExclusivelyVisible(layerName)) {
this.setVisibilityForAllLayers(true);
} else {
this.setVisibilityForAllLayers(false);
this.props.onChangeLayer(layerName, "isDisabled", false);
}
}}
checked={!isDisabled}
/>
</div>
Expand Down