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

Make layer order editable via drag and drop #7188

Merged
merged 15 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion frontend/javascripts/messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const settingsTooltips: Partial<Record<keyof RecommendedConfiguration, st
zoom: "Zoom in or out in the data viewports",
displayScalebars: "Show a scale in the lower-right corner of each viewport",
blendMode:
"Set the blend mode for the dataset. The additive mode (default) adds the data values of all color layers. In cover mode, color layers are rendered on top of each other so that the data values of lower color layers are hidden by values of higher layers.",
"Set the blend mode for the dataset. The additive mode (default) adds the data values of all color layers. In cover mode, color layers are rendered on top of each other so that the data values of lower color layers are hidden by values of higher layers. Cover mode enables reordering of color layers.",
renderWatermark: "Show a WEBKNOSSOS logo in the lower-left corner of each screenshot.",
antialiasRendering: "Antialias rendering (can impact performance)",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ class PlaneMaterialFactory {
colorLayerOrder.length !== oldLayerOrder.length ||
colorLayerOrder.some((layerName, index) => layerName !== oldLayerOrder[index]);
if (changedLayerOrder) {
oldLayerOrder = [...colorLayerOrder];
this.recomputeShaders();
}
app.vent.emit("rerender");
Expand Down
9 changes: 5 additions & 4 deletions frontend/javascripts/oxalis/model_initialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,18 +799,19 @@ function ensureDatasetSettingsHasLayerOrder(
const colorLayerNames = _.keys(datasetConfiguration.layers).filter((layerName) =>
isColorLayer(dataset, layerName),
);
const onlyExistingLayers =
datasetConfiguration?.colorLayerOrder?.filter(
(layerName) => colorLayerNames.indexOf(layerName) >= 0,
) || [];
if (
datasetConfiguration.colorLayerOrder == null ||
MichaelBuessemeyer marked this conversation as resolved.
Show resolved Hide resolved
datasetConfiguration.colorLayerOrder.length < colorLayerNames.length
onlyExistingLayers.length < colorLayerNames.length
) {
return {
...datasetConfiguration,
colorLayerOrder: colorLayerNames,
};
}
const onlyExistingLayers = datasetConfiguration.colorLayerOrder.filter(
(layerName) => colorLayerNames.indexOf(layerName) >= 0,
);
return { ...datasetConfiguration, colorLayerOrder: onlyExistingLayers };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import {
} from "oxalis/model/actions/settings_actions";
import { userSettings } from "types/schemas/user_settings.schema";
import type { Vector3, ControlMode } from "oxalis/constants";
import Constants, { ControlModeEnum } from "oxalis/constants";
import Constants, { BLEND_MODES, ControlModeEnum } from "oxalis/constants";
import EditableTextLabel from "oxalis/view/components/editable_text_label";
import LinkButton from "components/link_button";
import { Model } from "oxalis/singletons";
Expand Down Expand Up @@ -381,7 +381,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
layerName: string,
elementClass: string,
layerSettings: DatasetLayerConfiguration,
draggingDisabled?: boolean,
draggingDisabled: boolean = true,
) => {
const { tracing, dataset } = this.props;
const { intensityRange } = layerSettings;
Expand Down Expand Up @@ -469,7 +469,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
const items = possibleItems.filter((el) => el);
return (
<div className="flex-container">
{draggingDisabled == null || draggingDisabled ? null : <DragHandle />}
{draggingDisabled ? null : <DragHandle />}
{this.getEnableDisableLayerSwitch(isDisabled, onChange)}
<div
className="flex-item"
Expand Down Expand Up @@ -737,7 +737,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
layerName,
layerConfiguration,
isColorLayer,
draggingDisabled = undefined,
draggingDisabled = true,
}: {
layerName: string;
layerConfiguration: DatasetLayerConfiguration | null | undefined;
Expand Down Expand Up @@ -1100,21 +1100,21 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
};

render() {
const { layers, colorLayerOrder } = this.props.datasetConfiguration;
const { layers, colorLayerOrder, blendMode } = this.props.datasetConfiguration;
const LayerSettings = this.LayerSettings;
const SortableLayerSettings = this.SortableLayerSettings;

const segmentationLayerNames = Object.keys(layers).filter(
(layerName) => !getIsColorLayer(this.props.dataset, layerName),
);
const isSortingDisabled = colorLayerOrder.length < 2 || blendMode === BLEND_MODES.Additive;
const colorLayerSettings = colorLayerOrder.map((layerName, index) => {
const isSortingDisabled = colorLayerOrder.length < 2;
return (
<SortableLayerSettings
key={layerName}
layerName={layerName}
layerConfiguration={layers[layerName]}
isColorLayer={true}
isColorLayer
index={index}
disabled={isSortingDisabled}
draggingDisabled={isSortingDisabled}
Expand Down