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

Disable proofreading actions for mapped meshes #8091

Merged
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- It is now possible to add metadata in annotations to Trees and Segments. [#7875](https://github.com/scalableminds/webknossos/pull/7875)

### Changed
- Some mesh-related actions were disabled in proofreading-mode when using meshfiles that were created for a mapping rather than an oversegmentation. [#8091](https://github.com/scalableminds/webknossos/pull/8091)

### Fixed
- Fixed a bug during dataset upload in case the configured `datastore.baseFolder` is an absolute path. [#8098](https://github.com/scalableminds/webknossos/pull/8098)
Expand Down
72 changes: 28 additions & 44 deletions frontend/javascripts/oxalis/view/context_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ function getMeshItems(
maybeUnmappedSegmentId: number | null | undefined,
visibleSegmentationLayer: APIDataLayer | null | undefined,
voxelSizeFactor: Vector3,
meshFileMappingName: string | null | undefined,
): MenuItemType[] {
if (
clickedMeshId == null ||
Expand All @@ -414,15 +415,29 @@ function getMeshItems(
// by looking the segment id up the segments list and checking against null.
const activeSegmentMissing = segments.getNullable(activeCellId) == null;

const getTooltip = (actionVerb: "merge" | "split", actionNeedsActiveSegment: boolean) => {
return !isProofreadingActive
? `Cannot ${actionVerb} because the proofreading tool is not active.`
: maybeUnmappedSegmentId == null
? "The mesh wasn't loaded in proofreading mode. Please reload the mesh."
: meshFileMappingName != null
? "This mesh was created for a mapping. Please use a meshfile that is based on unmapped oversegmentation data."
: actionNeedsActiveSegment && activeSegmentMissing
? "Select a segment first."
: null;
};
Comment on lines +418 to +428
Copy link
Contributor

Choose a reason for hiding this comment

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

Très bien! 🎉


const shouldAgglomerateSkeletonActionsBeDisabled =
!isProofreadingActive ||
activeSegmentMissing ||
maybeUnmappedSegmentId == null ||
meshFileMappingName != null;
Comment on lines +430 to +434
Copy link
Contributor

Choose a reason for hiding this comment

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

👯


const maybeProofreadingItems: MenuItemType[] = isProofreadingActive
? [
{
key: "merge-agglomerate-skeleton",
disabled:
!isProofreadingActive ||
activeSegmentMissing ||
clickedMeshId === activeCellId ||
maybeUnmappedSegmentId == null,
disabled: shouldAgglomerateSkeletonActionsBeDisabled || clickedMeshId === activeCellId,
onClick: () => {
if (maybeUnmappedSegmentId == null) {
// Should not happen due to the disabled property.
Expand All @@ -431,28 +446,14 @@ function getMeshItems(
return Store.dispatch(proofreadMerge(null, maybeUnmappedSegmentId, clickedMeshId));
},
label: (
<FastTooltip
title={
!isProofreadingActive
? "Cannot merge because the proofreading tool is not active."
: maybeUnmappedSegmentId == null
? "The mesh wasn't loaded in proofreading mode. Please reload the mesh."
: activeSegmentMissing
? "Select a segment first."
: null
}
>
Merge with active segment
</FastTooltip>
<FastTooltip title={getTooltip("merge", true)}>Merge with active segment</FastTooltip>
),
},
{
key: "min-cut-agglomerate-at-position",
disabled:
!isProofreadingActive ||
activeSegmentMissing ||
shouldAgglomerateSkeletonActionsBeDisabled ||
clickedMeshId !== activeCellId ||
maybeUnmappedSegmentId == null ||
activeUnmappedSegmentId == null ||
maybeUnmappedSegmentId === activeUnmappedSegmentId,
onClick: () => {
Expand All @@ -465,24 +466,12 @@ function getMeshItems(
);
},
label: (
<FastTooltip
title={
!isProofreadingActive
? "Cannot split because the proofreading tool is not active."
: maybeUnmappedSegmentId == null
? "The mesh wasn't loaded in proofreading mode. Please reload the mesh."
: activeSegmentMissing
? "Select a segment first."
: null
}
>
Split from active segment
</FastTooltip>
<FastTooltip title={getTooltip("split", true)}>Split from active segment</FastTooltip>
),
},
{
key: "split-from-all-neighbors",
disabled: maybeUnmappedSegmentId == null,
disabled: maybeUnmappedSegmentId == null || meshFileMappingName != null,
onClick: () => {
if (maybeUnmappedSegmentId == null) {
// Should not happen due to the disabled property.
Expand All @@ -493,15 +482,7 @@ function getMeshItems(
);
},
label: (
<FastTooltip
title={
!isProofreadingActive
? "Cannot split because the proofreading tool is not active."
: maybeUnmappedSegmentId == null
? "The mesh wasn't loaded in proofreading mode. Please reload the mesh."
: null
}
>
<FastTooltip title={getTooltip("split", false)}>
Split from all neighboring segments
</FastTooltip>
),
Expand Down Expand Up @@ -576,6 +557,7 @@ function getNodeContextMenuOptions({
volumeTracing,
infoRows,
allowUpdate,
currentMeshFile,
}: NodeContextMenuOptionsProps): ItemType[] {
const state = Store.getState();
const isProofreadingActive = state.uiInformation.activeTool === AnnotationToolEnum.PROOFREAD;
Expand Down Expand Up @@ -617,6 +599,7 @@ function getNodeContextMenuOptions({
maybeUnmappedSegmentId,
visibleSegmentationLayer,
voxelSize.factor,
currentMeshFile?.mappingName,
);

const menuItems: ItemType[] = [
Expand Down Expand Up @@ -1251,6 +1234,7 @@ function getNoNodeContextMenuOptions(props: NoNodeContextMenuProps): ItemType[]
maybeUnmappedSegmentId,
visibleSegmentationLayer,
voxelSize.factor,
currentMeshFile?.mappingName,
);

if (isSkeletonToolActive) {
Expand Down