Skip to content

Commit 19efde6

Browse files
No transform controls when exploded view is enabled (#616)
* No transform controls when exploded view is enabled * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 93a88a2 commit 19efde6

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

packages/base/src/3dview/mainview.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ export class MainView extends React.Component<IProps, IStates> {
12401240
* Attach the transform controls to the current selection, or detach it
12411241
*/
12421242
private _updateTransformControls(selection: string[]) {
1243-
if (selection.length === 1) {
1243+
if (selection.length === 1 && !this._explodedView.enabled) {
12441244
const selectedMeshName = selection[0];
12451245
const matchingChild = this._meshGroup?.children.find(child =>
12461246
child.name.startsWith(selectedMeshName)
@@ -1595,6 +1595,8 @@ export class MainView extends React.Component<IProps, IStates> {
15951595

15961596
this._explodedViewLinesHelperGroup?.removeFromParent();
15971597
}
1598+
1599+
this._updateTransformControls(Object.keys(this._currentSelection || {}));
15981600
}
15991601

16001602
private _updateCamera() {

packages/base/src/3dview/mainviewmodel.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ import {
1818
} from '@jupytercad/schema';
1919
import { showErrorMessage } from '@jupyterlab/apputils';
2020
import { ObservableMap } from '@jupyterlab/observables';
21-
import { JSONValue, PromiseDelegate, UUID } from '@lumino/coreutils';
21+
import {
22+
JSONObject,
23+
JSONValue,
24+
PromiseDelegate,
25+
UUID
26+
} from '@lumino/coreutils';
2227
import { IDisposable } from '@lumino/disposable';
2328
import { ISignal, Signal } from '@lumino/signaling';
2429
import { v4 as uuid } from 'uuid';
@@ -51,6 +56,7 @@ export class MainViewModel implements IDisposable {
5156
get workerBusy(): ISignal<this, boolean> {
5257
return this._workerBusy;
5358
}
59+
5460
get jcadModel() {
5561
return this._jcadModel;
5662
}
@@ -59,6 +65,14 @@ export class MainViewModel implements IDisposable {
5965
return this._viewSetting.changed;
6066
}
6167

68+
get viewSettings(): JSONObject {
69+
const settings: JSONObject = {};
70+
for (const key of this._viewSetting.keys()) {
71+
settings[key] = this._viewSetting.get(key) || null;
72+
}
73+
return settings;
74+
}
75+
6276
dispose(): void {
6377
if (this._isDisposed) {
6478
return;

packages/base/src/commands.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ import { PathExt } from '@jupyterlab/coreutils';
4545
import { MainViewModel } from './3dview/mainviewmodel';
4646
import { handleRemoveObject } from './panelview';
4747
import { v4 as uuid } from 'uuid';
48+
import { ExplodedView } from './types';
49+
import { JSONObject } from '@lumino/coreutils';
4850
export function newName(type: string, model: IJupyterCadModel): string {
4951
const sharedModel = model.sharedModel;
5052

@@ -958,9 +960,20 @@ export function addCommands(
958960
commands.addCommand(CommandIDs.transform, {
959961
label: trans.__('Toggle Transform Controls'),
960962
isEnabled: () => {
961-
return tracker.currentWidget
962-
? tracker.currentWidget.context.model.sharedModel.editable
963-
: false;
963+
const current = tracker.currentWidget;
964+
965+
if (
966+
!current ||
967+
!tracker.currentWidget.context.model.sharedModel.editable
968+
) {
969+
return false;
970+
}
971+
972+
const viewSettings = tracker.currentWidget.content.currentViewModel
973+
.viewSettings as JSONObject;
974+
return viewSettings.explodedView
975+
? !(viewSettings.explodedView as ExplodedView).enabled
976+
: true;
964977
},
965978
isToggled: () => {
966979
const current = tracker.currentWidget?.content;
@@ -1032,6 +1045,13 @@ export function addCommands(
10321045
label: trans.__('Exploded View'),
10331046
isEnabled: () => Boolean(tracker.currentWidget),
10341047
icon: explodedViewIcon,
1048+
isToggled: () => {
1049+
const viewSettings = tracker.currentWidget?.content.currentViewModel
1050+
.viewSettings as JSONObject;
1051+
return viewSettings?.explodedView
1052+
? (viewSettings.explodedView as ExplodedView).enabled
1053+
: false;
1054+
},
10351055
execute: async () => {
10361056
const current = tracker.currentWidget;
10371057

@@ -1048,6 +1068,11 @@ export function addCommands(
10481068
cancelButton: true
10491069
});
10501070
await dialog.launch();
1071+
1072+
commands.notifyCommandChanged(CommandIDs.updateExplodedView);
1073+
1074+
// Notify change so that toggle button for transform disables if needed
1075+
commands.notifyCommandChanged(CommandIDs.transform);
10511076
}
10521077
});
10531078

0 commit comments

Comments
 (0)