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

Add toggle color layer visibility button #3943

Merged
merged 12 commits into from
Mar 29, 2019
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class DatasetImportView extends React.PureComponent<Props, State> {
brightness: 0,
contrast: 1,
color: [255, 255, 255],
isVisible: true,
};
const datasetDefaultConfiguration = (await getDatasetDefaultConfiguration(
this.props.datasetId,
Expand Down
21 changes: 18 additions & 3 deletions frontend/javascripts/libs/datasource.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,21 @@
"properties": {
"name": { "type": "string" },
"category": { "enum": ["color", "segmentation"] },
"elementClass": { "enum": ["uint8", "uint16", "uint24", "uint32", "uint64", "float,", "double", "int8", "int16", "int32", "int64"] }
"elementClass": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my ide beautifies code again 🤔
As this is accepted by prettier I suggest to keep it this way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, in the long run, this can be quite cumbersome. This is especially prone to merge conflicts. Can you please disable any IDE auto-formatting which differs from prettiers behavior?

"enum": [
"uint8",
"uint16",
"uint24",
"uint32",
"uint64",
"float,",
"double",
"int8",
"int16",
"int32",
"int64"
]
}
},
"required": ["name", "category", "elementClass"]
},
Expand Down Expand Up @@ -128,9 +142,10 @@
"properties": {
"brightness": { "type": "number" },
"contrast": { "type": "number" },
"color": { "$ref": "#/definitions/types::Vector3" }
"color": { "$ref": "#/definitions/types::Vector3" },
"isVisible": { "type": "boolean" }
},
"required": ["brightness", "contrast", "color"]
"required": ["brightness", "contrast", "color", "isVisible"]
}
}
}
Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/libs/datasource.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ export type LayerUserConfiguration = {
brightness: number,
contrast: number,
color: Vector3,
isVisible: boolean,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ class PlaneMaterialFactory {
updateUniformsForLayer(settings: DatasetLayerConfiguration, name: string): void {
this.uniforms[`${name}_brightness`].value = settings.brightness / 255;
this.uniforms[`${name}_contrast`].value = settings.contrast;
this.uniforms[`${name}_alpha`].value = settings.alpha / 100;
this.uniforms[`${name}_alpha`].value = settings.isVisible ? settings.alpha / 100 : 0;

if (settings.color != null) {
const color = this.convertColor(settings.color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function SettingsReducer(state: OxalisState, action: Action): OxalisState {
contrast: 1,
color: [255, 255, 255],
alpha: 100,
isVisible: true,
},
initialLayerSettings[layer.name],
);
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 @@ -213,6 +213,7 @@ export type DatasetLayerConfiguration = {|
+brightness: number,
+contrast: number,
+alpha: number,
+isVisible: boolean,
|};

export type LoadingStrategy = "BEST_QUALITY_FIRST" | "PROGRESSIVE_QUALITY";
Expand Down
23 changes: 20 additions & 3 deletions frontend/javascripts/oxalis/view/settings/dataset_settings_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import constants, {
} from "oxalis/constants";
import messages, { settings } from "messages";

const Panel = Collapse.Panel;
const Option = Select.Option;
const { Panel } = Collapse;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also done by my ide

const { Option } = Select;

type DatasetSettingsProps = {|
datasetConfiguration: DatasetConfiguration,
Expand All @@ -65,7 +65,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps> {
isLastLayer: boolean,
) => {
const isRGB = isRgb(this.props.dataset, layerName);
const { brightness, contrast, alpha, color } = layer;
const { brightness, contrast, alpha, color, isVisible } = layer;
return (
<div key={layerName}>
<Row>
Expand All @@ -74,6 +74,23 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps> {
<Tag style={{ cursor: "default", marginLeft: 8 }} color={isRGB && "#1890ff"}>
{isRGB ? "24-bit" : "8-bit"} Layer
</Tag>
{alpha > 0 && isVisible ? (
MichaelBuessemeyer marked this conversation as resolved.
Show resolved Hide resolved
<Tooltip title="Make this color layer invisible.">
<Icon
type="eye"
onClick={() => this.props.onChangeLayer(layerName, "isVisible", false)}
style={{ marginTop: 4, marginLeft: 8, cursor: "pointer" }}
/>
</Tooltip>
) : (
<Tooltip title="Make this color layer visible.">
MichaelBuessemeyer marked this conversation as resolved.
Show resolved Hide resolved
<Icon
type="eye-o"
MichaelBuessemeyer marked this conversation as resolved.
Show resolved Hide resolved
onClick={() => this.props.onChangeLayer(layerName, "isVisible", true)}
style={{ marginTop: 4, marginLeft: 8, cursor: "pointer" }}
/>
</Tooltip>
)}
<Tooltip title="If you are having trouble finding your data, webKnossos can try to find a position which contains data.">
<Icon
type="scan"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ const datasetConfigOverrides: { [key: string]: DatasetConfiguration } = {
ROI2017_wkw_fallback: {
fourBit: false,
interpolation: true,
layers: { color: { color: [255, 255, 255], contrast: 1, brightness: 0, alpha: 100 } },
layers: {
color: { color: [255, 255, 255], contrast: 1, brightness: 0, alpha: 100, isVisible: true },
},
quality: 0,
segmentationOpacity: 0,
highlightHoveredCellId: true,
Expand Down