mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-07 17:04:58 +01:00
adding boolean capabilities to primitive operations
This commit is contained in:
parent
0825dc0065
commit
2cd26f19e5
14 changed files with 90 additions and 27 deletions
15
modules/ui/components/controls/ComboBoxControl.jsx
Normal file
15
modules/ui/components/controls/ComboBoxControl.jsx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import React from 'react';
|
||||
|
||||
export default class ComboBoxControl extends React.Component {
|
||||
|
||||
render() {
|
||||
let {onChange, value, children} = this.props;
|
||||
return <select value={value} onChange={e => onChange(e.target.value)}>
|
||||
{children}
|
||||
</select>
|
||||
}
|
||||
}
|
||||
|
||||
export function ComboBoxOption({children, value}) {
|
||||
return <option value={value}>{children}</option>
|
||||
}
|
||||
10
web/app/cad/craft/primitives/booleanOptionHelper.js
Normal file
10
web/app/cad/craft/primitives/booleanOptionHelper.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
export function assignBooleanParams(execParams, rawParams, getAllShells) {
|
||||
if (rawParams.boolean) {
|
||||
execParams.boolean = {
|
||||
type: rawParams.boolean,
|
||||
operands: getAllShells()
|
||||
}
|
||||
}
|
||||
return execParams;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import React from 'react';
|
||||
import {Group} from '../../wizard/components/form/Form';
|
||||
import {NumberField, ReadOnlyValueField} from '../../wizard/components/form/Fields';
|
||||
import BooleanChoice from '../../wizard/components/form/BooleanChioce';
|
||||
|
||||
export default function BoxWizard() {
|
||||
return <Group>
|
||||
|
|
@ -8,5 +9,6 @@ export default function BoxWizard() {
|
|||
<NumberField name='width' />
|
||||
<NumberField name='height' />
|
||||
<NumberField name='depth' />
|
||||
<BooleanChoice name='boolean' />
|
||||
</Group>;
|
||||
}
|
||||
|
|
@ -2,16 +2,18 @@ import BoxWizard from './BoxWizard';
|
|||
import {BoxGeometry} from 'three';
|
||||
import schema from './boxOpSchema';
|
||||
import primitivePreviewer from '../primitivePreviewer';
|
||||
import CSys from '../../../../math/csys';
|
||||
import datumConsumingOperation from '../datumConsumingOperation';
|
||||
import {assignBooleanParams} from '../booleanOptionHelper';
|
||||
|
||||
function run(params, services) {
|
||||
return datumConsumingOperation(params, services, csys => services.craftEngine.createBox({
|
||||
csys,
|
||||
width: params.width,
|
||||
height: params.height,
|
||||
depth: params.depth
|
||||
}));
|
||||
return datumConsumingOperation(params, services, csys => services.craftEngine.createBox(
|
||||
assignBooleanParams({
|
||||
csys,
|
||||
width: params.width,
|
||||
height: params.height,
|
||||
depth: params.depth
|
||||
}, params, services.cadRegistry.getAllShells)
|
||||
));
|
||||
}
|
||||
|
||||
export default {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import React from 'react';
|
||||
import {Group} from '../../wizard/components/form/Form';
|
||||
import {NumberField, ReadOnlyValueField} from '../../wizard/components/form/Fields';
|
||||
import BooleanChoice from '../../wizard/components/form/BooleanChioce';
|
||||
|
||||
export default function TorusWizard() {
|
||||
return <Group>
|
||||
|
|
@ -8,5 +9,6 @@ export default function TorusWizard() {
|
|||
<NumberField name='radius' />
|
||||
<NumberField name='frustum' />
|
||||
<NumberField name='height' />
|
||||
<BooleanChoice name='boolean' />
|
||||
</Group>;
|
||||
}
|
||||
|
|
@ -5,14 +5,17 @@ import {IMAGINARY_SURFACE_MATERIAL} from '../../../preview/scenePreviewer';
|
|||
import CSys from '../../../../math/csys';
|
||||
import * as SceneGraph from '../../../../../../modules/scene/sceneGraph';
|
||||
import datumConsumingOperation from '../datumConsumingOperation';
|
||||
import {assignBooleanParams} from '../booleanOptionHelper';
|
||||
|
||||
function run(params, services) {
|
||||
return datumConsumingOperation(params, services, csys => services.craftEngine.createCone({
|
||||
csys,
|
||||
radius: params.radius,
|
||||
frustum: params.frustum,
|
||||
height: params.height
|
||||
}));
|
||||
return datumConsumingOperation(params, services, csys => services.craftEngine.createCone(
|
||||
assignBooleanParams({
|
||||
csys,
|
||||
radius: params.radius,
|
||||
frustum: params.frustum,
|
||||
height: params.height
|
||||
}, params, services.cadRegistry.getAllShells)
|
||||
));
|
||||
}
|
||||
|
||||
function previewer(ctx, initialParams) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import React from 'react';
|
||||
import {Group} from '../../wizard/components/form/Form';
|
||||
import {NumberField, ReadOnlyValueField} from '../../wizard/components/form/Fields';
|
||||
import BooleanChoice from '../../wizard/components/form/BooleanChioce';
|
||||
|
||||
export default function CylinderWizard() {
|
||||
return <Group>
|
||||
<ReadOnlyValueField name='datum' placeholder='origin'/>
|
||||
<NumberField name='radius' />
|
||||
<NumberField name='height' />
|
||||
<BooleanChoice name='boolean' />
|
||||
</Group>;
|
||||
}
|
||||
|
|
@ -3,13 +3,16 @@ import schema from './cylinderOpSchema';
|
|||
import primitivePreviewer from '../primitivePreviewer';
|
||||
import CylinderWizard from './CylinderWizard';
|
||||
import datumConsumingOperation from '../datumConsumingOperation';
|
||||
import {assignBooleanParams} from '../booleanOptionHelper';
|
||||
|
||||
function run(params, services) {
|
||||
return datumConsumingOperation(params, services, csys => services.craftEngine.createCylinder({
|
||||
csys,
|
||||
radius: params.radius,
|
||||
height: params.height
|
||||
}));
|
||||
return datumConsumingOperation(params, services, csys => services.craftEngine.createCylinder(
|
||||
assignBooleanParams({
|
||||
csys,
|
||||
radius: params.radius,
|
||||
height: params.height
|
||||
}, params, services.cadRegistry.getAllShells)
|
||||
));
|
||||
}
|
||||
|
||||
export default {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import React from 'react';
|
||||
import {Group} from '../../wizard/components/form/Form';
|
||||
import {NumberField, ReadOnlyValueField} from '../../wizard/components/form/Fields';
|
||||
import BooleanChoice from '../../wizard/components/form/BooleanChioce';
|
||||
|
||||
export default function SphereWizard() {
|
||||
return <Group>
|
||||
<ReadOnlyValueField name='datum' placeholder='origin'/>
|
||||
<NumberField name='radius' />
|
||||
<BooleanChoice name='boolean' />
|
||||
</Group>;
|
||||
}
|
||||
|
|
@ -3,12 +3,15 @@ import schema from './sphereOpSchema';
|
|||
import primitivePreviewer from '../primitivePreviewer';
|
||||
import SphereWizard from './SphereWizard';
|
||||
import datumConsumingOperation from '../datumConsumingOperation';
|
||||
import {assignBooleanParams} from '../booleanOptionHelper';
|
||||
|
||||
function run(params, services) {
|
||||
return datumConsumingOperation(params, services, csys => services.craftEngine.createSphere({
|
||||
csys,
|
||||
radius: params.radius,
|
||||
}));
|
||||
return datumConsumingOperation(params, services, csys => services.craftEngine.createSphere(
|
||||
assignBooleanParams({
|
||||
csys,
|
||||
radius: params.radius,
|
||||
}, params, services.cadRegistry.getAllShells)
|
||||
));
|
||||
}
|
||||
|
||||
export default {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import React from 'react';
|
||||
import {Group} from '../../wizard/components/form/Form';
|
||||
import {NumberField, ReadOnlyValueField} from '../../wizard/components/form/Fields';
|
||||
import BooleanChoice from '../../wizard/components/form/BooleanChioce';
|
||||
|
||||
export default function TorusWizard() {
|
||||
return <Group>
|
||||
<ReadOnlyValueField name='datum' placeholder='origin'/>
|
||||
<NumberField name='radius' />
|
||||
<NumberField name='tube' />
|
||||
<BooleanChoice name='boolean' />
|
||||
</Group>;
|
||||
}
|
||||
|
|
@ -5,13 +5,16 @@ import {IMAGINARY_SURFACE_MATERIAL} from '../../../preview/scenePreviewer';
|
|||
import CSys from '../../../../math/csys';
|
||||
import * as SceneGraph from '../../../../../../modules/scene/sceneGraph';
|
||||
import datumConsumingOperation from '../datumConsumingOperation';
|
||||
import {assignBooleanParams} from '../booleanOptionHelper';
|
||||
|
||||
function run(params, services) {
|
||||
return datumConsumingOperation(params, services, csys => services.craftEngine.createTorus({
|
||||
csys,
|
||||
radius: params.radius,
|
||||
tube: params.tube
|
||||
}));
|
||||
return datumConsumingOperation(params, services, csys => services.craftEngine.createTorus(
|
||||
assignBooleanParams({
|
||||
csys,
|
||||
radius: params.radius,
|
||||
tube: params.tube
|
||||
}, params, services.cadRegistry.getAllShells)
|
||||
));
|
||||
}
|
||||
|
||||
function previewer(ctx, initialParams) {
|
||||
|
|
|
|||
12
web/app/cad/craft/wizard/components/form/BooleanChioce.jsx
Normal file
12
web/app/cad/craft/wizard/components/form/BooleanChioce.jsx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import React from 'react';
|
||||
import {ComboBoxOption} from 'ui/components/controls/ComboBoxControl';
|
||||
import {ComboBoxField} from './Fields';
|
||||
|
||||
export default function BooleanChoice(props) {
|
||||
return <ComboBoxField {...props}>
|
||||
<ComboBoxOption value={null}>{'<none>'}</ComboBoxOption>
|
||||
<ComboBoxOption value={'INTERSECT'}>intersect</ComboBoxOption>
|
||||
<ComboBoxOption value={'SUBTRACT'}>subtract</ComboBoxOption>
|
||||
<ComboBoxOption value={'UNION'}>union</ComboBoxOption>
|
||||
</ComboBoxField>
|
||||
}
|
||||
|
|
@ -5,9 +5,11 @@ import TextControl from 'ui/components/controls/TextControl';
|
|||
import RadioButtons from 'ui/components/controls/RadioButtons';
|
||||
import CheckboxControl from 'ui/components/controls/CheckboxControl';
|
||||
import ReadOnlyValueControl from 'ui/components/controls/ReadOnlyValueControl';
|
||||
import ComboBoxControl from 'ui/components/controls/ComboBoxControl';
|
||||
|
||||
export const NumberField = attachToForm(formField(NumberControl));
|
||||
export const TextField = attachToForm(formField(TextControl));
|
||||
export const RadioButtonsField = attachToForm(formField(RadioButtons));
|
||||
export const CheckboxField = attachToForm(formField(CheckboxControl));
|
||||
export const ComboBoxField = attachToForm(formField(ComboBoxControl));
|
||||
export const ReadOnlyValueField = attachToForm(formField(ReadOnlyValueControl));
|
||||
|
|
|
|||
Loading…
Reference in a new issue