From 2ee7120175616a92ebeb8f67239d9e0399d43ec4 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Tue, 22 Feb 2022 00:34:31 -0800 Subject: [PATCH] workbenches framework --- modules/gems/indexType.d.ts | 4 + .../examples/features/occ_bottle/index.ts | 82 +++++---------- .../workbenches/examples/features/registry.ts | 4 - modules/workbenches/examples/index.ts | 17 ++-- .../boolean.operation.ts | 6 +- .../features/extrude/extrude.operation.ts | 5 +- .../{fillet_tool => fillet}/docs/index.md | 0 .../features/{fillet_tool => fillet}/icon.svg | 0 .../{fillet_tool => fillet}/icon32.png | Bin .../{fillet_tool => fillet}/icon96.png | Bin .../modeler/features/fillet/index.ts | 91 +++++++++++++++++ .../modeler/features/fillet_tool/index.ts | 93 ------------------ .../{hole_tool => hole}/docs/index.md | 0 .../features/{hole_tool => hole}/icon.svg | 0 .../features/{hole_tool => hole}/index.ts | 6 +- .../modeler/features/loft/loft.operation.ts | 19 ++-- .../docs/index.md | 0 .../icon32.png | Bin .../icon96.png | Bin .../{primitive_box => primitiveBox}/index.ts | 6 +- .../docs/index.md | 0 .../icon32.png | Bin .../icon96.png | Bin .../index.ts | 6 +- .../docs/index.md | 0 .../icon32.png | Bin .../icon96.png | Bin .../features/primitiveCylinder/index.ts | 68 +++++++++++++ .../docs/index.md | 0 .../icon32.png | Bin .../icon96.png | Bin .../modeler/features/primitiveSphere/index.ts | 62 ++++++++++++ .../docs/index.md | 0 .../icon32.png | Bin .../icon96.png | Bin .../modeler/features/primitiveTorus/index.ts | 70 +++++++++++++ .../features/primitive_cylinder/index.ts | 70 ------------- .../features/primitive_sphere/index.ts | 64 ------------ .../modeler/features/primitive_torus/index.ts | 70 ------------- .../workbenches/modeler/features/registry.ts | 4 - .../revolve.operation.ts | 6 +- .../{shell_tool => shell}/shell.operation.ts | 6 +- modules/workbenches/modeler/index.ts | 70 ++++++++----- modules/workbenches/registry.ts | 11 ++- web/app/cad/actions/actionSystemPlugin.ts | 5 +- .../simplePlane/simplePlaneOpSchema.js | 2 +- .../cad/dom/components/PlugableControlBar.jsx | 5 +- .../cad/dom/components/PlugableToolbar.jsx | 29 +++++- web/app/cad/dom/menu/MenuHolder.jsx | 6 +- web/app/cad/dom/uiPlugin.js | 41 -------- web/app/cad/dom/uiPlugin.ts | 78 +++++++++++++++ web/app/cad/init/startApplication.js | 8 +- web/app/cad/part/partOperationsPlugin.js | 44 --------- web/app/cad/sketch/inPlaceSketcher.js | 12 +-- web/app/cad/sketch/sketcherUIContrib.js | 62 ------------ web/app/cad/sketch/sketcherUIContrib.ts | 80 +++++++++++++++ web/app/cad/{part => workbench}/menuConfig.js | 0 .../cad/{part => workbench}/uiConfigPlugin.js | 6 -- web/app/cad/workbench/workbenchPlugin.ts | 20 ++++ web/app/cad/workbench/workbenchService.ts | 68 +++++++++++++ .../cad/workbench/workbenchesLoaderPlugin.ts | 54 ++++++++++ 61 files changed, 744 insertions(+), 616 deletions(-) create mode 100644 modules/gems/indexType.d.ts delete mode 100644 modules/workbenches/examples/features/registry.ts rename modules/workbenches/modeler/features/{boolean_tool => boolean}/boolean.operation.ts (90%) rename modules/workbenches/modeler/features/{fillet_tool => fillet}/docs/index.md (100%) rename modules/workbenches/modeler/features/{fillet_tool => fillet}/icon.svg (100%) rename modules/workbenches/modeler/features/{fillet_tool => fillet}/icon32.png (100%) rename modules/workbenches/modeler/features/{fillet_tool => fillet}/icon96.png (100%) create mode 100644 modules/workbenches/modeler/features/fillet/index.ts delete mode 100644 modules/workbenches/modeler/features/fillet_tool/index.ts rename modules/workbenches/modeler/features/{hole_tool => hole}/docs/index.md (100%) rename modules/workbenches/modeler/features/{hole_tool => hole}/icon.svg (100%) rename modules/workbenches/modeler/features/{hole_tool => hole}/index.ts (96%) rename modules/workbenches/modeler/features/{primitive_box => primitiveBox}/docs/index.md (100%) rename modules/workbenches/modeler/features/{primitive_box => primitiveBox}/icon32.png (100%) rename modules/workbenches/modeler/features/{primitive_box => primitiveBox}/icon96.png (100%) rename modules/workbenches/modeler/features/{primitive_box => primitiveBox}/index.ts (91%) rename modules/workbenches/modeler/features/{primitive_cone => primitiveCone}/docs/index.md (100%) rename modules/workbenches/modeler/features/{primitive_cone => primitiveCone}/icon32.png (100%) rename modules/workbenches/modeler/features/{primitive_cone => primitiveCone}/icon96.png (100%) rename modules/workbenches/modeler/features/{primitive_cone => primitiveCone}/index.ts (92%) rename modules/workbenches/modeler/features/{primitive_cylinder => primitiveCylinder}/docs/index.md (100%) rename modules/workbenches/modeler/features/{primitive_cylinder => primitiveCylinder}/icon32.png (100%) rename modules/workbenches/modeler/features/{primitive_cylinder => primitiveCylinder}/icon96.png (100%) create mode 100644 modules/workbenches/modeler/features/primitiveCylinder/index.ts rename modules/workbenches/modeler/features/{primitive_sphere => primitiveSphere}/docs/index.md (100%) rename modules/workbenches/modeler/features/{primitive_sphere => primitiveSphere}/icon32.png (100%) rename modules/workbenches/modeler/features/{primitive_sphere => primitiveSphere}/icon96.png (100%) create mode 100644 modules/workbenches/modeler/features/primitiveSphere/index.ts rename modules/workbenches/modeler/features/{primitive_torus => primitiveTorus}/docs/index.md (100%) rename modules/workbenches/modeler/features/{primitive_torus => primitiveTorus}/icon32.png (100%) rename modules/workbenches/modeler/features/{primitive_torus => primitiveTorus}/icon96.png (100%) create mode 100644 modules/workbenches/modeler/features/primitiveTorus/index.ts delete mode 100644 modules/workbenches/modeler/features/primitive_cylinder/index.ts delete mode 100644 modules/workbenches/modeler/features/primitive_sphere/index.ts delete mode 100644 modules/workbenches/modeler/features/primitive_torus/index.ts delete mode 100644 modules/workbenches/modeler/features/registry.ts rename modules/workbenches/modeler/features/{revolve_tool => revolve}/revolve.operation.ts (94%) rename modules/workbenches/modeler/features/{shell_tool => shell}/shell.operation.ts (94%) delete mode 100644 web/app/cad/dom/uiPlugin.js create mode 100644 web/app/cad/dom/uiPlugin.ts delete mode 100644 web/app/cad/part/partOperationsPlugin.js delete mode 100644 web/app/cad/sketch/sketcherUIContrib.js create mode 100644 web/app/cad/sketch/sketcherUIContrib.ts rename web/app/cad/{part => workbench}/menuConfig.js (100%) rename web/app/cad/{part => workbench}/uiConfigPlugin.js (81%) create mode 100644 web/app/cad/workbench/workbenchPlugin.ts create mode 100644 web/app/cad/workbench/workbenchService.ts create mode 100644 web/app/cad/workbench/workbenchesLoaderPlugin.ts diff --git a/modules/gems/indexType.d.ts b/modules/gems/indexType.d.ts new file mode 100644 index 00000000..765444c4 --- /dev/null +++ b/modules/gems/indexType.d.ts @@ -0,0 +1,4 @@ + +export type Index = { + [key: string]: T +}; diff --git a/modules/workbenches/examples/features/occ_bottle/index.ts b/modules/workbenches/examples/features/occ_bottle/index.ts index 45a092d7..9ebda20c 100644 --- a/modules/workbenches/examples/features/occ_bottle/index.ts +++ b/modules/workbenches/examples/features/occ_bottle/index.ts @@ -1,60 +1,28 @@ -import { ApplicationContext } from 'context'; -import { MBrepShell } from 'cad/model/mshell'; -import { roundValueForPresentation as r } from 'cad/craft/operationHelper'; -import { createOCCBottle } from './bottle.occ'; -import { occ2brep } from 'cad/occ/occ2models'; +import {ApplicationContext} from 'context'; +import {MBrepShell} from 'cad/model/mshell'; +import {roundValueForPresentation as r} from 'cad/craft/operationHelper'; +import {createOCCBottle} from './bottle.occ'; +import {occ2brep} from 'cad/occ/occ2models'; import icon from './icon.svg'; +import {OperationDescriptor} from "cad/craft/operationPlugin"; -export default { - id: 'OCC_BOTTLE', - label: 'OCC Bottle', - icon: { - iconType: 'svg', - iconContent: icon - }, - info: 'create occ bottle', - mutualExclusiveFields: [], - paramsInfo: ({ width, height, thickness, color }) => `(${r(width)} ${r(height)} ${r(thickness)} ${r(color)})`, - schema: { - width: { - type: 'number', - defaultValue: 200, - label: 'width' - }, - height: { - type: 'number', - defaultValue: 280, - label: 'height' - }, - thickness: { - type: 'number', - min: 0, - label: 'thickness', - defaultValue: 150 - }, - color: { - type: 'string', - defaultValue: "red", - label: 'Color', - enum: [ - { - label: 'Red', - value: 'red' - }, - { - label: 'Green', - value: 'green' - }, - ], - }, - }, - run: ({ width, height, thickness, color }, ctx: ApplicationContext) => { - const occObj = createOCCBottle(width, height, thickness, ctx.occService.occContext); - const mobject = new MBrepShell(occ2brep(occObj, ctx.occService.occContext)); - console.log(color); - return { - consumed: [], - created: [mobject] - }; - } +export const OCCBottle:OperationDescriptor = { + id: 'OCC_BOTTLE', + label: 'OCC Bottle', + icon: { + iconType: 'svg', + iconContent: icon + }, + info: 'create occ bottle', + paramsInfo: ({width, height, thickness, color}) => `(${r(width)} ${r(height)} ${r(thickness)} ${r(color)})`, + form: [], + run: ({width, height, thickness, color}, ctx: ApplicationContext) => { + const occObj = createOCCBottle(width, height, thickness, ctx.occService.occContext); + const mobject = new MBrepShell(occ2brep(occObj, ctx.occService.occContext)); + console.log(color); + return { + consumed: [], + created: [mobject] + }; + } } diff --git a/modules/workbenches/examples/features/registry.ts b/modules/workbenches/examples/features/registry.ts deleted file mode 100644 index c3811255..00000000 --- a/modules/workbenches/examples/features/registry.ts +++ /dev/null @@ -1,4 +0,0 @@ - - -export default [ -]; \ No newline at end of file diff --git a/modules/workbenches/examples/index.ts b/modules/workbenches/examples/index.ts index 446d4f98..2abea21e 100644 --- a/modules/workbenches/examples/index.ts +++ b/modules/workbenches/examples/index.ts @@ -1,8 +1,13 @@ -import OCC_BOTTLE from './features/occ_bottle'; +import OCCBottle from './features/occ_bottle'; +import {WorkbenchConfig} from "cad/workbench/workbenchService"; -export default { - workbenchId: 'examples', - features: [ - OCC_BOTTLE, - ] +export const ExampleWorkspace: WorkbenchConfig = { + workbenchId: 'examples', + features: [ + OCCBottle, + ], + actions: [], + ui: { + toolbar: [] + } } \ No newline at end of file diff --git a/modules/workbenches/modeler/features/boolean_tool/boolean.operation.ts b/modules/workbenches/modeler/features/boolean/boolean.operation.ts similarity index 90% rename from modules/workbenches/modeler/features/boolean_tool/boolean.operation.ts rename to modules/workbenches/modeler/features/boolean/boolean.operation.ts index d73dd6e1..5834884e 100644 --- a/modules/workbenches/modeler/features/boolean_tool/boolean.operation.ts +++ b/modules/workbenches/modeler/features/boolean/boolean.operation.ts @@ -9,8 +9,8 @@ interface BooleanParams { boolean: BooleanDefinition } -const BooleanOperation: OperationDescriptor = { - id: 'boolean_tool', +export const BooleanOperation: OperationDescriptor = { + id: 'BOOLEAN', label: 'Boolean', icon: 'img/cad/intersection', info: 'Booleans 2D sketch', @@ -46,5 +46,3 @@ const BooleanOperation: OperationDescriptor = { }, ], } - -export default BooleanOperation; \ No newline at end of file diff --git a/modules/workbenches/modeler/features/extrude/extrude.operation.ts b/modules/workbenches/modeler/features/extrude/extrude.operation.ts index 251e2e9f..0b5cecff 100644 --- a/modules/workbenches/modeler/features/extrude/extrude.operation.ts +++ b/modules/workbenches/modeler/features/extrude/extrude.operation.ts @@ -5,7 +5,6 @@ import {EntityKind} from "cad/model/entities"; import {BooleanDefinition} from "cad/craft/schema/common/BooleanDefinition"; import {UnitVector} from "math/vector"; import {OperationDescriptor} from "cad/craft/operationPlugin"; -import { negate } from 'cypress/types/lodash'; interface ExtrudeParams { @@ -16,7 +15,7 @@ interface ExtrudeParams { boolean: BooleanDefinition } -const ExtrudeOperation: OperationDescriptor = { +export const ExtrudeOperation: OperationDescriptor = { id: 'EXTRUDE', label: 'Extrude', icon: 'img/cad/extrude', @@ -137,5 +136,3 @@ const ExtrudeOperation: OperationDescriptor = { ], } - -export default ExtrudeOperation; \ No newline at end of file diff --git a/modules/workbenches/modeler/features/fillet_tool/docs/index.md b/modules/workbenches/modeler/features/fillet/docs/index.md similarity index 100% rename from modules/workbenches/modeler/features/fillet_tool/docs/index.md rename to modules/workbenches/modeler/features/fillet/docs/index.md diff --git a/modules/workbenches/modeler/features/fillet_tool/icon.svg b/modules/workbenches/modeler/features/fillet/icon.svg similarity index 100% rename from modules/workbenches/modeler/features/fillet_tool/icon.svg rename to modules/workbenches/modeler/features/fillet/icon.svg diff --git a/modules/workbenches/modeler/features/fillet_tool/icon32.png b/modules/workbenches/modeler/features/fillet/icon32.png similarity index 100% rename from modules/workbenches/modeler/features/fillet_tool/icon32.png rename to modules/workbenches/modeler/features/fillet/icon32.png diff --git a/modules/workbenches/modeler/features/fillet_tool/icon96.png b/modules/workbenches/modeler/features/fillet/icon96.png similarity index 100% rename from modules/workbenches/modeler/features/fillet_tool/icon96.png rename to modules/workbenches/modeler/features/fillet/icon96.png diff --git a/modules/workbenches/modeler/features/fillet/index.ts b/modules/workbenches/modeler/features/fillet/index.ts new file mode 100644 index 00000000..98748dd3 --- /dev/null +++ b/modules/workbenches/modeler/features/fillet/index.ts @@ -0,0 +1,91 @@ +import {ApplicationContext} from 'context'; +import {roundValueForPresentation as r} from 'cad/craft/operationHelper'; + +import {EntityKind} from "cad/model/entities"; +import {OperationDescriptor} from "cad/craft/operationPlugin"; + +export const FilletOperation: OperationDescriptor = { + id: 'FILLET_TOOL', + label: 'Fillet/Chapher', + icon: 'img/cad/fillet', + info: 'Fillet/Champher', + paramsInfo: ({size, opperationType,}) => `(${r(size)} ${r(opperationType)}})`, + form: [ + { + type: 'selection', + name: 'edges', + capture: [EntityKind.EDGE], + label: 'edges', + multi: true, + defaultValue: { + usePreselection: true, + preselectionIndex: 0 + }, + }, + { + type: 'choice', + style: "dropdown", + label: 'opperationType', + name: 'opperationType', + values: ["Fillet", "Champher"], + defaultValue: "Fillet", + }, + { + type: 'number', + label: 'size', + name: 'size', + defaultValue: 5, + }, + ], + + run: (params, ctx: ApplicationContext) => { + + let occ = ctx.occService; + const oci = occ.commandInterface; + let returnObject = { + consumed: [], + created: [], + } + + var edgesAndValue = []; + + //add all the edges and size to seperate arrays for each shell that edges are selected from + + params.edges.forEach((edge) => { + if (!returnObject.consumed.includes(edge.shell)) { + returnObject.consumed.push(edge.shell); + edgesAndValue[edge.shell.id] = []; + } + + if (params.opperationType == "Fillet") { + //order of parameters is diferent between fillet and champher + edgesAndValue[edge.shell.id].push(params.size); + edgesAndValue[edge.shell.id].push(edge); + } + if (params.opperationType == "Champher") { + //order of parameters is diferent between fillet and champher + edgesAndValue[edge.shell.id].push(edge); + edgesAndValue[edge.shell.id].push(params.size); + } + }); + + //perform the opperations on each of the bodies. + Object.keys(edgesAndValue).forEach((shellToOpperateOnName) => { + var shellToOpperateOn = edgesAndValue[shellToOpperateOnName]; + var newShellName = shellToOpperateOnName + "f"; + + if (params.opperationType == "Fillet") oci.blend(newShellName, shellToOpperateOn[1].shell, ...shellToOpperateOn); + if (params.opperationType == "Champher") oci.chamf(newShellName, shellToOpperateOn[0].shell, ...shellToOpperateOn); + + returnObject.created.push(occ.io.getShell(newShellName)); + }); + + + console.log(returnObject); + + + return returnObject; + }, + +} + diff --git a/modules/workbenches/modeler/features/fillet_tool/index.ts b/modules/workbenches/modeler/features/fillet_tool/index.ts deleted file mode 100644 index 9588632a..00000000 --- a/modules/workbenches/modeler/features/fillet_tool/index.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { ApplicationContext } from 'context'; -import { MBrepShell } from 'cad/model/mshell'; -import { roundValueForPresentation as r } from 'cad/craft/operationHelper'; -import { occ2brep } from 'cad/occ/occ2models'; - -import { EntityKind } from "cad/model/entities"; - -export default { - id: 'fillet_tool', - label: 'Fillet/Chapher', - icon: 'img/cad/fillet', - info: 'Fillet/Champher', - mutualExclusiveFields: [], - paramsInfo: ({ size, opperationType, }) => `(${r(size)} ${r(opperationType)}})`, - form: [ - { - type: 'selection', - name: 'edges', - capture: [EntityKind.EDGE], - label: 'edges', - multi: true, - defaultValue: { - usePreselection: true, - preselectionIndex: 0 - }, - }, - { - type: 'choice', - style: "dropdown", - label: 'opperationType', - name: 'opperationType', - values: ["Fillet", "Champher"], - defaultValue: "Fillet", - }, - { - type: 'number', - label: 'size', - name: 'size', - defaultValue: 5, - }, - ], - - run: (params, ctx: ApplicationContext) => { - - let occ = ctx.occService; - const oci = occ.commandInterface; - let returnObject = { - consumed: [], - created: [], - } - - var edgesAndValue = []; - - //add all the edges and size to seperate arrays for each shell that edges are selected from - - params.edges.forEach((edge) => { - if (!returnObject.consumed.includes(edge.shell)) { - returnObject.consumed.push(edge.shell); - edgesAndValue[edge.shell.id] = []; - } - - if (params.opperationType == "Fillet") { - //order of parameters is diferent between fillet and champher - edgesAndValue[edge.shell.id].push(params.size); - edgesAndValue[edge.shell.id].push(edge); - } - if (params.opperationType == "Champher") { - //order of parameters is diferent between fillet and champher - edgesAndValue[edge.shell.id].push(edge); - edgesAndValue[edge.shell.id].push(params.size); - } - }); - - //perform the opperations on each of the bodies. - Object.keys(edgesAndValue).forEach((shellToOpperateOnName) => { - var shellToOpperateOn = edgesAndValue[shellToOpperateOnName]; - var newShellName = shellToOpperateOnName + "f"; - - if (params.opperationType == "Fillet") oci.blend(newShellName, shellToOpperateOn[1].shell, ...shellToOpperateOn); - if (params.opperationType == "Champher") oci.chamf(newShellName, shellToOpperateOn[0].shell, ...shellToOpperateOn); - - returnObject.created.push(occ.io.getShell(newShellName)); - }); - - - console.log(returnObject); - - - return returnObject; - }, - -} - diff --git a/modules/workbenches/modeler/features/hole_tool/docs/index.md b/modules/workbenches/modeler/features/hole/docs/index.md similarity index 100% rename from modules/workbenches/modeler/features/hole_tool/docs/index.md rename to modules/workbenches/modeler/features/hole/docs/index.md diff --git a/modules/workbenches/modeler/features/hole_tool/icon.svg b/modules/workbenches/modeler/features/hole/icon.svg similarity index 100% rename from modules/workbenches/modeler/features/hole_tool/icon.svg rename to modules/workbenches/modeler/features/hole/icon.svg diff --git a/modules/workbenches/modeler/features/hole_tool/index.ts b/modules/workbenches/modeler/features/hole/index.ts similarity index 96% rename from modules/workbenches/modeler/features/hole_tool/index.ts rename to modules/workbenches/modeler/features/hole/index.ts index a186cc10..839d034d 100644 --- a/modules/workbenches/modeler/features/hole_tool/index.ts +++ b/modules/workbenches/modeler/features/hole/index.ts @@ -14,8 +14,8 @@ interface HoleParams { holeType: string; } -const HoleOperation: OperationDescriptor = { - id: 'hole_tool', +export const HoleOperation: OperationDescriptor = { + id: 'HOLE_TOOL', label: 'hole', icon: 'img/cad/Shell', info: 'creates hole features', @@ -136,5 +136,3 @@ const HoleOperation: OperationDescriptor = { }, ], } - -export default HoleOperation; \ No newline at end of file diff --git a/modules/workbenches/modeler/features/loft/loft.operation.ts b/modules/workbenches/modeler/features/loft/loft.operation.ts index 4a17afa6..bf41c14c 100644 --- a/modules/workbenches/modeler/features/loft/loft.operation.ts +++ b/modules/workbenches/modeler/features/loft/loft.operation.ts @@ -1,11 +1,8 @@ -import { roundValueForPresentation as r } from 'cad/craft/operationHelper'; -import { MFace } from "cad/model/mface"; -import { ApplicationContext } from "context"; -import { EntityKind } from "cad/model/entities"; -import { BooleanDefinition } from "cad/craft/schema/common/BooleanDefinition"; -import { UnitVector } from "math/vector"; -import { OperationDescriptor } from "cad/craft/operationPlugin"; -import { negate } from 'cypress/types/lodash'; +import {roundValueForPresentation as r} from 'cad/craft/operationHelper'; +import {ApplicationContext} from "context"; +import {EntityKind} from "cad/model/entities"; +import {BooleanDefinition} from "cad/craft/schema/common/BooleanDefinition"; +import {OperationDescriptor} from "cad/craft/operationPlugin"; import {MSketchLoop} from "cad/model/mloop"; @@ -15,8 +12,8 @@ interface LoftParams { loftType: string; } -const LoftOperation: OperationDescriptor = { - id: 'loft', +export const LoftOperation: OperationDescriptor = { + id: 'LOFT', label: 'Loft', icon: 'img/cad/loft', info: 'Lofts 2D sketch', @@ -81,5 +78,3 @@ const LoftOperation: OperationDescriptor = { ], } - -export default LoftOperation; \ No newline at end of file diff --git a/modules/workbenches/modeler/features/primitive_box/docs/index.md b/modules/workbenches/modeler/features/primitiveBox/docs/index.md similarity index 100% rename from modules/workbenches/modeler/features/primitive_box/docs/index.md rename to modules/workbenches/modeler/features/primitiveBox/docs/index.md diff --git a/modules/workbenches/modeler/features/primitive_box/icon32.png b/modules/workbenches/modeler/features/primitiveBox/icon32.png similarity index 100% rename from modules/workbenches/modeler/features/primitive_box/icon32.png rename to modules/workbenches/modeler/features/primitiveBox/icon32.png diff --git a/modules/workbenches/modeler/features/primitive_box/icon96.png b/modules/workbenches/modeler/features/primitiveBox/icon96.png similarity index 100% rename from modules/workbenches/modeler/features/primitive_box/icon96.png rename to modules/workbenches/modeler/features/primitiveBox/icon96.png diff --git a/modules/workbenches/modeler/features/primitive_box/index.ts b/modules/workbenches/modeler/features/primitiveBox/index.ts similarity index 91% rename from modules/workbenches/modeler/features/primitive_box/index.ts rename to modules/workbenches/modeler/features/primitiveBox/index.ts index 1a52cd48..500fb134 100644 --- a/modules/workbenches/modeler/features/primitive_box/index.ts +++ b/modules/workbenches/modeler/features/primitiveBox/index.ts @@ -13,8 +13,8 @@ interface PrimitiveBoxParams { boolean: BooleanDefinition, } -const PrimitiveBoxOperation: OperationDescriptor = { - id: 'primitive_box', +export const PrimitiveBoxOperation: OperationDescriptor = { + id: 'PRIMITIVE_BOX', label: 'Primitive Box', icon: 'img/cad/cube', info: 'Primitive Box', @@ -73,5 +73,3 @@ const PrimitiveBoxOperation: OperationDescriptor = { }, } - -export default PrimitiveBoxOperation; \ No newline at end of file diff --git a/modules/workbenches/modeler/features/primitive_cone/docs/index.md b/modules/workbenches/modeler/features/primitiveCone/docs/index.md similarity index 100% rename from modules/workbenches/modeler/features/primitive_cone/docs/index.md rename to modules/workbenches/modeler/features/primitiveCone/docs/index.md diff --git a/modules/workbenches/modeler/features/primitive_cone/icon32.png b/modules/workbenches/modeler/features/primitiveCone/icon32.png similarity index 100% rename from modules/workbenches/modeler/features/primitive_cone/icon32.png rename to modules/workbenches/modeler/features/primitiveCone/icon32.png diff --git a/modules/workbenches/modeler/features/primitive_cone/icon96.png b/modules/workbenches/modeler/features/primitiveCone/icon96.png similarity index 100% rename from modules/workbenches/modeler/features/primitive_cone/icon96.png rename to modules/workbenches/modeler/features/primitiveCone/icon96.png diff --git a/modules/workbenches/modeler/features/primitive_cone/index.ts b/modules/workbenches/modeler/features/primitiveCone/index.ts similarity index 92% rename from modules/workbenches/modeler/features/primitive_cone/index.ts rename to modules/workbenches/modeler/features/primitiveCone/index.ts index 6f3a1a7a..e50bbc4d 100644 --- a/modules/workbenches/modeler/features/primitive_cone/index.ts +++ b/modules/workbenches/modeler/features/primitiveCone/index.ts @@ -13,8 +13,8 @@ interface PrimitiveConeParams { boolean: BooleanDefinition, } -const PrimitiveConeOperation: OperationDescriptor = { - id: 'primitive_cone', +export const PrimitiveConeOperation: OperationDescriptor = { + id: 'PRIMITIVE_CONE', label: 'Primitive Cone', icon: 'img/cad/cone', info: 'Primitive Cone', @@ -73,5 +73,3 @@ const PrimitiveConeOperation: OperationDescriptor = { }, } - -export default PrimitiveConeOperation; \ No newline at end of file diff --git a/modules/workbenches/modeler/features/primitive_cylinder/docs/index.md b/modules/workbenches/modeler/features/primitiveCylinder/docs/index.md similarity index 100% rename from modules/workbenches/modeler/features/primitive_cylinder/docs/index.md rename to modules/workbenches/modeler/features/primitiveCylinder/docs/index.md diff --git a/modules/workbenches/modeler/features/primitive_cylinder/icon32.png b/modules/workbenches/modeler/features/primitiveCylinder/icon32.png similarity index 100% rename from modules/workbenches/modeler/features/primitive_cylinder/icon32.png rename to modules/workbenches/modeler/features/primitiveCylinder/icon32.png diff --git a/modules/workbenches/modeler/features/primitive_cylinder/icon96.png b/modules/workbenches/modeler/features/primitiveCylinder/icon96.png similarity index 100% rename from modules/workbenches/modeler/features/primitive_cylinder/icon96.png rename to modules/workbenches/modeler/features/primitiveCylinder/icon96.png diff --git a/modules/workbenches/modeler/features/primitiveCylinder/index.ts b/modules/workbenches/modeler/features/primitiveCylinder/index.ts new file mode 100644 index 00000000..276126a0 --- /dev/null +++ b/modules/workbenches/modeler/features/primitiveCylinder/index.ts @@ -0,0 +1,68 @@ +import {ApplicationContext} from 'context'; +import {roundValueForPresentation as r} from 'cad/craft/operationHelper'; +import {EntityKind} from "cad/model/entities"; +import {BooleanDefinition} from "cad/craft/schema/common/BooleanDefinition"; +import {OperationDescriptor} from "cad/craft/operationPlugin"; + + +interface PrimitiveCylinderParams { + diameter: number, + height: number, + locations: {}, + boolean: BooleanDefinition, +} + +export const PrimitiveCylinderOperation: OperationDescriptor = { + id: 'PRIMITIVE_CYLINDER', + label: 'Primitive cylinder', + icon: 'img/cad/cylinder', + info: 'Primitive Cylinder', + paramsInfo: ({height, diameter}) => `(${r(height)} , ${r(diameter)} )`, + form: [ + { + type: 'number', + label: 'Diameter', + name: 'diameter', + defaultValue: 50, + }, + { + type: 'number', + label: 'Height', + name: 'height', + defaultValue: 50, + }, + { + type: 'selection', + name: 'locations', + capture: [EntityKind.DATUM], + label: 'locations', + multi: false, + optional: true, + defaultValue: { + usePreselection: true, + preselectionIndex: 0 + }, + }, + + { + type: 'boolean', + name: 'boolean', + label: 'boolean', + optional: true, + } + + ], + + + run: (params: PrimitiveCylinderParams, ctx: ApplicationContext) => { + + let occ = ctx.occService; + const oci = occ.commandInterface; + + //pcylinder cy 5 10 + oci.pcylinder("cy", params.diameter / 2, params.height); + + return occ.utils.applyBooleanModifier(["cy"], params.boolean); + + }, +} diff --git a/modules/workbenches/modeler/features/primitive_sphere/docs/index.md b/modules/workbenches/modeler/features/primitiveSphere/docs/index.md similarity index 100% rename from modules/workbenches/modeler/features/primitive_sphere/docs/index.md rename to modules/workbenches/modeler/features/primitiveSphere/docs/index.md diff --git a/modules/workbenches/modeler/features/primitive_sphere/icon32.png b/modules/workbenches/modeler/features/primitiveSphere/icon32.png similarity index 100% rename from modules/workbenches/modeler/features/primitive_sphere/icon32.png rename to modules/workbenches/modeler/features/primitiveSphere/icon32.png diff --git a/modules/workbenches/modeler/features/primitive_sphere/icon96.png b/modules/workbenches/modeler/features/primitiveSphere/icon96.png similarity index 100% rename from modules/workbenches/modeler/features/primitive_sphere/icon96.png rename to modules/workbenches/modeler/features/primitiveSphere/icon96.png diff --git a/modules/workbenches/modeler/features/primitiveSphere/index.ts b/modules/workbenches/modeler/features/primitiveSphere/index.ts new file mode 100644 index 00000000..e7fab5c8 --- /dev/null +++ b/modules/workbenches/modeler/features/primitiveSphere/index.ts @@ -0,0 +1,62 @@ +import {ApplicationContext} from 'context'; +import {roundValueForPresentation as r} from 'cad/craft/operationHelper'; +import {EntityKind} from "cad/model/entities"; +import {BooleanDefinition} from "cad/craft/schema/common/BooleanDefinition"; +import {OperationDescriptor} from "cad/craft/operationPlugin"; + + +interface PrimitiveSphereParams { + radius: number, + locations: {}, + boolean: BooleanDefinition, +} + +export const PrimitiveSphereOperation: OperationDescriptor = { + id: 'PRIMITIVE_SPHERE', + label: 'Primitive Sphere', + icon: 'img/cad/sphere', + info: 'Primitive Sphere', + paramsInfo: ({radius,}) => `(${r(radius)} )`, + form: [ + { + type: 'number', + label: 'Radius', + name: 'radius', + defaultValue: 50, + }, + + { + type: 'selection', + name: 'locations', + capture: [EntityKind.DATUM], + label: 'locations', + multi: false, + optional: true, + defaultValue: { + usePreselection: true, + preselectionIndex: 0 + }, + }, + + { + type: 'boolean', + name: 'boolean', + label: 'boolean', + optional: true, + } + + ], + + + run: (params: PrimitiveSphereParams, ctx: ApplicationContext) => { + + let occ = ctx.occService; + const oci = occ.commandInterface; + + //pSphere cy 5 10 + oci.psphere("Sphere", params.radius); + + return occ.utils.applyBooleanModifier(["Sphere"], params.boolean); + + }, +} diff --git a/modules/workbenches/modeler/features/primitive_torus/docs/index.md b/modules/workbenches/modeler/features/primitiveTorus/docs/index.md similarity index 100% rename from modules/workbenches/modeler/features/primitive_torus/docs/index.md rename to modules/workbenches/modeler/features/primitiveTorus/docs/index.md diff --git a/modules/workbenches/modeler/features/primitive_torus/icon32.png b/modules/workbenches/modeler/features/primitiveTorus/icon32.png similarity index 100% rename from modules/workbenches/modeler/features/primitive_torus/icon32.png rename to modules/workbenches/modeler/features/primitiveTorus/icon32.png diff --git a/modules/workbenches/modeler/features/primitive_torus/icon96.png b/modules/workbenches/modeler/features/primitiveTorus/icon96.png similarity index 100% rename from modules/workbenches/modeler/features/primitive_torus/icon96.png rename to modules/workbenches/modeler/features/primitiveTorus/icon96.png diff --git a/modules/workbenches/modeler/features/primitiveTorus/index.ts b/modules/workbenches/modeler/features/primitiveTorus/index.ts new file mode 100644 index 00000000..feb26030 --- /dev/null +++ b/modules/workbenches/modeler/features/primitiveTorus/index.ts @@ -0,0 +1,70 @@ +import {ApplicationContext} from 'context'; +import {roundValueForPresentation as r} from 'cad/craft/operationHelper'; +import {EntityKind} from "cad/model/entities"; +import {BooleanDefinition} from "cad/craft/schema/common/BooleanDefinition"; +import {OperationDescriptor} from "cad/craft/operationPlugin"; + + +interface PrimitiveTorusParams { + radius: number, + tubeRadius: number, + locations: {}, + boolean: BooleanDefinition, +} + +const PrimitiveTorusOperation: OperationDescriptor = { + id: 'PRIMITIVE_TORUS', + label: 'Primitive Torus', + icon: 'img/cad/torus', + info: 'Primitive Torus', + paramsInfo: ({radius, tubeRadius}) => `(${r(radius)} , ${r(tubeRadius)} )`, + form: [ + { + type: 'number', + label: 'Radius', + name: 'radius', + defaultValue: 50, + }, + { + type: 'number', + label: 'Tube Radius', + name: 'tubeRadius', + defaultValue: 10, + }, + { + type: 'selection', + name: 'locations', + capture: [EntityKind.DATUM], + label: 'locations', + multi: false, + optional: true, + defaultValue: { + usePreselection: true, + preselectionIndex: 0 + }, + }, + + { + type: 'boolean', + name: 'boolean', + label: 'boolean', + optional: true, + } + + ], + + + run: (params: PrimitiveTorusParams, ctx: ApplicationContext) => { + + let occ = ctx.occService; + const oci = occ.commandInterface; + + //pTorus cy 5 10 + oci.ptorus("torus", params.radius, params.tubeRadius); + + return occ.utils.applyBooleanModifier(["torus"], params.boolean); + + }, +} + +export default PrimitiveTorusOperation; \ No newline at end of file diff --git a/modules/workbenches/modeler/features/primitive_cylinder/index.ts b/modules/workbenches/modeler/features/primitive_cylinder/index.ts deleted file mode 100644 index 9a14d72f..00000000 --- a/modules/workbenches/modeler/features/primitive_cylinder/index.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { ApplicationContext } from 'context'; -import { roundValueForPresentation as r } from 'cad/craft/operationHelper'; -import { EntityKind } from "cad/model/entities"; -import { BooleanDefinition } from "cad/craft/schema/common/BooleanDefinition"; -import { OperationDescriptor } from "cad/craft/operationPlugin"; - - -interface PrimitiveCylinderParams { - diameter: number, - height: number, - locations: {}, - boolean: BooleanDefinition, -} - -const PrimitiveCylinderOperation: OperationDescriptor = { - id: 'primitive_cylinder', - label: 'Primitive cylinder', - icon: 'img/cad/cylinder', - info: 'Primitive Cylinder', - paramsInfo: ({ height, diameter}) => `(${r(height)} , ${r(diameter)} )`, - form: [ - { - type: 'number', - label: 'Diameter', - name: 'diameter', - defaultValue: 50, - }, - { - type: 'number', - label: 'Height', - name: 'height', - defaultValue: 50, - }, - { - type: 'selection', - name: 'locations', - capture: [EntityKind.DATUM], - label: 'locations', - multi: false, - optional: true, - defaultValue: { - usePreselection: true, - preselectionIndex: 0 - }, - }, - - { - type: 'boolean', - name: 'boolean', - label: 'boolean', - optional: true, - } - - ], - - - run: (params: PrimitiveCylinderParams, ctx: ApplicationContext) => { - - let occ = ctx.occService; - const oci = occ.commandInterface; - - //pcylinder cy 5 10 - oci.pcylinder("cy", params.diameter/2, params.height); - - return occ.utils.applyBooleanModifier(["cy"], params.boolean); - - }, -} - -export default PrimitiveCylinderOperation; \ No newline at end of file diff --git a/modules/workbenches/modeler/features/primitive_sphere/index.ts b/modules/workbenches/modeler/features/primitive_sphere/index.ts deleted file mode 100644 index 4a33b5fc..00000000 --- a/modules/workbenches/modeler/features/primitive_sphere/index.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { ApplicationContext } from 'context'; -import { roundValueForPresentation as r } from 'cad/craft/operationHelper'; -import { EntityKind } from "cad/model/entities"; -import { BooleanDefinition } from "cad/craft/schema/common/BooleanDefinition"; -import { OperationDescriptor } from "cad/craft/operationPlugin"; - - -interface PrimitiveSphereParams { - radius: number, - locations: {}, - boolean: BooleanDefinition, -} - -const PrimitiveSphereOperation: OperationDescriptor = { - id: 'primitive_sphere', - label: 'Primitive Sphere', - icon: 'img/cad/sphere', - info: 'Primitive Sphere', - paramsInfo: ({ radius, }) => `(${r(radius)} )`, - form: [ - { - type: 'number', - label: 'Radius', - name: 'radius', - defaultValue: 50, - }, - - { - type: 'selection', - name: 'locations', - capture: [EntityKind.DATUM], - label: 'locations', - multi: false, - optional: true, - defaultValue: { - usePreselection: true, - preselectionIndex: 0 - }, - }, - - { - type: 'boolean', - name: 'boolean', - label: 'boolean', - optional: true, - } - - ], - - - run: (params: PrimitiveSphereParams, ctx: ApplicationContext) => { - - let occ = ctx.occService; - const oci = occ.commandInterface; - - //pSphere cy 5 10 - oci.psphere("Sphere", params.radius); - - return occ.utils.applyBooleanModifier(["Sphere"], params.boolean); - - }, -} - -export default PrimitiveSphereOperation; \ No newline at end of file diff --git a/modules/workbenches/modeler/features/primitive_torus/index.ts b/modules/workbenches/modeler/features/primitive_torus/index.ts deleted file mode 100644 index 4015a222..00000000 --- a/modules/workbenches/modeler/features/primitive_torus/index.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { ApplicationContext } from 'context'; -import { roundValueForPresentation as r } from 'cad/craft/operationHelper'; -import { EntityKind } from "cad/model/entities"; -import { BooleanDefinition } from "cad/craft/schema/common/BooleanDefinition"; -import { OperationDescriptor } from "cad/craft/operationPlugin"; - - -interface PrimitiveTorusParams { - radius: number, - tubeRadius: number, - locations: {}, - boolean: BooleanDefinition, -} - -const PrimitiveTorusOperation: OperationDescriptor = { - id: 'primitive_torus', - label: 'Primitive Torus', - icon: 'img/cad/torus', - info: 'Primitive Torus', - paramsInfo: ({ radius, tubeRadius }) => `(${r(radius)} , ${r(tubeRadius)} )`, - form: [ - { - type: 'number', - label: 'Radius', - name: 'radius', - defaultValue: 50, - }, - { - type: 'number', - label: 'Tube Radius', - name: 'tubeRadius', - defaultValue: 10, - }, - { - type: 'selection', - name: 'locations', - capture: [EntityKind.DATUM], - label: 'locations', - multi: false, - optional: true, - defaultValue: { - usePreselection: true, - preselectionIndex: 0 - }, - }, - - { - type: 'boolean', - name: 'boolean', - label: 'boolean', - optional: true, - } - - ], - - - run: (params: PrimitiveTorusParams, ctx: ApplicationContext) => { - - let occ = ctx.occService; - const oci = occ.commandInterface; - - //pTorus cy 5 10 - oci.ptorus("torus", params.radius, params.tubeRadius); - - return occ.utils.applyBooleanModifier(["torus"], params.boolean); - - }, -} - -export default PrimitiveTorusOperation; \ No newline at end of file diff --git a/modules/workbenches/modeler/features/registry.ts b/modules/workbenches/modeler/features/registry.ts deleted file mode 100644 index c3811255..00000000 --- a/modules/workbenches/modeler/features/registry.ts +++ /dev/null @@ -1,4 +0,0 @@ - - -export default [ -]; \ No newline at end of file diff --git a/modules/workbenches/modeler/features/revolve_tool/revolve.operation.ts b/modules/workbenches/modeler/features/revolve/revolve.operation.ts similarity index 94% rename from modules/workbenches/modeler/features/revolve_tool/revolve.operation.ts rename to modules/workbenches/modeler/features/revolve/revolve.operation.ts index 95773f3a..6a24d94f 100644 --- a/modules/workbenches/modeler/features/revolve_tool/revolve.operation.ts +++ b/modules/workbenches/modeler/features/revolve/revolve.operation.ts @@ -13,8 +13,8 @@ interface RevolveParams { boolean: BooleanDefinition } -const RevolveOperation: OperationDescriptor = { - id: 'Revolve', +export const RevolveOperation: OperationDescriptor = { + id: 'REVOLVE', label: 'Revolve', icon: 'img/cad/revolve', info: 'Revolves 2D sketch', @@ -77,5 +77,3 @@ const RevolveOperation: OperationDescriptor = { ], } - -export default RevolveOperation; \ No newline at end of file diff --git a/modules/workbenches/modeler/features/shell_tool/shell.operation.ts b/modules/workbenches/modeler/features/shell/shell.operation.ts similarity index 94% rename from modules/workbenches/modeler/features/shell_tool/shell.operation.ts rename to modules/workbenches/modeler/features/shell/shell.operation.ts index 07db0552..e7d4838f 100644 --- a/modules/workbenches/modeler/features/shell_tool/shell.operation.ts +++ b/modules/workbenches/modeler/features/shell/shell.operation.ts @@ -10,8 +10,8 @@ interface ShellParams { faces: [MFace]; } -const ShellOperation: OperationDescriptor = { - id: 'shell_tool', +export const ShellOperation: OperationDescriptor = { + id: 'SHELL_TOOL', label: 'Shell', icon: 'img/cad/shell', info: 'Shells 2D sketch', @@ -76,5 +76,3 @@ const ShellOperation: OperationDescriptor = { }, ], } - -export default ShellOperation; \ No newline at end of file diff --git a/modules/workbenches/modeler/index.ts b/modules/workbenches/modeler/index.ts index 776bcabd..bd0b00ca 100644 --- a/modules/workbenches/modeler/index.ts +++ b/modules/workbenches/modeler/index.ts @@ -1,31 +1,47 @@ -import EXTRUDE from './features/extrude/extrude.operation'; -import RevolveOperation from './features/revolve_tool/revolve.operation'; -import primitive_box from './features/primitive_box'; -import primitive_cone from './features/primitive_cone'; -import primitive_cylinder from './features/primitive_cylinder'; -import primitive_sphere from './features/primitive_sphere'; -import primitive_torus from './features/primitive_torus'; -import hole_tool from './features/hole_tool'; -import fillet_tool from './features/fillet_tool'; -import boolean_tool from './features/boolean_tool/boolean.operation'; -import ShellOperation from './features/shell_tool/shell.operation'; -import loft from './features/loft/loft.operation' +import {ExtrudeOperation} from './features/extrude/extrude.operation'; +import {LoftOperation} from './features/loft/loft.operation' +import {WorkbenchConfig} from "cad/workbench/workbenchService"; +import {PrimitiveBoxOperation} from "workbenches/modeler/features/primitiveBox"; +import {PrimitiveConeOperation} from "workbenches/modeler/features/primitiveCone"; +import {PrimitiveCylinderOperation} from "workbenches/modeler/features/primitiveCylinder"; +import {PrimitiveSphereOperation} from "workbenches/modeler/features/primitiveSphere"; +import PrimitiveTorusOperation from "workbenches/modeler/features/primitiveTorus"; +import {HoleOperation} from "workbenches/modeler/features/hole"; +import {FilletOperation} from "workbenches/modeler/features/fillet"; +import {BooleanOperation} from "workbenches/modeler/features/boolean/boolean.operation"; +import {RevolveOperation} from "workbenches/modeler/features/revolve/revolve.operation"; +import {ShellOperation} from "workbenches/modeler/features/shell/shell.operation"; -export default { +export const ModelerWorkspace: WorkbenchConfig = { - workbenchId: 'modeler', - features: [ - EXTRUDE, - primitive_box, - primitive_cone, - primitive_cylinder, - primitive_sphere, - primitive_torus, - hole_tool, - fillet_tool, - RevolveOperation, - boolean_tool, - ShellOperation, - loft, + workbenchId: 'modeler', + features: [ + ExtrudeOperation, + PrimitiveBoxOperation, + PrimitiveConeOperation, + PrimitiveCylinderOperation, + PrimitiveSphereOperation, + PrimitiveTorusOperation, + HoleOperation, + FilletOperation, + RevolveOperation, + BooleanOperation, + ShellOperation, + LoftOperation, + ], + actions: [], + ui:{ + toolbar: [ + 'DATUM_CREATE', 'PLANE', 'EditFace', '-', + "OCC_BOTTLE", '-', + "EXTRUDE", "REVOLVE", "LOFT","-", "BOOLEAN", "SHELL_TOOL", + "PRIMITIVE_CYLINDER", + "PRIMITIVE_BOX", + "PRIMITIVE_CONE", + "PRIMITIVE_SPHERE", + "PRIMITIVE_TORUS", + "HOLE_TOOL", + "FILLET_TOOL" ] + } } \ No newline at end of file diff --git a/modules/workbenches/registry.ts b/modules/workbenches/registry.ts index fea5b8c4..cba179ed 100644 --- a/modules/workbenches/registry.ts +++ b/modules/workbenches/registry.ts @@ -1,7 +1,8 @@ -import ModelerWorkbench from './modeler'; -import ExampleWorkbench from './examples'; +import {ModelerWorkspace} from "workbenches/modeler"; +import {ExampleWorkspace} from "workbenches/examples"; +import {WorkbenchConfig} from "cad/workbench/workbenchService"; -export default [ - ModelerWorkbench, - ExampleWorkbench, +export const WorkbenchRegistry: WorkbenchConfig[] = [ + ModelerWorkspace, + // ExampleWorkspace, ] \ No newline at end of file diff --git a/web/app/cad/actions/actionSystemPlugin.ts b/web/app/cad/actions/actionSystemPlugin.ts index dc96791f..aa67df29 100644 --- a/web/app/cad/actions/actionSystemPlugin.ts +++ b/web/app/cad/actions/actionSystemPlugin.ts @@ -2,14 +2,13 @@ import {enableAnonymousActionHint} from './anonHint'; import * as stream from 'lstream'; import {state, StateStream, Stream} from 'lstream'; import {LOG_FLAGS} from '../logFlags'; -import {CoreContext} from "context"; +import {ApplicationContext} from "context"; import {IconType} from "react-icons"; -export function activate(context: CoreContext) { +export function activate(context: ApplicationContext) { let {streams} = context; - const appearanceStreams: ActionAppearanceStreams = {}; const stateStreams: ActionStateStreams = {}; const hint$: StateStream = state(null); diff --git a/web/app/cad/craft/primitives/simplePlane/simplePlaneOpSchema.js b/web/app/cad/craft/primitives/simplePlane/simplePlaneOpSchema.js index cc1befa2..165cf07d 100644 --- a/web/app/cad/craft/primitives/simplePlane/simplePlaneOpSchema.js +++ b/web/app/cad/craft/primitives/simplePlane/simplePlaneOpSchema.js @@ -6,7 +6,7 @@ export default { }, parallelTo: { type: 'entity', - allowedKinds: 'face', + allowedKinds: ['face'], optional: true, }, depth: { diff --git a/web/app/cad/dom/components/PlugableControlBar.jsx b/web/app/cad/dom/components/PlugableControlBar.jsx index 34d5e408..ad2ec0a8 100644 --- a/web/app/cad/dom/components/PlugableControlBar.jsx +++ b/web/app/cad/dom/components/PlugableControlBar.jsx @@ -7,6 +7,7 @@ import {isMenuAction} from '../menu/menuPlugin'; import {menuAboveElementHint} from '../menu/menuUtils'; import {useStream} from "ui/effects"; import {ActionButtonBehavior} from "../../actions/ActionButtonBehavior"; +import {NonExistentAppearance, NonExistentState} from "cad/dom/components/PlugableToolbar"; export default function PlugableControlBar() { return } right={}/>; @@ -44,8 +45,8 @@ function ConnectedActionButton(props) { const actionId = props.actionId; - const actionAppearance = useStream(ctx => ctx.streams.action.appearance[actionId]); - const actionState = useStream(ctx => ctx.streams.action.state[actionId]); + const actionAppearance = useStream(ctx => (ctx.streams.action.appearance[actionId] || NonExistentAppearance(actionId))); + const actionState = useStream(ctx => ctx.streams.action.state[actionId] || NonExistentState); if (!actionAppearance || !actionState) { return null; diff --git a/web/app/cad/dom/components/PlugableToolbar.jsx b/web/app/cad/dom/components/PlugableToolbar.jsx index 47233abc..4d2eff8c 100644 --- a/web/app/cad/dom/components/PlugableToolbar.jsx +++ b/web/app/cad/dom/components/PlugableToolbar.jsx @@ -5,9 +5,11 @@ import ImgIcon from 'ui/components/ImgIcon'; import {toIdAndOverrides} from '../../actions/actionRef'; import {ActionButtonBehavior} from '../../actions/ActionButtonBehavior'; import capitalize from 'gems/capitalize'; -import {combine} from 'lstream'; +import {constant} from 'lstream'; import {useStream} from "ui/effects"; import {NoIcon} from "../../../sketcher/icons/NoIcon"; +import {GrCircleQuestion} from "react-icons/all"; +import {memoize} from "lodash/function"; function ConfigurableToolbar({actions, size, ...props}) { return @@ -64,11 +66,32 @@ function ActionButton({label, icon, icon96, icon32, cssIcons, symbol, size = 'la } +const K = constant({ + info: "unknown action: ", + label: "unknown action ", + icon: GrCircleQuestion +}) + +export const NonExistentAppearance = memoize((actionId) => { + debugger + return constant({ + info: "unknown action: " + actionId, + label: "unknown action " + actionId, + icon: () => ?{actionId}? + }) +}) + +export const NonExistentState = constant({ + enabled: true, + visible: true +}); + + export function ConnectedActionButton(props) { const actionId = props.actionId; - const actionAppearance = useStream(ctx => ctx.streams.action.appearance[actionId]); - const actionState = useStream(ctx => ctx.streams.action.state[actionId]); + const actionAppearance = useStream(ctx => (ctx.streams.action.appearance[actionId] || NonExistentAppearance(actionId))); + const actionState = useStream(ctx => ctx.streams.action.state[actionId] || NonExistentState); if (!actionAppearance || !actionState) { return null; } diff --git a/web/app/cad/dom/menu/MenuHolder.jsx b/web/app/cad/dom/menu/MenuHolder.jsx index 6ef13f8a..0fde1d56 100644 --- a/web/app/cad/dom/menu/MenuHolder.jsx +++ b/web/app/cad/dom/menu/MenuHolder.jsx @@ -6,6 +6,7 @@ import {ActionButtonBehavior} from '../../actions/ActionButtonBehavior'; import connect from 'ui/connect'; import {combine, merger} from 'lstream'; import {useStream} from "ui/effects"; +import {NonExistentAppearance, NonExistentState} from "cad/dom/components/PlugableToolbar"; function MenuHolder({menus}) { return menus.map(({id, actions}) => ); @@ -58,9 +59,8 @@ export function ConnectedMenuItem(props) { const actionId = props.actionId; - const actionAppearance = useStream(ctx => ctx.streams.action.appearance[actionId]); - const actionState = useStream(ctx => ctx.streams.action.state[actionId]); - + const actionAppearance = useStream(ctx => (ctx.streams.action.appearance[actionId] || NonExistentAppearance(actionId))); + const actionState = useStream(ctx => ctx.streams.action.state[actionId] || NonExistentState); if (!actionAppearance || !actionState) { return null; diff --git a/web/app/cad/dom/uiPlugin.js b/web/app/cad/dom/uiPlugin.js deleted file mode 100644 index 4555456a..00000000 --- a/web/app/cad/dom/uiPlugin.js +++ /dev/null @@ -1,41 +0,0 @@ -import {state} from 'lstream'; - -export function defineStreams({streams}) { - - streams.ui = { - controlBars: { - left: state([]), - right: state([]) - }, - toolbars: { - headsUp: state([]), - headsUpShowTitles: state(true), - headsUpQuickActions: state([]), - sketcherGeneral: state([]), - sketcherConstraints: state([]), - sketcherControl: state([]) - }, - floatViews: state([]), - sockets: {} - }; - -} - -export function activate({streams, services}) { - - let components = new Map(); - const registerComponent = (id, Component) => components.set(id, Component); - const getComponent = id => components.get(id); - - let floatViewDescriptors = new Map(); - - function registerFloatView(id, Component, title, icon) { - floatViewDescriptors.set(id, {Component, title, icon}); - streams.ui.floatViews.mutate(views => views.push(id)); - } - const getFloatView = id => floatViewDescriptors.get(id); - - services.ui = { - registerComponent, getComponent, registerFloatView, getFloatView - } -} diff --git a/web/app/cad/dom/uiPlugin.ts b/web/app/cad/dom/uiPlugin.ts new file mode 100644 index 00000000..b5a5e282 --- /dev/null +++ b/web/app/cad/dom/uiPlugin.ts @@ -0,0 +1,78 @@ +import {state, StateStream} from 'lstream'; + +export function defineStreams({streams}) { + + streams.ui = { + controlBars: { + left: state([]), + right: state([]) + }, + toolbars: { + headsUp: state([]), + headsUpShowTitles: state(true), + headsUpQuickActions: state([]), + sketcherGeneral: state([]), + sketcherConstraints: state([]), + sketcherControl: state([]) + }, + floatViews: state([]), + sockets: {} + }; + +} + +export function activate(ctx) { + + const {streams, services} = ctx; + + let components = new Map(); + const registerComponent = (id, Component) => components.set(id, Component); + const getComponent = id => components.get(id); + + let floatViewDescriptors = new Map(); + + function registerFloatView(id, Component, title, icon) { + floatViewDescriptors.set(id, {Component, title, icon}); + streams.ui.floatViews.mutate(views => views.push(id)); + } + const getFloatView = id => floatViewDescriptors.get(id); + + services.ui = { + registerComponent, getComponent, registerFloatView, getFloatView + } + + ctx.uiService = { + ...services.ui, + streams: ctx.streams.ui + } +} + +export type ActionRef = (string | string[])[]; + +declare module 'context' { + interface CoreContext { + + uiService: { + registerFloatView(id: string, Component: any, title: string, icon: any); + registerComponent(id: string, Component: any); + getComponent(id: string) : any; + getFloatView(id: string) : any; + streams: { + controlBars: { + left: StateStream + right: StateStream + }, + toolbars: { + headsUp: StateStream, + headsUpShowTitles: StateStream, + headsUpQuickActions: StateStream, + sketcherGeneral: StateStream, + sketcherConstraints: StateStream, + sketcherControl: StateStream + }, + floatViews: StateStream, + sockets: any + } + }; + } +} \ No newline at end of file diff --git a/web/app/cad/init/startApplication.js b/web/app/cad/init/startApplication.js index 6a5ceff4..8416f515 100644 --- a/web/app/cad/init/startApplication.js +++ b/web/app/cad/init/startApplication.js @@ -32,12 +32,13 @@ import * as OCCTPlugin from '../craft/e0/occtPlugin'; import context from 'context'; import startReact from "../dom/startReact"; -import * as UIConfigPlugin from "../part/uiConfigPlugin"; +import * as UIConfigPlugin from "../workbench/uiConfigPlugin"; import * as DebugPlugin from "../debugPlugin"; import * as ExpressionsPlugin from "../expressions/expressionsPlugin"; -import * as PartOperationsPlugin from "../part/partOperationsPlugin"; +import {WorkbenchPlugin} from "../workbench/workbenchPlugin"; import * as LocationPlugin from "../location/LocationPlugin"; import * as AssemblyPlugin from "../assembly/assemblyPlugin"; +import {WorkbenchesLoaderPlugin} from "cad/workbench/workbenchesLoaderPlugin"; export default function startApplication(callback) { @@ -72,10 +73,11 @@ export default function startApplication(callback) { MarkerPlugin, PickControlPlugin, EntityContextPlugin, + WorkbenchPlugin, SketcherPlugin, UIConfigPlugin, DebugPlugin, - PartOperationsPlugin, + WorkbenchesLoaderPlugin, LocationPlugin, AssemblyPlugin, RemotePartsPlugin, diff --git a/web/app/cad/part/partOperationsPlugin.js b/web/app/cad/part/partOperationsPlugin.js deleted file mode 100644 index 95be76ab..00000000 --- a/web/app/cad/part/partOperationsPlugin.js +++ /dev/null @@ -1,44 +0,0 @@ -import cutOperation from '../craft/cutExtrude/cutOperation'; -import planeOperation from '../craft/primitives/simplePlane/simplePlaneOperation'; -import filletOperation from '../craft/fillet/filletOperation'; -import revolveOperation from '../craft/revolve/revolveOperation'; -import createDatumOperation from '../craft/datum/create/createDatumOperation'; -import moveDatumOperation from '../craft/datum/move/moveDatumOperation'; -import rotateDatumOperation from '../craft/datum/rotate/rotateDatumOperation'; -import datumOperation from '../craft/primitives/plane/planeOperation'; -import boxOperation from '../craft/primitives/box/boxOperation'; -import sphereOperation from '../craft/primitives/sphere/sphereOperation'; -import cylinderOperation from '../craft/primitives/cylinder/cylinderOperation'; -import torusOperation from '../craft/primitives/torus/torusOperation'; -import coneOperation from '../craft/primitives/cone/coneOperation'; -import spatialCurveOperation from '../craft/spatialCurve/spatialCurveOperation'; -import loftOperation from '../craft/loft/loftOperation'; -import {intersectionOperation, subtractOperation, unionOperation} from '../craft/boolean/booleanOperation'; -import WorkbenchRegistry from 'workbenches/registry'; - -export function activate({services}) { - services.operation.registerOperations([ - planeOperation, - boxOperation, - // extrudeOperation, - cutOperation, - revolveOperation, - filletOperation, - createDatumOperation, - moveDatumOperation, - rotateDatumOperation, - datumOperation, - sphereOperation, - cylinderOperation, - torusOperation, - coneOperation, - spatialCurveOperation, - loftOperation, - intersectionOperation, - subtractOperation, - unionOperation, - ]); - WorkbenchRegistry.forEach(w => { - services.operation.registerOperations(w.features); - }); -} \ No newline at end of file diff --git a/web/app/cad/sketch/inPlaceSketcher.js b/web/app/cad/sketch/inPlaceSketcher.js index 33bd2342..9214f9c4 100644 --- a/web/app/cad/sketch/inPlaceSketcher.js +++ b/web/app/cad/sketch/inPlaceSketcher.js @@ -1,10 +1,8 @@ -import {DelegatingPanTool} from '../../sketcher/tools/pan'; +import {DelegatingPanTool} from 'sketcher/tools/pan'; import {Matrix4} from 'three/src/math/Matrix4'; import {CAMERA_MODE} from '../scene/viewer'; import DPR from 'dpr'; -import {SKETCHER_MODE_HEADS_UP_ACTIONS} from "./sketcherUIContrib"; -import {createEssentialAppContext} from "../../sketcher/sketcherContext"; -import {STANDARD_MODE_HEADS_UP_TOOLBAR} from "../part/uiConfigPlugin"; +import {createEssentialAppContext} from "sketcher/sketcherContext"; import {ORIGIN} from "math/vector"; export class InPlaceSketcher { @@ -44,8 +42,7 @@ export class InPlaceSketcher { this.viewer.toolManager.setDefaultTool(new DelegatingPanTool(this.viewer, viewer3d.sceneSetup.renderer.domElement)); viewer3d.sceneSetup.trackballControls.addEventListener( 'change', this.onCameraChange); - this.ctx.streams.ui.toolbars.headsUp.next(SKETCHER_MODE_HEADS_UP_ACTIONS); - this.ctx.streams.ui.toolbars.headsUpShowTitles.next(false); + this.ctx.workbenchService.switchWorkbench('sketcher'); let sketchData = this.ctx.services.storage.get(this.sketchStorageKey); this.viewer.historyManager.init(sketchData); @@ -70,8 +67,7 @@ export class InPlaceSketcher { this.sketcherAppContext = null; this.ctx.streams.sketcher.sketchingFace.next(null); this.ctx.streams.sketcher.sketcherAppContext.next(null); - this.ctx.streams.ui.toolbars.headsUp.next(STANDARD_MODE_HEADS_UP_TOOLBAR); - this.ctx.streams.ui.toolbars.headsUpShowTitles.next(true); + this.ctx.workbenchService.switchToDefaultWorkbench(); viewer3d.requestRender(); } diff --git a/web/app/cad/sketch/sketcherUIContrib.js b/web/app/cad/sketch/sketcherUIContrib.js deleted file mode 100644 index 9c9c5360..00000000 --- a/web/app/cad/sketch/sketcherUIContrib.js +++ /dev/null @@ -1,62 +0,0 @@ -import objectToolActions from '../../sketcher/actions/objectToolActions'; -import measureActions from '../../sketcher/actions/measureActions'; -import {insertAfter} from 'gems/iterables'; -import operationActions from "../../sketcher/actions/operationActions"; -import constraintGlobalActions from "../../sketcher/actions/constraintGlobalActions"; -import generalToolActions from "../../sketcher/actions/generalToolActions"; -import sketcherControlActions from "./sketcherControlActions"; - -export default function (ctx) { - ctx.actionService.registerActions(sketcherControlActions); - ctx.actionService.registerActions([ - ...constraintGlobalActions, - ...measureActions, - ...generalToolActions, - ...objectToolActions, - ...operationActions, - - ].map(convertSketcherAction)); - -} - -const SKETCHER_PREFIX = 'sketcher.'; - -function toSketcherActionId(id) { - return SKETCHER_PREFIX + id; -} - -function convertSketcherAction(action) { - - return { - id: toSketcherActionId(action.id), - appearance: { - icon: action.icon, - label: action.shortName, - info: action.description, - }, - invoke: ({services}, e) => action.invoke(services.sketcher.inPlaceEditor.sketcherAppContext) - } -} -export const SKETCHER_MODE_HEADS_UP_ACTIONS = [ - ['sketchSaveAndExit', 'sketchExit'], - '-', - generalToolActions.map(a => toSketcherActionId(a.id)), - '-', - [ - ...objectToolActions.map(a => toSketcherActionId(a.id)), - toSketcherActionId('Offset'), - ], - '-', - measureActions.map(a => toSketcherActionId(a.id)), - '-', - constraintGlobalActions.map(a => toSketcherActionId(a.id)), - '-', - ['LookAtFace'], - '-', - ['sketchOpenInTab'] -]; - -insertAfter(SKETCHER_MODE_HEADS_UP_ACTIONS, SKETCHER_PREFIX + 'Export', '-'); -insertAfter(SKETCHER_MODE_HEADS_UP_ACTIONS, SKETCHER_PREFIX + 'PanTool', '-'); -insertAfter(SKETCHER_MODE_HEADS_UP_ACTIONS, SKETCHER_PREFIX + 'BezierTool', '-'); - diff --git a/web/app/cad/sketch/sketcherUIContrib.ts b/web/app/cad/sketch/sketcherUIContrib.ts new file mode 100644 index 00000000..47c2bb0c --- /dev/null +++ b/web/app/cad/sketch/sketcherUIContrib.ts @@ -0,0 +1,80 @@ +import objectToolActions from '../../sketcher/actions/objectToolActions'; +import measureActions from '../../sketcher/actions/measureActions'; +import {insertAfter} from 'gems/iterables'; +import operationActions from "../../sketcher/actions/operationActions"; +import constraintGlobalActions from "../../sketcher/actions/constraintGlobalActions"; +import generalToolActions from "../../sketcher/actions/generalToolActions"; +import sketcherControlActions from "./sketcherControlActions"; +import {ApplicationContext} from "context"; +import {WorkbenchConfig} from "cad/workbench/workbenchService"; + +export default function (ctx: ApplicationContext) { + + const convertedActions = [ + ...constraintGlobalActions, + ...measureActions, + ...generalToolActions, + ...objectToolActions, + ...operationActions, + ].map(convertSketcherAction); + + const SKETCHER_MODE_HEADS_UP_ACTIONS = [ + ['sketchSaveAndExit', 'sketchExit'], + '-', + generalToolActions.map(a => toSketcherActionId(a.id)), + '-', + [ + ...objectToolActions.map(a => toSketcherActionId(a.id)), + toSketcherActionId('Offset'), + ], + '-', + measureActions.map(a => toSketcherActionId(a.id)), + '-', + constraintGlobalActions.map(a => toSketcherActionId(a.id)), + '-', + ['LookAtFace'], + '-', + ['sketchOpenInTab'] + ]; + + insertAfter(SKETCHER_MODE_HEADS_UP_ACTIONS, SKETCHER_PREFIX + 'Export', '-'); + insertAfter(SKETCHER_MODE_HEADS_UP_ACTIONS, SKETCHER_PREFIX + 'PanTool', '-'); + insertAfter(SKETCHER_MODE_HEADS_UP_ACTIONS, SKETCHER_PREFIX + 'BezierTool', '-'); + + ctx.workbenchService.registerWorkbench({ + workbenchId: 'sketcher', + internal: true, + features: [], + actions: [ + ...sketcherControlActions, + ...convertedActions + ], + ui: { + toolbar: SKETCHER_MODE_HEADS_UP_ACTIONS, + toolbarStyle: 'compact' + } + }); + + +} + +const SKETCHER_PREFIX = 'sketcher.'; + +function toSketcherActionId(id: string): string { + return SKETCHER_PREFIX + id; +} + +function convertSketcherAction(action) { + + return { + id: toSketcherActionId(action.id), + appearance: { + icon: action.icon, + label: action.shortName, + info: action.description, + }, + invoke: ({services}, e) => action.invoke(services.sketcher.inPlaceEditor.sketcherAppContext) + } +} + + diff --git a/web/app/cad/part/menuConfig.js b/web/app/cad/workbench/menuConfig.js similarity index 100% rename from web/app/cad/part/menuConfig.js rename to web/app/cad/workbench/menuConfig.js diff --git a/web/app/cad/part/uiConfigPlugin.js b/web/app/cad/workbench/uiConfigPlugin.js similarity index 81% rename from web/app/cad/part/uiConfigPlugin.js rename to web/app/cad/workbench/uiConfigPlugin.js index 618c9d70..499c3d61 100644 --- a/web/app/cad/part/uiConfigPlugin.js +++ b/web/app/cad/workbench/uiConfigPlugin.js @@ -10,11 +10,6 @@ import Expressions from '../expressions/Expressions'; import {SelectionView} from "../dom/components/SelectionView"; import {GrSelect} from "react-icons/gr"; -export const STANDARD_MODE_HEADS_UP_TOOLBAR = ['DATUM_CREATE', 'PLANE', 'EditFace', '-', "OCC_BOTTLE", '-', - "EXTRUDE", "Revolve", "loft","-", "boolean_tool", "shell_tool", - "primitive_cylinder", "primitive_box", "primitive_cone", "primitive_sphere", "primitive_torus", "hole_tool", - "fillet_tool"]; - export function activate(ctx) { const {services, streams} = ctx; streams.ui.controlBars.left.value = ['menu.file', 'menu.craft', 'menu.boolean', 'menu.primitives', 'menu.views', 'Donate', 'GitHub']; @@ -24,7 +19,6 @@ export function activate(ctx) { ['ShowSketches', {label: 'sketches'}], ['DeselectAll', {label: null}], ['ToggleCameraMode', {label: null}] ]; - streams.ui.toolbars.headsUp.value = STANDARD_MODE_HEADS_UP_TOOLBAR; streams.ui.toolbars.headsUpQuickActions.value = ['Save', 'StlExport']; ctx.actionService.registerActions(CoreActions); diff --git a/web/app/cad/workbench/workbenchPlugin.ts b/web/app/cad/workbench/workbenchPlugin.ts new file mode 100644 index 00000000..94e60d15 --- /dev/null +++ b/web/app/cad/workbench/workbenchPlugin.ts @@ -0,0 +1,20 @@ +import {ApplicationContext} from "context"; +import {WorkbenchService} from "cad/workbench/workbenchService"; + + +declare module 'context' { + interface CoreContext { + + workbenchService: WorkbenchService; + } +} + + +export const WorkbenchPlugin = { + + activate(ctx: ApplicationContext) { + + ctx.workbenchService = new WorkbenchService(ctx); + } + +} diff --git a/web/app/cad/workbench/workbenchService.ts b/web/app/cad/workbench/workbenchService.ts new file mode 100644 index 00000000..5cffefc6 --- /dev/null +++ b/web/app/cad/workbench/workbenchService.ts @@ -0,0 +1,68 @@ +import {OperationDescriptor} from "cad/craft/operationPlugin"; +import {ActionDefinition} from "cad/actions/actionSystemPlugin"; +import {state} from "lstream"; +import {Index} from "gems/indexType"; +import {ApplicationContext, CoreContext} from "context"; +import {ActionRef} from "cad/dom/uiPlugin"; + +export class WorkbenchService { + + workbenches$ = state>({}); + + currentWorkbench$ = state(null); + ctx: CoreContext; + + constructor(ctx: ApplicationContext) { + this.ctx = ctx; + this.currentWorkbench$.attach(workbenchConfig => { + if (!workbenchConfig) { + return + } + ctx.uiService.streams.toolbars.headsUp.next(workbenchConfig.ui.toolbar); + const toolbarStyle = workbenchConfig.ui.toolbarStyle || 'large' + ctx.uiService.streams.toolbars.headsUpShowTitles.next(toolbarStyle === "large"); + }) + } + + getWorkbenchConfig(workbenchId: string): WorkbenchConfig { + return this.workbenches$.value[workbenchId]; + } + + registerWorkbench(workbenchConfig: WorkbenchConfig) { + if (this.getWorkbenchConfig(workbenchConfig.workbenchId)) { + throw 'workbench already exists: ' + workbenchConfig.workbenchId; + } + this.ctx.operationService.registerOperations(workbenchConfig.features) + this.ctx.actionService.registerActions(workbenchConfig.actions); + + this.workbenches$.update(workbenches => ({ + ...workbenches, + [workbenchConfig.workbenchId]: workbenchConfig + })); + } + + switchWorkbench(workbenchId: string) { + const workbenchConfig = this.workbenches$.value[workbenchId]; + if (!workbenchConfig) { + throw 'nonexistent workbench ' + workbenchId; + } + this.currentWorkbench$.next(workbenchConfig); + } + + switchToDefaultWorkbench() { + this.switchWorkbench('modeler'); + } +} + +export interface WorkbenchUIConfig { + toolbar: ActionRef; + toolbarStyle?: 'compact' | 'large'; +} + +export interface WorkbenchConfig { + workbenchId: string; + internal?: boolean; + features: OperationDescriptor[]; + actions: ActionDefinition[]; + ui: WorkbenchUIConfig; +} \ No newline at end of file diff --git a/web/app/cad/workbench/workbenchesLoaderPlugin.ts b/web/app/cad/workbench/workbenchesLoaderPlugin.ts new file mode 100644 index 00000000..76844273 --- /dev/null +++ b/web/app/cad/workbench/workbenchesLoaderPlugin.ts @@ -0,0 +1,54 @@ +import {ApplicationContext, CoreContext} from "context"; +import {WorkbenchRegistry} from "workbenches/registry"; +import planeOperation from "cad/craft/primitives/simplePlane/simplePlaneOperation"; +import boxOperation from "cad/craft/primitives/box/boxOperation"; +import cutOperation from "cad/craft/cutExtrude/cutOperation"; +import revolveOperation from "cad/craft/revolve/revolveOperation"; +import filletOperation from "cad/craft/fillet/filletOperation"; +import createDatumOperation from "cad/craft/datum/create/createDatumOperation"; +import moveDatumOperation from "cad/craft/datum/move/moveDatumOperation"; +import rotateDatumOperation from "cad/craft/datum/rotate/rotateDatumOperation"; +import datumOperation from "cad/craft/primitives/plane/planeOperation"; +import sphereOperation from "cad/craft/primitives/sphere/sphereOperation"; +import cylinderOperation from "cad/craft/primitives/cylinder/cylinderOperation"; +import torusOperation from "cad/craft/primitives/torus/torusOperation"; +import coneOperation from "cad/craft/primitives/cone/coneOperation"; +import spatialCurveOperation from "cad/craft/spatialCurve/spatialCurveOperation"; +import loftOperation from "cad/craft/loft/loftOperation"; +import {intersectionOperation, subtractOperation, unionOperation} from "cad/craft/boolean/booleanOperation"; + + +export const WorkbenchesLoaderPlugin = { + + activate(ctx: ApplicationContext) { + registerCoreOperations(ctx); + WorkbenchRegistry.forEach(wConfig => ctx.workbenchService.registerWorkbench(wConfig)); + ctx.workbenchService.switchToDefaultWorkbench(); + } + +} + +function registerCoreOperations(ctx: CoreContext) { + + ctx.operationService.registerOperations([ + planeOperation, + boxOperation, + // extrudeOperation, + cutOperation, + revolveOperation, + filletOperation, + createDatumOperation, + moveDatumOperation, + rotateDatumOperation, + datumOperation, + sphereOperation, + cylinderOperation, + torusOperation, + coneOperation, + spatialCurveOperation, + loftOperation, + intersectionOperation, + subtractOperation, + unionOperation, + ]); +} \ No newline at end of file