From 9f0e2d419ba865c01ca9d6a8754513a2b87e292b Mon Sep 17 00:00:00 2001 From: Mike Molinari Date: Fri, 25 Feb 2022 01:42:45 +0000 Subject: [PATCH] Added option to keep tools to the boolean feature command. --- .../features/boolean/boolean.operation.ts | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/modules/workbenches/modeler/features/boolean/boolean.operation.ts b/modules/workbenches/modeler/features/boolean/boolean.operation.ts index 5834884e..e8df6a73 100644 --- a/modules/workbenches/modeler/features/boolean/boolean.operation.ts +++ b/modules/workbenches/modeler/features/boolean/boolean.operation.ts @@ -3,10 +3,13 @@ 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 { param } from 'cypress/types/jquery'; +import { MObject } from 'cad/model/mobject'; interface BooleanParams { tools: []; - boolean: BooleanDefinition + keepTools:boolean; + boolean: BooleanDefinition; } export const BooleanOperation: OperationDescriptor = { @@ -20,29 +23,44 @@ export const BooleanOperation: OperationDescriptor = { let occ = ctx.occService; const oci = occ.commandInterface; - console.log(params.tools, params.boolean); + let returnObject = occ.utils.applyBooleanModifier(params.tools, params.boolean); + + if (params.keepTools == true) { + // filter consumed array to remove the tools but leaving the targets regardless if + // the targets are explicitly set or implied by leaving targets blank. + returnObject.consumed = returnObject.created.filter((el) => !params.tools.includes(el as never)); + }else{ + returnObject.consumed = returnObject.consumed.concat(params.tools); + } - return occ.utils.applyBooleanModifier(params.tools, params.boolean); + return returnObject; }, form: [ - { - type: 'boolean', - name: 'boolean', - label: 'Targets', - optional: true, - defaultValue: 'UNION' - }, { type: 'selection', name: 'tools', capture: [EntityKind.SHELL], label: 'Tools', + optional: false, multi: true, defaultValue: { usePreselection: true, preselectionIndex: 0 }, }, + { + type: 'checkbox', + name: 'keepTools', + label: 'Keep Tools', + defaultValue: false, + }, + { + type: 'boolean', + name: 'boolean', + label: 'Targets', + optional: true, + defaultValue: "UNION", + }, ], }