Skip to content

Commit

Permalink
Return full MainViewModel with get mainViewModel()
Browse files Browse the repository at this point in the history
  • Loading branch information
arjxn-py authored and martinRenou committed Oct 10, 2024
1 parent 3badc25 commit 4bd6b28
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/base/src/3dview/mainview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class MainView extends React.Component<IProps, IStates> {
window.addEventListener('jupytercadObjectSelection', (e: Event) => {
const customEvent = e as CustomEvent;

if (customEvent.detail.mainViewModel === this._mainViewModel.id) {
if (customEvent.detail.mainViewModelId === this._mainViewModel.id) {
this.lookAtPosition(customEvent.detail.objPosition);
}
});
Expand Down
5 changes: 3 additions & 2 deletions packages/base/src/panelview/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ISignal } from '@lumino/signaling';
import { IJupyterCadTracker, IJupyterCadWidget } from '@jupytercad/schema';
import { IControlPanelModel } from '../types';
import { JupyterCadWidget } from '../widget';
import { MainViewModel } from '../3dview/mainviewmodel';

export class ControlPanelModel implements IControlPanelModel {
constructor(options: ControlPanelModel.IOptions) {
Expand All @@ -27,9 +28,9 @@ export class ControlPanelModel implements IControlPanelModel {
return this._tracker.currentWidget?.context.model.sharedModel;
}

get mainViewModel(): string | undefined {
get mainViewModel(): MainViewModel | undefined {
return (this._tracker.currentWidget as JupyterCadWidget | null)?.content
.currentViewModel.id;
.currentViewModel;
}

disconnect(f: any): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/panelview/objecttree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class ObjectTreeReact extends React.Component<IProps, IStates> {
detail: {
objectId,
objPosition,
mainViewModel: this.props.cpModel.mainViewModel
mainViewModelId: this.props.cpModel.mainViewModel?.id
}
});
window.dispatchEvent(event);
Expand Down
3 changes: 2 additions & 1 deletion packages/base/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ISignal } from '@lumino/signaling';
import { IJupyterCadModel, IJupyterCadDoc, IDict } from '@jupytercad/schema';
import { IJupyterCadTracker, IJupyterCadWidget } from '@jupytercad/schema';
import { MainViewModel } from './3dview/mainviewmodel';

export { IDict };
export type ValueOf<T> = T[keyof T];
Expand Down Expand Up @@ -42,5 +43,5 @@ export interface IControlPanelModel {
filePath: string | undefined;
jcadModel: IJupyterCadModel | undefined;
sharedModel: IJupyterCadDoc | undefined;
mainViewModel: string | undefined;
mainViewModel: MainViewModel | undefined;
}

0 comments on commit 4bd6b28

Please sign in to comment.