Skip to content

Commit

Permalink
added undo for the rest of actions
Browse files Browse the repository at this point in the history
  • Loading branch information
hxhxhx88 committed Feb 23, 2024
1 parent 7f0c128 commit 0a82528
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 62 deletions.
4 changes: 2 additions & 2 deletions app/frontend/src/component/panel/layer/Hover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {ComponentProximity} from 'state/annotate/render/mouse';
import {ColorPalette} from '../entity/display';
import {editStyle} from 'common/constant';
import {getComponent} from 'state/annotate/annotation';
import {useAddComponents, useTransferComponent} from 'state/annotate/annotation-broadcast';
import {useAddDeleteComponents, useTransferComponent} from 'state/annotate/annotation-broadcast';

const FullSize: CSSProperties = {position: 'absolute', left: 0, top: 0, width: '100%', height: '100%'};

Expand Down Expand Up @@ -174,7 +174,7 @@ const TopLevelHover: FC<HTMLAttributes<HTMLDivElement>> = ({...divProps}) => {
[manipulation]
)
);
const {addComponents} = useAddComponents();
const {addComponents} = useAddDeleteComponents();
const {transferComponent} = useTransferComponent();

const {isControlOrMetaPressed, isShiftPressed} = useControlMetaShiftPressed();
Expand Down
4 changes: 2 additions & 2 deletions app/frontend/src/component/panel/layer/polychain/Draw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {ColorPalette} from 'component/panel/entity/display';
import {useHotkeys} from 'react-hotkeys-hook';
import {useKeyPressed} from 'common/keyboard';
import {getComponent} from 'state/annotate/annotation';
import {useAddComponent} from 'state/annotate/annotation-broadcast';
import {useAddDeleteComponents} from 'state/annotate/annotation-broadcast';

type Props = HTMLAttributes<HTMLDivElement> & {
width: number;
Expand Down Expand Up @@ -89,7 +89,7 @@ const LayerWithEntityId: FC<Props & {entityId: EntityId}> = ({entityId, width, h
)
);

const {addComponent} = useAddComponent();
const {addComponent} = useAddDeleteComponents();

const drawPolychain = useDrawPolychain(transform);
const drawAnnoVertex = useDrawVertex(transform);
Expand Down
4 changes: 2 additions & 2 deletions app/frontend/src/component/panel/layer/rectangle/Draw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {EntityId} from 'type/annotation';
import {useHotkeys} from 'react-hotkeys-hook';
import {Button, Space, Tag, Tooltip} from 'antd';
import {ClearOutlined} from '@ant-design/icons';
import {useAddComponent} from 'state/annotate/annotation-broadcast';
import {useAddDeleteComponents} from 'state/annotate/annotation-broadcast';

type Props = HTMLAttributes<HTMLDivElement> & {
width: number;
Expand Down Expand Up @@ -50,7 +50,7 @@ const LayerWithEntityId: FC<Props & {entityId: EntityId}> = ({entityId, width, h
)
);

const {addComponent} = useAddComponent();
const {addComponent} = useAddDeleteComponents();
useHotkeys(
'esc',
useCallback(() => finish(), [finish])
Expand Down
6 changes: 3 additions & 3 deletions app/frontend/src/component/panel/menu/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {useStore as useRenderStore} from 'state/annotate/render';
import type {EntityId, ComponentId} from 'type/annotation';
import {getSlice} from 'state/annotate/annotation';
import {
useDeleteComponents,
useAddDeleteComponents,
useDeleteEntities,
usePaste,
useSeparateComponent,
Expand All @@ -31,7 +31,7 @@ export function useComponentActions(entityId: EntityId, componentId: ComponentId
const sliceIndex = useRenderStore(s => s.sliceIndex);

const {separateComponent} = useSeparateComponent();
const {deleteComponents} = useDeleteComponents();
const {deleteComponents} = useAddDeleteComponents();
const startManipulation = useRenderStore(s => s.manipulate.start);

const nc = useAnnoStore(
Expand Down Expand Up @@ -80,7 +80,7 @@ export function useEntityActions(): Action[] {
const sliceIndex = useRenderStore(s => s.sliceIndex);

const {deleteEntities} = useDeleteEntities();
const {deleteComponents} = useDeleteComponents();
const {deleteComponents} = useAddDeleteComponents();
const {truncateEntities} = useTruncateEntities();

// copy
Expand Down
4 changes: 2 additions & 2 deletions app/frontend/src/component/panel/menu/mask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {ConfigContext} from 'common/context';
import {expand, rleCountsFromStringCOCO, rleCountsToStringCOCO, shrink} from 'common/algorithm/rle';
import {Mask, TrackReq} from 'openapi/nutsh';
import {correctSliceUrl} from 'common/route';
import {useAddComponents} from 'state/annotate/annotation-broadcast';
import {useAddDeleteComponents} from 'state/annotate/annotation-broadcast';

export function useActions(mask: MaskComponent, eid: EntityId): Action[] {
const config = useContext(ConfigContext);
Expand All @@ -22,7 +22,7 @@ export function useActions(mask: MaskComponent, eid: EntityId): Action[] {
const currentSliceIndex = useRenderStore(s => s.sliceIndex);
const currentSliceUrl = useRenderStore(s => correctSliceUrl(s.sliceUrls[s.sliceIndex]));
const subsequentSliceUrls = useRenderStore(s => s.sliceUrls.slice(s.sliceIndex + 1).map(correctSliceUrl));
const {addComponents} = useAddComponents();
const {addComponents} = useAddDeleteComponents();

const track = useCallback(
(mask: MaskComponent) => {
Expand Down
Loading

0 comments on commit 0a82528

Please sign in to comment.