Skip to content

Commit

Permalink
Adjusted initial camera position, enabled 'Reset zoom' option for 3D …
Browse files Browse the repository at this point in the history
…canvas (#5395)
  • Loading branch information
bsekachev authored Dec 1, 2022
1 parent 01fec6f commit 772f0cd
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 186 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ from online detectors & interactors) (<https://github.com/opencv/cvat/pull/4543>
- 3D canvas now can be dragged in IDLE mode (<https://github.com/opencv/cvat/pull/5385>)
- Datumaro version is upgraded to 0.3 (dev) (<https://github.com/opencv/cvat/pull/4984>)
- Allowed trailing slashes in the SDK host address (<https://github.com/opencv/cvat/pull/5057>)
- Adjusted initial camera position, enabled 'Reset zoom' option for 3D canvas (<https://github.com/opencv/cvat/pull/5395>)
- Enabled authentication via email (<https://github.com/opencv/cvat/pull/5037>)

### Deprecated
Expand Down
2 changes: 1 addition & 1 deletion cvat-canvas3d/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-canvas3d",
"version": "0.0.2",
"version": "0.0.3",
"description": "Part of Computer Vision Annotation Tool which presents its canvas3D library",
"main": "src/canvas3d.ts",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions cvat-canvas3d/src/typescript/canvas3d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -13,6 +14,7 @@ import {
MouseInteraction,
ShapeProperties,
GroupData,
Configuration,
} from './canvas3dModel';
import {
Canvas3dView, Canvas3dViewImpl, ViewsDOM, CameraAction,
Expand Down Expand Up @@ -94,6 +96,10 @@ class Canvas3dImpl implements Canvas3d {
this.model.configureShapes(shapeProperties);
}

public configure(configuration: Configuration): void {
this.model.configure(configuration);
}

public activate(clientID: number | null, attributeID: number | null = null): void {
this.model.activate(String(clientID), attributeID);
}
Expand Down
8 changes: 7 additions & 1 deletion cvat-canvas3d/src/typescript/canvas3dController.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

import {
Canvas3dModel, Mode, DrawData, ActiveElement, FocusData, GroupData,
Canvas3dModel, Mode, DrawData, ActiveElement, FocusData, GroupData, Configuration,
} from './canvas3dModel';

export interface Canvas3dController {
Expand All @@ -12,6 +13,7 @@ export interface Canvas3dController {
readonly selected: any;
readonly focused: FocusData;
readonly groupData: GroupData;
readonly configuration: Configuration;
readonly imageIsDeleted: boolean;
mode: Mode;
group(groupData: GroupData): void;
Expand Down Expand Up @@ -56,6 +58,10 @@ export class Canvas3dControllerImpl implements Canvas3dController {
return this.model.groupData;
}

public get configuration(): Configuration {
return this.model.configuration;
}

public group(groupData: GroupData): void {
this.model.group(groupData);
}
Expand Down
24 changes: 24 additions & 0 deletions cvat-canvas3d/src/typescript/canvas3dModel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -19,6 +20,10 @@ export interface GroupData {
grouped?: [];
}

export interface Configuration {
resetZoom?: boolean;
}

export interface Image {
renderWidth: number;
renderHeight: number;
Expand Down Expand Up @@ -80,6 +85,7 @@ export enum UpdateReasons {
SHAPE_ACTIVATED = 'shape_activated',
GROUP = 'group',
FITTED_CANVAS = 'fitted_canvas',
CONFIG_UPDATED = 'config_updated',
}

export enum Mode {
Expand Down Expand Up @@ -112,20 +118,23 @@ export interface Canvas3dDataModel {
selected: any;
shapeProperties: ShapeProperties;
groupData: GroupData;
configuration: Configuration;
}

export interface Canvas3dModel {
mode: Mode;
data: Canvas3dDataModel;
readonly imageIsDeleted: boolean;
readonly groupData: GroupData;
readonly configuration: Configuration;
setup(frameData: any, objectStates: any[]): void;
isAbleToChangeFrame(): boolean;
draw(drawData: DrawData): void;
cancel(): void;
dragCanvas(enable: boolean): void;
activate(clientID: string | null, attributeID: number | null): void;
configureShapes(shapeProperties: any): void;
configure(configuration: Configuration): void;
fit(): void;
group(groupData: GroupData): void;
destroy(): void;
Expand Down Expand Up @@ -177,6 +186,9 @@ export class Canvas3dModelImpl extends MasterImpl implements Canvas3dModel {
selectedOpacity: 60,
colorBy: 'Label',
},
configuration: {
resetZoom: false,
},
};
}

Expand Down Expand Up @@ -327,6 +339,14 @@ export class Canvas3dModelImpl extends MasterImpl implements Canvas3dModel {
this.notify(UpdateReasons.GROUP);
}

public configure(configuration: Configuration): void {
if (typeof configuration.resetZoom === 'boolean') {
this.data.configuration.resetZoom = configuration.resetZoom;
}

this.notify(UpdateReasons.CONFIG_UPDATED);
}

public configureShapes(shapeProperties: ShapeProperties): void {
this.data.drawData.enabled = false;
this.data.mode = Mode.IDLE;
Expand All @@ -341,6 +361,10 @@ export class Canvas3dModelImpl extends MasterImpl implements Canvas3dModel {
this.notify(UpdateReasons.FITTED_CANVAS);
}

public get configuration(): Configuration {
return { ...this.data.configuration };
}

public get groupData(): GroupData {
return { ...this.data.groupData };
}
Expand Down
Loading

0 comments on commit 772f0cd

Please sign in to comment.