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

Show measurement tool in read-only mode #8334

Merged
merged 14 commits into from
Feb 3, 2025
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.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Added the possibility to configure a rotation for a dataset, which can be toggled off and on when viewing and annotating data. [#8159](https://github.com/scalableminds/webknossos/pull/8159)
- When using the “Restore older Version” feature, there are no longer separate tabs for the different annotation layers. Only one linear annotation history is now used, and if you revert to an older version, all layers are reverted. If layers were added/deleted since then, that is also reverted. This also means that proofreading annotations can now be reverted to older versions as well. The description text of annotations is now versioned as well. [#7917](https://github.com/scalableminds/webknossos/pull/7917)
- Added the possibility to use the "merger mode" even when the user has annotated volume data in the current layer (as long as no other mapping is active). [#8335](https://github.com/scalableminds/webknossos/pull/8335)
- Measurement tools are now accessible when viewing datasets outside of an annotation. [#8334](https://github.com/scalableminds/webknossos/pull/8334)

### Changed

Expand Down
2 changes: 2 additions & 0 deletions frontend/javascripts/oxalis/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ export const MeasurementTools: Array<keyof typeof AnnotationToolEnum> = [
AnnotationToolEnum.AREA_MEASUREMENT,
];

export const AvailableToolsInViewMode = [...MeasurementTools, AnnotationToolEnum.MOVE];

export type AnnotationTool = keyof typeof AnnotationToolEnum;
export enum ContourModeEnum {
DRAW = "DRAW",
Expand Down
4 changes: 4 additions & 0 deletions frontend/javascripts/oxalis/model/reducers/ui_reducer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AnnotationToolEnum, AvailableToolsInViewMode, ControlModeEnum } from "oxalis/constants";
import type { Action } from "oxalis/model/actions/actions";
import { updateKey, updateKey2 } from "oxalis/model/helpers/deep_update";
import {
Expand Down Expand Up @@ -55,6 +56,9 @@ function UiReducer(state: OxalisState, action: Action): OxalisState {

case "SET_TOOL": {
if (!state.tracing.restrictions.allowUpdate) {
if (AvailableToolsInViewMode.includes(AnnotationToolEnum[action.tool])) {
return setToolReducer(state, action.tool);
}
return state;
}

Expand Down
53 changes: 29 additions & 24 deletions frontend/javascripts/oxalis/view/action-bar/toolbar_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { document } from "libs/window";
import {
type AnnotationTool,
AnnotationToolEnum,
ControlModeEnum,
FillModeEnum,
type InterpolationMode,
InterpolationModeEnum,
Expand Down Expand Up @@ -847,17 +848,17 @@ const TOOL_NAMES = {
AREA_MEASUREMENT: "Area Measurement Tool",
};

export default function ToolbarView() {
export default function ToolbarView({ isReadOnly }: { isReadOnly: boolean }) {
const dispatch = useDispatch();
const hasVolume = useSelector((state: OxalisState) => state.tracing.volumes.length > 0);
const hasSkeleton = useSelector((state: OxalisState) => state.tracing.skeleton != null);
const hasVolume = useSelector((state: OxalisState) => state.tracing?.volumes.length > 0);
const hasSkeleton = useSelector((state: OxalisState) => state.tracing?.skeleton != null);

const isAgglomerateMappingEnabled = useSelector(hasAgglomerateMapping);

const [lastForcefullyDisabledTool, setLastForcefullyDisabledTool] =
useState<AnnotationTool | null>(null);
const isVolumeModificationAllowed = useSelector(
(state: OxalisState) => !hasEditableMapping(state),
);
const isVolumeModificationAllowed =
useSelector((state: OxalisState) => !hasEditableMapping(state)) && !isReadOnly;
const useLegacyBindings = useSelector(
(state: OxalisState) => state.userConfiguration.useLegacyBindings,
);
Expand Down Expand Up @@ -942,7 +943,7 @@ export default function ToolbarView() {
<i className="fas fa-arrows-alt" />
</ToolRadioButton>

{hasSkeleton ? (
{hasSkeleton && !isReadOnly ? (
<ToolRadioButton
name={TOOL_NAMES.SKELETON}
description={skeletonToolDescription}
Expand Down Expand Up @@ -1106,24 +1107,28 @@ export default function ToolbarView() {
</ToolRadioButton>
</React.Fragment>
) : null}
<ToolRadioButton
name={TOOL_NAMES.BOUNDING_BOX}
description="Create, resize and modify bounding boxes."
disabledExplanation={disabledInfosForTools[AnnotationToolEnum.BOUNDING_BOX].explanation}
disabled={disabledInfosForTools[AnnotationToolEnum.BOUNDING_BOX].isDisabled}
value={AnnotationToolEnum.BOUNDING_BOX}
>
<img
src="/assets/images/bounding-box.svg"
alt="Bounding Box Icon"
style={{
opacity: disabledInfosForTools[AnnotationToolEnum.BOUNDING_BOX].isDisabled ? 0.5 : 1,
...imgStyleForSpaceyIcons,
}}
/>
</ToolRadioButton>
{!isReadOnly && (
<ToolRadioButton
name={TOOL_NAMES.BOUNDING_BOX}
description="Create, resize and modify bounding boxes."
disabledExplanation={disabledInfosForTools[AnnotationToolEnum.BOUNDING_BOX].explanation}
disabled={disabledInfosForTools[AnnotationToolEnum.BOUNDING_BOX].isDisabled}
value={AnnotationToolEnum.BOUNDING_BOX}
>
<img
src="/assets/images/bounding-box.svg"
alt="Bounding Box Icon"
style={{
opacity: disabledInfosForTools[AnnotationToolEnum.BOUNDING_BOX].isDisabled
? 0.5
: 1,
...imgStyleForSpaceyIcons,
}}
/>
</ToolRadioButton>
)}

{hasSkeleton && hasVolume ? (
{hasSkeleton && hasVolume && !isReadOnly ? (
<ToolRadioButton
name={TOOL_NAMES.PROOFREAD}
description={
Expand Down
4 changes: 3 additions & 1 deletion frontend/javascripts/oxalis/view/action_bar_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,10 @@ class ActionBarView extends React.PureComponent<Props, State> {
{getIsAIAnalysisEnabled() && isAdminOrDatasetManager
? this.renderStartAIJobButton(shouldDisableAIJobButton, tooltip)
: null}
{!isReadOnly && constants.MODES_PLANE.indexOf(viewMode) > -1 ? <ToolbarView /> : null}
{isViewMode ? this.renderStartTracingButton() : null}
{constants.MODES_PLANE.indexOf(viewMode) > -1 ? (
<ToolbarView isReadOnly={isReadOnly} />
) : null}
</div>
<AddNewLayoutModal
addLayout={this.addNewLayout}
Expand Down