make boolean operations distinct

This commit is contained in:
Val Erastov 2018-11-30 19:41:47 -08:00
parent 28d863a52e
commit 0e802520be
3 changed files with 14 additions and 20 deletions

View file

@ -7,6 +7,5 @@ export default function BooleanWizard() {
return <Group>
<SingleEntity name='operandA' label='operand A' entity='shell' selectionIndex={0} />
<SingleEntity name='operandB' label='operand B' entity='shell' selectionIndex={1} />
<BooleanChoice name='type' strict/>
</Group>;
}

View file

@ -1,4 +1,4 @@
export default defaultValue => ({
export default {
operandA: {
type: 'shell',
defaultValue: {type: 'selection'}
@ -6,10 +6,5 @@ export default defaultValue => ({
operandB: {
type: 'shell',
defaultValue: {type: 'selection'}
},
type: {
type: 'enum',
values: ['INTERSECT', 'SUBTRACT', 'UNION'],
defaultValue
}
})
};

View file

@ -1,13 +1,13 @@
import schema from './booleanOpSchema';
import BooleanWizard from './BooleanWizard';
function run(params, services) {
const run = type => (params, services) => {
return services.craftEngine.boolean({
type: params.type,
type,
operandsA: [services.cadRegistry.findShell(params.operandA)],
operandsB: [services.cadRegistry.findShell(params.operandB)]
});
}
};
const paramsInfo = ({operandA, operandB}) => `(${operandA}, ${operandB})`;
@ -17,36 +17,36 @@ const selectionMode = {
export const intersectionOperation = {
id: 'INTERSECTION',
label: 'boolean',
label: 'intersection',
icon: 'img/cad/intersection',
info: 'intersection operation on two shells',
paramsInfo,
form: BooleanWizard,
schema: schema('INTERSECTION'),
run,
schema,
run: run('INTERSECTION'),
selectionMode
};
export const subtractOperation = {
id: 'SUBTRACT',
label: 'boolean',
label: 'subtract',
icon: 'img/cad/subtract',
info: 'subtract operation on two shells',
paramsInfo,
form: BooleanWizard,
schema: schema('SUBTRACT'),
run,
schema,
run: run('SUBTRACT'),
selectionMode
};
export const unionOperation = {
id: 'UNION',
label: 'boolean',
label: 'union',
icon: 'img/cad/union',
info: 'union operation on two shells',
paramsInfo,
form: BooleanWizard,
schema: schema('UNION'),
run,
schema,
run: run('UNION'),
selectionMode
};