Skip to content

Commit

Permalink
Move jcad model to schema package
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Nov 14, 2023
1 parent 11a3afb commit c1c22d2
Show file tree
Hide file tree
Showing 37 changed files with 357 additions and 356 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ ui-tests
**/build/
jupytercad/
examples/
packages/opencascade/build.yml
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
jupytercad
**/*.d.ts
**/*.js
packages/opencascade/build.yml
12 changes: 5 additions & 7 deletions packages/base/src/annotation/model.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { DocumentRegistry } from '@jupyterlab/docregistry';
import { User } from '@jupyterlab/services';

import { ISignal, Signal } from '@lumino/signaling';

import {
IAnnotationModel,
IAnnotation,
IAnnotationContent,
IAnnotationModel,
IJupyterCadModel
} from '../types';
} from '@jupytercad/schema';
import { DocumentRegistry } from '@jupyterlab/docregistry';
import { User } from '@jupyterlab/services';
import { ISignal, Signal } from '@lumino/signaling';

export class AnnotationModel implements IAnnotationModel {
constructor(options: AnnotationModel.IOptions) {
Expand Down
5 changes: 2 additions & 3 deletions packages/base/src/annotation/view.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { caretRightIcon, closeIcon } from '@jupyterlab/ui-components';
import { IAnnotationModel } from '@jupytercad/schema';
import { Dialog, showDialog } from '@jupyterlab/apputils';

import { caretRightIcon, closeIcon } from '@jupyterlab/ui-components';
import * as React from 'react';

import { minimizeIcon } from '../tools';
import { IAnnotationModel } from '../types';
import { Message } from './message';

interface IAnnotationProps {
Expand Down
17 changes: 11 additions & 6 deletions packages/base/src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import {
IDict,
IJCadObject,
IJupyterCadDoc,
IJupyterCadModel,
Parts
} from '@jupytercad/schema';
import formSchema from '@jupytercad/schema/lib/_interface/forms.json';
import { JupyterFrontEnd } from '@jupyterlab/application';
import { showErrorMessage, WidgetTracker } from '@jupyterlab/apputils';
import { ITranslator } from '@jupyterlab/translation';
import { SketcherDialog } from './sketcher/sketcherdialog';
import { redoIcon, undoIcon } from '@jupyterlab/ui-components';

import { FormDialog } from './formdialog';
import { SketcherDialog } from './sketcher/sketcherdialog';
import {
axesIcon,
boxIcon,
Expand All @@ -16,12 +26,7 @@ import {
torusIcon,
unionIcon
} from './tools';

import { IDict, IJupyterCadDoc, IJupyterCadModel } from './types';
import { JupyterCadPanel, JupyterCadWidget } from './widget';
import formSchema from '@jupytercad/schema/lib/_interface/forms.json';
import { IJCadObject, Parts } from '@jupytercad/schema';
import { redoIcon, undoIcon } from '@jupyterlab/ui-components';

const FORM_SCHEMA = {};
// Injecting "name" in the schema, as it's not part of the official schema but
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/factory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { JupyterCadModel } from '@jupytercad/schema';
import { ABCWidgetFactory, DocumentRegistry } from '@jupyterlab/docregistry';
import { CommandRegistry } from '@lumino/commands';

import { JupyterCadModel } from './model';
import { IJupyterCadTracker } from './token';
import { ToolbarWidget } from './toolbar/widget';
import { JupyterCadPanel, JupyterCadWidget } from './widget';
Expand Down
8 changes: 5 additions & 3 deletions packages/base/src/fcplugin/modelfactory.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {
IAnnotationModel,
IJupyterCadDoc,
JupyterCadModel
} from '@jupytercad/schema';
import { DocumentRegistry } from '@jupyterlab/docregistry';
import { Contents } from '@jupyterlab/services';

import { IAnnotationModel, IJupyterCadDoc } from '../types';
import { JupyterCadModel } from '../model';

/**
* A Model factory to create new instances of JupyterCadModel.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/fcplugin/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
ICollaborativeDrive,
SharedDocumentFactory
} from '@jupyter/docprovider';
import { IAnnotationModel, JupyterCadDoc } from '@jupytercad/schema';
import {
JupyterFrontEnd,
JupyterFrontEndPlugin
Expand All @@ -17,10 +18,9 @@ import { ILauncher } from '@jupyterlab/launcher';
import { fileIcon } from '@jupyterlab/ui-components';

import { JupyterCadWidgetFactory } from '../factory';
import { JupyterCadDoc } from '../model';
import { IAnnotationToken, IJupyterCadDocTracker } from '../token';
import { requestAPI } from '../tools';
import { IAnnotationModel, IJupyterCadWidget } from '../types';
import { IJupyterCadWidget } from '../types';
import { JupyterCadFCModelFactory } from './modelfactory';

const FACTORY = 'Jupytercad Freecad Factory';
Expand Down
11 changes: 8 additions & 3 deletions packages/base/src/formdialog.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import * as React from 'react';
import {
IDict,
IJupyterCadClientState,
IJupyterCadModel
} from '@jupytercad/schema';
import { Dialog } from '@jupyterlab/apputils';
import { DocumentRegistry } from '@jupyterlab/docregistry';
import * as React from 'react';

import { ObjectPropertiesForm } from './panelview/formbuilder';
import { IDict, IJupyterCadClientState, IJupyterCadModel } from './types';
import { focusInputField, removeStyleFromProperty } from './tools';
import { DocumentRegistry } from '@jupyterlab/docregistry';

export interface IFormDialogOptions {
schema: IDict;
Expand Down
1 change: 0 additions & 1 deletion packages/base/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export * from './commands';
export * from './factory';
export * from './formdialog';
export * from './mainview';
export * from './model';
export * from './token';
export * from './tools';
export * from './types';
Expand Down
7 changes: 5 additions & 2 deletions packages/base/src/jcadplugin/modelfactory.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { DocumentRegistry } from '@jupyterlab/docregistry';
import { Contents } from '@jupyterlab/services';

import { IAnnotationModel, IJupyterCadDoc } from '../types';
import { JupyterCadModel } from '../model';
import {
IAnnotationModel,
IJupyterCadDoc,
JupyterCadModel
} from '@jupytercad/schema';

/**
* A Model factory to create new instances of JupyterCadModel.
Expand Down
21 changes: 8 additions & 13 deletions packages/base/src/jcadplugin/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
import {
ICollaborativeDrive,
SharedDocumentFactory
} from '@jupyter/docprovider';
import { IAnnotationModel, JupyterCadDoc } from '@jupytercad/schema';
import {
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';

import {
ICommandPalette,
IThemeManager,
WidgetTracker
} from '@jupyterlab/apputils';

import { fileIcon } from '@jupyterlab/ui-components';

import { IFileBrowserFactory } from '@jupyterlab/filebrowser';

import { ILauncher } from '@jupyterlab/launcher';
import { fileIcon } from '@jupyterlab/ui-components';

import {
ICollaborativeDrive,
SharedDocumentFactory
} from '@jupyter/docprovider';

import { IAnnotationModel, IJupyterCadWidget } from '../types';
import { IAnnotationToken, IJupyterCadDocTracker } from '../token';
import { JupyterCadWidgetFactory } from '../factory';
import { IAnnotationToken, IJupyterCadDocTracker } from '../token';
import { IJupyterCadWidget } from '../types';
import { JupyterCadJcadModelFactory } from './modelfactory';
import { JupyterCadDoc } from '../model';

const FACTORY = 'Jupytercad Jcad Factory';
const PALETTE_CATEGORY = 'JupyterCAD';
Expand Down
20 changes: 9 additions & 11 deletions packages/base/src/mainview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ import {
MainAction,
WorkerAction
} from '@jupytercad/occ-worker';
import {
IAnnotation,
IDict,
IJcadObjectDocChange,
IJupyterCadClientState,
IJupyterCadDoc,
IJupyterCadModel
} from '@jupytercad/schema';
import { IObservableMap, ObservableMap } from '@jupyterlab/observables';
import { User } from '@jupyterlab/services';
import { CommandRegistry } from '@lumino/commands';
Expand All @@ -24,17 +32,7 @@ import { v4 as uuid } from 'uuid';

import { FloatingAnnotation } from './annotation/view';
import { getCSSVariableColor, throttle } from './tools';
import {
AxeHelper,
CameraSettings,
ExplodedView,
IAnnotation,
IDict,
IJcadObjectDocChange,
IJupyterCadClientState,
IJupyterCadDoc,
IJupyterCadModel
} from './types';
import { AxeHelper, CameraSettings, ExplodedView } from './types';

// Apply the BVH extension
THREE.BufferGeometry.prototype.computeBoundsTree = computeBoundsTree;
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/notebookrenderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
IJupyterYWidget
} from 'yjs-widgets';

import { JupyterCadModel } from '../model';
import { JupyterCadModel } from '@jupytercad/schema';
import { JupyterCadPanel } from '../widget';

export interface ICommMetadata {
Expand Down
3 changes: 1 addition & 2 deletions packages/base/src/panelview/annotations.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { IAnnotationModel } from '@jupytercad/schema';
import { PanelWithToolbar, ReactWidget } from '@jupyterlab/ui-components';

import * as React from 'react';

import { IAnnotationModel } from '../types';
import { Annotation } from '../annotation/view';

interface IProps {
Expand Down
8 changes: 4 additions & 4 deletions packages/base/src/panelview/leftpanel.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IAnnotationModel, JupyterCadDoc } from '@jupytercad/schema';
import { SidePanel } from '@jupyterlab/ui-components';

import { JupyterCadDoc } from '../model';
import { IControlPanelModel, IAnnotationModel } from '../types';
import { IJupyterCadTracker } from '../token';
import { IControlPanelModel } from '../types';
import { Annotations } from './annotations';
import { ControlPanelHeader } from './header';
import { ObjectTree } from './objecttree';
import { Annotations } from './annotations';
import { IJupyterCadTracker } from '../token';

export class LeftPanelWidget extends SidePanel {
constructor(options: LeftPanelWidget.IOptions) {
Expand Down
8 changes: 2 additions & 6 deletions packages/base/src/panelview/model.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { IJupyterCadDoc, IJupyterCadModel } from '@jupytercad/schema';
import { ISignal } from '@lumino/signaling';

import { IJupyterCadTracker } from '../token';
import {
IControlPanelModel,
IJupyterCadDoc,
IJupyterCadModel,
IJupyterCadWidget
} from '../types';
import { IControlPanelModel, IJupyterCadWidget } from '../types';

export class ControlPanelModel implements IControlPanelModel {
constructor(options: ControlPanelModel.IOptions) {
Expand Down
18 changes: 9 additions & 9 deletions packages/base/src/panelview/objectproperties.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { IJCadModel } from '@jupytercad/schema';
import {
IDict,
IJCadModel,
IJcadObjectDocChange,
IJupyterCadClientState,
IJupyterCadDoc,
IJupyterCadModel
} from '@jupytercad/schema';
import formSchema from '@jupytercad/schema/lib/_interface/forms.json';
import { ReactWidget } from '@jupyterlab/apputils';
import { PanelWithToolbar } from '@jupyterlab/ui-components';
Expand All @@ -11,14 +18,7 @@ import {
itemFromName,
removeStyleFromProperty
} from '../tools';
import {
IControlPanelModel,
IDict,
IJcadObjectDocChange,
IJupyterCadClientState,
IJupyterCadDoc,
IJupyterCadModel
} from '../types';
import { IControlPanelModel } from '../types';
import { ObjectPropertiesForm } from './formbuilder';

export class ObjectProperties extends PanelWithToolbar {
Expand Down
30 changes: 15 additions & 15 deletions packages/base/src/panelview/objecttree.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import * as React from 'react';
import { JSONObject } from '@lumino/coreutils';

import {
IDict,
IJCadModel,
IJCadObject,
IJcadObjectDocChange,
IJupyterCadClientState,
IJupyterCadDoc,
IJupyterCadModel
} from '@jupytercad/schema';
import { ReactWidget } from '@jupyterlab/apputils';
import {
closeIcon,
LabIcon,
PanelWithToolbar,
ToolbarButtonComponent,
closeIcon
ToolbarButtonComponent
} from '@jupyterlab/ui-components';
import { JSONObject } from '@lumino/coreutils';
import { Panel } from '@lumino/widgets';
import {
ReactTree,
ThemeSettings,
TreeNodeId,
TreeNodeList
} from '@naisutech/react-tree';
import * as React from 'react';
import { v4 as uuid } from 'uuid';

import visibilitySvg from '../../style/icon/visibility.svg';
import visibilityOffSvg from '../../style/icon/visibilityOff.svg';
import { IJCadModel, IJCadObject } from '@jupytercad/schema';
import {
IControlPanelModel,
IDict,
IJcadObjectDocChange,
IJupyterCadClientState,
IJupyterCadDoc,
IJupyterCadModel
} from '../types';
import { v4 as uuid } from 'uuid';
import { IControlPanelModel } from '../types';

const visibilityIcon = new LabIcon({
name: 'jupytercad:visibilityIcon',
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/panelview/rightpanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { JupyterCadDoc } from '@jupytercad/schema';
import { SidePanel } from '@jupyterlab/ui-components';

import { JupyterCadDoc } from '../model';
import { IControlPanelModel } from '../types';
import { ControlPanelHeader } from './header';
import { ObjectProperties } from './objectproperties';
Expand Down
3 changes: 2 additions & 1 deletion packages/base/src/sketcher/sketcherdialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IDict, IJupyterCadDoc } from '@jupytercad/schema';
import { Dialog } from '@jupyterlab/apputils';
import * as React from 'react';
import { IDict, IJupyterCadDoc } from '../types';

import { SketcherModel } from './sketchermodel';
import { SketcherReactWidget } from './sketcherwidget';

Expand Down
Loading

0 comments on commit c1c22d2

Please sign in to comment.