Skip to content

Commit d6ac54e

Browse files
Modify updateCameraSettings command to use a toogle button instead of a formDialog.
Replace the camera icon by a video camera one.
1 parent 86ba3af commit d6ac54e

5 files changed

Lines changed: 56 additions & 29 deletions

File tree

examples/jcad.ipynb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,22 @@
1717
}
1818
],
1919
"metadata": {
20+
"kernelspec": {
21+
"display_name": "Python 3 (ipykernel)",
22+
"language": "python",
23+
"name": "python3"
24+
},
2025
"language_info": {
21-
"name": "python"
26+
"codemirror_mode": {
27+
"name": "ipython",
28+
"version": 3
29+
},
30+
"file_extension": ".py",
31+
"mimetype": "text/x-python",
32+
"name": "python",
33+
"nbconvert_exporter": "python",
34+
"pygments_lexer": "ipython3",
35+
"version": "3.13.3"
2236
}
2337
},
2438
"nbformat": 4,

packages/base/src/commands.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
wireframeIcon,
3838
transformIcon,
3939
pencilSolidIcon,
40-
cameraSolidIcon
40+
videoSolidIcon
4141
} from './tools';
4242
import keybindings from './keybindings.json';
4343
import { DEFAULT_MESH_COLOR } from './3dview/helpers';
@@ -1085,27 +1085,33 @@ export function addCommands(
10851085
commands.notifyCommandChanged(CommandIDs.transform);
10861086
}
10871087
});
1088-
1088+
let toggled: boolean;
10891089
commands.addCommand(CommandIDs.updateCameraSettings, {
1090-
label: trans.__('Camera Settings'),
1090+
label: trans.__('Choose between Perspective and Orthographic Projection.'),
10911091
isEnabled: () => Boolean(tracker.currentWidget),
1092-
icon: cameraSolidIcon,
1092+
icon: videoSolidIcon,
1093+
isToggled: () => {
1094+
const current = tracker.currentWidget;
1095+
if (current) {
1096+
const content = current?.content;
1097+
const projection = content['Type'];
1098+
console.log('projection:', projection);
1099+
return (toggled = projection === 'Perspective');
1100+
} else {return false;}
1101+
},
10931102
execute: async () => {
1103+
toggled = !toggled;
10941104
const current = tracker.currentWidget;
1095-
10961105
if (!current) {
10971106
return;
1107+
} else {
1108+
const panel = current.content;
1109+
const projection = toggled
1110+
? { Type: 'Perspective' }
1111+
: { Type: 'Orthographic' };
1112+
const updatePanel = CAMERA_FORM.syncData(panel);
1113+
updatePanel(projection);
10981114
}
1099-
1100-
const dialog = new FormDialog({
1101-
model: current.model,
1102-
title: CAMERA_FORM.title,
1103-
schema: CAMERA_FORM.schema,
1104-
sourceData: CAMERA_FORM.default(current.content),
1105-
syncData: CAMERA_FORM.syncData(current.content),
1106-
cancelButton: true
1107-
});
1108-
await dialog.launch();
11091115
}
11101116
});
11111117

packages/base/src/tools.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import filletIconStr from '../style/icon/fillet.svg';
2525
import wireframeIconStr from '../style/icon/wireframe.svg';
2626
import chevronRightStr from '../style/icon/chevron-right.svg';
2727
import pencilSolidStr from '../style/icon/pencil-solid.svg';
28-
import cameraSolidStr from '../style/icon/camera-solid.svg';
28+
import videoSolidStr from '../style/icon/video-solid.svg';
2929
import terminalToolbarStr from '../style/icon/terminal-toolbar.svg';
3030

3131
import visibilitySvg from '../style/icon/visibility.svg';
@@ -150,9 +150,9 @@ export const pencilSolidIcon = new LabIcon({
150150
svgstr: pencilSolidStr
151151
});
152152

153-
export const cameraSolidIcon = new LabIcon({
154-
name: 'jupytercad:camera-solid-icon',
155-
svgstr: cameraSolidStr
153+
export const videoSolidIcon = new LabIcon({
154+
name: 'jupytercad:video-solid-icon',
155+
svgstr: videoSolidStr
156156
});
157157

158158
export const terminalToolbarIcon = new LabIcon({

packages/base/style/icon/camera-solid.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)