fix extrude-cut tests

This commit is contained in:
Val Erastov 2022-06-11 14:56:14 -07:00
parent bf19c9577e
commit 32b2291aa9
13 changed files with 61 additions and 50 deletions

View file

@ -150,7 +150,7 @@ export const ExtrudeOperation: OperationDescriptor<ExtrudeParams> = {
masking: [ masking: [
{ {
id: 'CUT2', id: 'CUT',
label: 'Cut', label: 'Cut',
icon: 'img/cad/cut', icon: 'img/cad/cut',
info: 'makes a cut based on 2D sketch', info: 'makes a cut based on 2D sketch',

View file

@ -48,7 +48,7 @@ export const ModelerWorkspace: WorkbenchConfig = {
ui: { ui: {
toolbar: [ toolbar: [
'DATUM_CREATE', 'PLANE', 'EditFace', '-', 'DATUM_CREATE', 'PLANE', 'EditFace', '-',
"EXTRUDE", "CUT2", "REVOLVE", "LOFT", "SWEEP", "-", "EXTRUDE", "CUT", "REVOLVE", "LOFT", "SWEEP", "-",
"BOOLEAN", "-", "BOOLEAN", "-",
"SHELL_TOOL", "FILLET_TOOL", "SCALE_BODY","-", "SHELL_TOOL", "FILLET_TOOL", "SCALE_BODY","-",
"MIRROR_BODY", "PATTERN_LINEAR", "PATTERN_RADIAL", "-", "MIRROR_BODY", "PATTERN_LINEAR", "PATTERN_RADIAL", "-",

View file

@ -3,7 +3,11 @@ import {genSerpinskiImpl} from '../../../web/app/utils/genSerpinski';
import {distance} from 'math/commons'; import {distance} from 'math/commons';
export function createSubjectFromInPlaceSketcher(ctx) { export function createSubjectFromInPlaceSketcher(ctx) {
return createSketcherTPI(ctx.services.sketcher.inPlaceEditor.sketcherAppContext); const sketcherCtx = ctx.services.sketcher.inPlaceEditor.sketcherAppContext;
if (!sketcherCtx) {
throw 'not in sketching mode';
}
return createSketcherTPI(sketcherCtx);
} }
export function createSketcherTPI(context) { export function createSketcherTPI(context) {

View file

@ -1,6 +1,7 @@
import {extrudeCube} from '../utils/scripts'; import {extrudeCube} from '../utils/scripts';
export const TEST_MODE = 'modellerUI'; export const TEST_MODE = 'modellerUI';
export const only = true;
export async function testCutMid(env, ui) { export async function testCutMid(env, ui) {
await extrudeCube(ui); await extrudeCube(ui);
@ -9,9 +10,10 @@ export async function testCutMid(env, ui) {
let sui = ui.openSketcher(); let sui = ui.openSketcher();
sui.addRectangle(-50, -50, 50, 50); sui.addRectangle(-50, -50, 50, 50);
ui.commitSketch(); ui.commitSketch();
ui.selectFaces([0, 0, 210], [0, 0, 190]);
ui.openWizard('CUT'); ui.openWizard('CUT');
ui.wizardContext.updateParam('value', 50); ui.wizardContext.updateParam('height', 50);
await ui.wizardOK(); await ui.wizardOK();
@ -24,9 +26,10 @@ export async function testCutCOI1Faces(env, ui) {
let sui = ui.openSketcher(); let sui = ui.openSketcher();
sui.addRectangle(0, 0, 80, 100); sui.addRectangle(0, 0, 80, 100);
ui.commitSketch(); ui.commitSketch();
ui.selectFaces([0, 0, 210], [0, 0, 190]);
ui.openWizard('CUT'); ui.openWizard('CUT');
ui.wizardContext.updateParam('value', 50); ui.wizardContext.updateParam('height', 50);
await ui.wizardOK(); await ui.wizardOK();
@ -39,9 +42,10 @@ export async function testCutCOI2Faces(env, ui) {
let sui = ui.openSketcher(); let sui = ui.openSketcher();
sui.addRectangle(0, 0, 100, 100); sui.addRectangle(0, 0, 100, 100);
ui.commitSketch(); ui.commitSketch();
ui.selectFaces([0, 0, 210], [0, 0, 190]);
ui.openWizard('CUT'); ui.openWizard('CUT');
ui.wizardContext.updateParam('value', 50); ui.wizardContext.updateParam('length', 50);
await ui.wizardOK(); await ui.wizardOK();
@ -54,9 +58,10 @@ export async function testCutCOI3Faces(env, ui) {
let sui = ui.openSketcher(); let sui = ui.openSketcher();
sui.addRectangle(0, -100, 100, 100); sui.addRectangle(0, -100, 100, 100);
ui.commitSketch(); ui.commitSketch();
ui.selectFaces([0, 0, 210], [0, 0, 190]);
ui.openWizard('CUT'); ui.openWizard('CUT');
ui.wizardContext.updateParam('value', 50); ui.wizardContext.updateParam('length', 50);
await ui.wizardOK(); await ui.wizardOK();
@ -69,9 +74,10 @@ export async function testCutCOI4Faces(env, ui) {
let sui = ui.openSketcher(); let sui = ui.openSketcher();
sui.addRectangle(-100, -100, 100, 100); sui.addRectangle(-100, -100, 100, 100);
ui.commitSketch(); ui.commitSketch();
ui.selectFaces([0, 0, 210], [0, 0, 190]);
ui.openWizard('CUT'); ui.openWizard('CUT');
ui.wizardContext.updateParam('value', 50); ui.wizardContext.updateParam('length', 50);
await ui.wizardOK(); await ui.wizardOK();
@ -86,9 +92,10 @@ export async function testCutMidAllWay(env, ui) {
let sui = ui.openSketcher(); let sui = ui.openSketcher();
sui.addRectangle(-50, -50, 50, 50); sui.addRectangle(-50, -50, 50, 50);
ui.commitSketch(); ui.commitSketch();
ui.selectFaces([0, 0, 210], [0, 0, 190]);
ui.openWizard('CUT'); ui.openWizard('CUT');
ui.wizardContext.updateParam('value', 200); ui.wizardContext.updateParam('length', 200);
await ui.wizardOK(); await ui.wizardOK();
@ -101,9 +108,10 @@ export async function testCutCOI1FacesAllWay(env, ui) {
let sui = ui.openSketcher(); let sui = ui.openSketcher();
sui.addRectangle(0, 0, 80, 100); sui.addRectangle(0, 0, 80, 100);
ui.commitSketch(); ui.commitSketch();
ui.selectFaces([0, 0, 210], [0, 0, 190]);
ui.openWizard('CUT'); ui.openWizard('CUT');
ui.wizardContext.updateParam('value', 200); ui.wizardContext.updateParam('length', 200);
await ui.wizardOK(); await ui.wizardOK();
@ -116,9 +124,10 @@ export async function testCutCOI2FacesAllWay(env, ui) {
let sui = ui.openSketcher(); let sui = ui.openSketcher();
sui.addRectangle(0, 0, 100, 100); sui.addRectangle(0, 0, 100, 100);
ui.commitSketch(); ui.commitSketch();
ui.selectFaces([0, 0, 210], [0, 0, 190]);
ui.openWizard('CUT'); ui.openWizard('CUT');
ui.wizardContext.updateParam('value', 200); ui.wizardContext.updateParam('length', 200);
await ui.wizardOK(); await ui.wizardOK();
@ -131,13 +140,15 @@ export async function testCutCOI3FacesAllWay(env, ui) {
let sui = ui.openSketcher(); let sui = ui.openSketcher();
sui.addRectangle(0, -100, 100, 100); sui.addRectangle(0, -100, 100, 100);
ui.commitSketch(); ui.commitSketch();
ui.selectFaces([0, 0, 210], [0, 0, 190]);
ui.openWizard('CUT'); ui.openWizard('CUT');
ui.wizardContext.updateParam('value', 200); ui.wizardContext.updateParam('length', 200);
await ui.wizardOK(); await ui.wizardOK();
} }
testCutCOI3FacesAllWay.only = true
export async function testCutCOI4FacesAllWay(env, ui) { export async function testCutCOI4FacesAllWay(env, ui) {
await extrudeCube(ui); await extrudeCube(ui);
@ -146,9 +157,10 @@ export async function testCutCOI4FacesAllWay(env, ui) {
let sui = ui.openSketcher(); let sui = ui.openSketcher();
sui.addRectangle(-100, -100, 100, 100); sui.addRectangle(-100, -100, 100, 100);
ui.commitSketch(); ui.commitSketch();
ui.selectFaces([0, 0, 210], [0, 0, 190]);
ui.openWizard('CUT'); ui.openWizard('CUT');
ui.wizardContext.updateParam('value', 200); ui.wizardContext.updateParam('length', 200);
await ui.wizardOK(); await ui.wizardOK();

View file

@ -12,10 +12,8 @@ export async function testExtrudeMid(env, ui) {
ui.commitSketch(); ui.commitSketch();
ui.openWizard('EXTRUDE'); ui.openWizard('EXTRUDE');
ui.wizardContext.updateParam('value', 50); ui.wizardContext.updateParam('length', 50);
await ui.wizardOK(); await ui.wizardOK();
} }
export async function testExtrudeCOI1Faces(env, ui) { export async function testExtrudeCOI1Faces(env, ui) {
@ -27,7 +25,7 @@ export async function testExtrudeCOI1Faces(env, ui) {
ui.commitSketch(); ui.commitSketch();
ui.openWizard('EXTRUDE'); ui.openWizard('EXTRUDE');
ui.wizardContext.updateParam('value', 50); ui.wizardContext.updateParam('length', 50);
await ui.wizardOK(); await ui.wizardOK();
@ -42,7 +40,7 @@ export async function testExtrudeCOI2Faces(env, ui) {
ui.commitSketch(); ui.commitSketch();
ui.openWizard('EXTRUDE'); ui.openWizard('EXTRUDE');
ui.wizardContext.updateParam('value', 50); ui.wizardContext.updateParam('length', 50);
await ui.wizardOK(); await ui.wizardOK();
@ -57,7 +55,7 @@ export async function testExtrudeCOI3Faces(env, ui) {
ui.commitSketch(); ui.commitSketch();
ui.openWizard('EXTRUDE'); ui.openWizard('EXTRUDE');
ui.wizardContext.updateParam('value', 50); ui.wizardContext.updateParam('length', 50);
await ui.wizardOK(); await ui.wizardOK();
@ -72,7 +70,7 @@ export async function testExtrudeCOI4Faces(env, ui) {
ui.commitSketch(); ui.commitSketch();
ui.openWizard('EXTRUDE'); ui.openWizard('EXTRUDE');
ui.wizardContext.updateParam('value', 50); ui.wizardContext.updateParam('length', 50);
await ui.wizardOK(); await ui.wizardOK();

View file

@ -47,11 +47,8 @@ export async function testExtrudeFromSketch(env, ui) {
} }
testExtrudeFromSketch.only = true
export async function testExtrudeArc(env, ui) { export async function testExtrudeArc(env, ui) {
let sketcherUI = await createPlaneAndOpenSketcher(ui); let [sketcherUI, sketchedFace] = await createPlaneAndOpenSketcher(ui);
let sketchedFace = ui.context.services.selection.face.single;
let arc = sketcherUI.addArc(0, 0, 100, 0, -100, 0); let arc = sketcherUI.addArc(0, 0, 100, 0, -100, 0);
let segment = sketcherUI.addSegment(100, 0, -100, 0); let segment = sketcherUI.addSegment(100, 0, -100, 0);
@ -64,7 +61,7 @@ export async function testExtrudeArc(env, ui) {
ui.selectFaces([0, 0, -10], [0, 0, 10]); ui.selectFaces([0, 0, -10], [0, 0, 10]);
ui.openWizard('EXTRUDE'); ui.openWizard('EXTRUDE');
ui.wizardContext.updateParam('value', 200); ui.wizardContext.updateParam('length', 200);
await ui.wizardOK(); await ui.wizardOK();
@ -88,8 +85,7 @@ export async function testExtrudeArc(env, ui) {
} }
export async function testExtrudeCircle(env, ui) { export async function testExtrudeCircle(env, ui) {
let sketcherUI = await createPlaneAndOpenSketcher(ui); let [sketcherUI, sketchedFace] = await createPlaneAndOpenSketcher(ui);
let sketchedFace = ui.context.services.selection.face.single;
let circle = sketcherUI.addCircle(100, 100, 100); let circle = sketcherUI.addCircle(100, 100, 100);
ui.commitSketch(); ui.commitSketch();
@ -97,7 +93,7 @@ export async function testExtrudeCircle(env, ui) {
ui.selectFaces([0, 0, -10], [0, 0, 10]); ui.selectFaces([0, 0, -10], [0, 0, 10]);
ui.openWizard('EXTRUDE'); ui.openWizard('EXTRUDE');
ui.wizardContext.updateParam('value', 200); ui.wizardContext.updateParam('length', 200);
await ui.wizardOK(); await ui.wizardOK();
@ -118,8 +114,7 @@ export async function testExtrudeCircle(env, ui) {
} }
export async function testExtrudeEllipse(env, ui) { export async function testExtrudeEllipse(env, ui) {
let sketcherUI = await createPlaneAndOpenSketcher(ui); let [sketcherUI, sketchedFace] = await createPlaneAndOpenSketcher(ui);
let sketchedFace = ui.context.services.selection.face.single;
let ellipse = sketcherUI.addEllipse(-100, 100, 100, 100, 0, 150); let ellipse = sketcherUI.addEllipse(-100, 100, 100, 100, 0, 150);
ui.commitSketch(); ui.commitSketch();
@ -127,7 +122,7 @@ export async function testExtrudeEllipse(env, ui) {
ui.selectFaces([0, 0, -10], [0, 0, 10]); ui.selectFaces([0, 0, -10], [0, 0, 10]);
ui.openWizard('EXTRUDE'); ui.openWizard('EXTRUDE');
ui.wizardContext.updateParam('value', 200); ui.wizardContext.updateParam('length', 200);
await ui.wizardOK(); await ui.wizardOK();
@ -158,7 +153,7 @@ export async function testExtrudeEllipticalArc(env, ui) {
ui.selectFaces([0, 0, -10], [0, 0, 10]); ui.selectFaces([0, 0, -10], [0, 0, 10]);
ui.openWizard('EXTRUDE'); ui.openWizard('EXTRUDE');
ui.wizardContext.updateParam('value', 200); ui.wizardContext.updateParam('length', 200);
await ui.wizardOK(); await ui.wizardOK();
@ -179,8 +174,7 @@ export async function testExtrudeEllipticalArc(env, ui) {
} }
export async function testExtrudeBezier(env, ui) { export async function testExtrudeBezier(env, ui) {
let sketcherUI = await createPlaneAndOpenSketcher(ui); let [sketcherUI, sketchedFace] = await createPlaneAndOpenSketcher(ui);
let sketchedFace = ui.context.services.selection.face.single;
let bezier = sketcherUI.addBezier(-100, 100, 100, 100, 0, 150); let bezier = sketcherUI.addBezier(-100, 100, 100, 100, 0, 150);
sketcherUI.move(bezier.cp2.x, bezier.cp2.y, bezier.cp2.x, bezier.cp1.y); sketcherUI.move(bezier.cp2.x, bezier.cp2.y, bezier.cp2.x, bezier.cp1.y);
@ -192,7 +186,7 @@ export async function testExtrudeBezier(env, ui) {
ui.selectFaces([0, 0, -10], [0, 0, 10]); ui.selectFaces([0, 0, -10], [0, 0, 10]);
ui.openWizard('EXTRUDE'); ui.openWizard('EXTRUDE');
ui.wizardContext.updateParam('value', 200); ui.wizardContext.updateParam('length', 200);
await ui.wizardOK(); await ui.wizardOK();

View file

@ -4,8 +4,7 @@ import {createPlaneAndOpenSketcher} from '../utils/scripts';
export const TEST_MODE = 'modellerUI'; export const TEST_MODE = 'modellerUI';
export async function testExtrudePrism(env, ui) { export async function testExtrudePrism(env, ui) {
let sketcherUI = await createPlaneAndOpenSketcher(ui); let [sketcherUI, sketchedFace] = await createPlaneAndOpenSketcher(ui);
let sketchedFace = ui.context.services.selection.face.single;
let [S1, S2, S3, S4] = sketcherUI.addRectangle(-100, -100, 100, 100); let [S1, S2, S3, S4] = sketcherUI.addRectangle(-100, -100, 100, 100);
// let gauge = ui.prismSurfaceGauge([-100, -100, 0], [100, -100, 0], [50, 50, 0], [-50, 50, 0] ); // let gauge = ui.prismSurfaceGauge([-100, -100, 0], [100, -100, 0], [50, 50, 0], [-50, 50, 0] );
@ -17,7 +16,7 @@ export async function testExtrudePrism(env, ui) {
ui.selectFaces([0, 0, -10], [0, 0, 10]); ui.selectFaces([0, 0, -10], [0, 0, 10]);
ui.openWizard('EXTRUDE'); ui.openWizard('EXTRUDE');
ui.wizardContext.updateParam('value', 2000); ui.wizardContext.updateParam('height', 2000);
ui.wizardContext.updateParam('prism', 0.1); ui.wizardContext.updateParam('prism', 0.1);
await ui.wizardOK(); await ui.wizardOK();
env.fail(); env.fail();

View file

@ -3,7 +3,7 @@ import {createPlaneAndOpenSketcher, extrudeCube} from '../utils/scripts';
export const TEST_MODE = 'modellerUI'; export const TEST_MODE = 'modellerUI';
export async function testLoftOver2Sections(env, ui) { export async function testLoftOver2Sections(env, ui) {
let sui = await createPlaneAndOpenSketcher(ui); let [sui, sketchedFace] = await createPlaneAndOpenSketcher(ui);
sui.addRectangle(-100, -100, 100, 100); sui.addRectangle(-100, -100, 100, 100);
ui.commitSketch(); ui.commitSketch();
@ -23,7 +23,7 @@ export async function testLoftOver2Sections(env, ui) {
} }
export async function testLoftOver3Sections(env, ui) { export async function testLoftOver3Sections(env, ui) {
let sui = await createPlaneAndOpenSketcher(ui); let [sui, sketchedFace] = await createPlaneAndOpenSketcher(ui);
sui.addRectangle(-100, -100, 100, 100); sui.addRectangle(-100, -100, 100, 100);
ui.commitSketch(); ui.commitSketch();
@ -55,7 +55,7 @@ export async function testLoftOver3Sections(env, ui) {
export async function testLoftCircleSections(env, ui) { export async function testLoftCircleSections(env, ui) {
let sui = await createPlaneAndOpenSketcher(ui); let [sui, sketchedFace] = await createPlaneAndOpenSketcher(ui);
sui.addRectangle(-100, -100, 100, 100); sui.addRectangle(-100, -100, 100, 100);
ui.commitSketch(); ui.commitSketch();

View file

@ -9,12 +9,12 @@ export async function createPlaneAndOpenSketcher(ui) {
} }
export async function extrudeCube(ui) { export async function extrudeCube(ui) {
let sketcherUI = await createPlaneAndOpenSketcher(ui); let [sketcherUI, sketchedFace] = await createPlaneAndOpenSketcher(ui);
sketcherUI.addRectangle(-100, -100, 100, 100); sketcherUI.addRectangle(-100, -100, 100, 100);
ui.commitSketch(); ui.commitSketch();
ui.selectFaces([0, 0, -10], [0, 0, 10]); ui.selectFaces([0, 0, -10], [0, 0, 10]);
ui.openWizard('EXTRUDE'); ui.openWizard('EXTRUDE');
ui.wizardContext.updateParam('value', 200); ui.wizardContext.updateParam('length', 200);
await ui.wizardOK(); await ui.wizardOK();
} }

View file

@ -79,8 +79,8 @@ export function activate(context: ApplicationContext) {
function showHintFor(request: HintRequest) { function showHintFor(request: HintRequest) {
if (request) { if (request) {
let {actionId, x, y, requester} = request; let {actionId, x, y, requester} = request;
let actionState = streams.action.state[actionId].value; let actionState = streams.action.state[actionId]?.value;
let actionAppearance = streams.action.appearance[actionId].value; let actionAppearance = streams.action.appearance[actionId]?.value;
if (actionState && actionAppearance) { if (actionState && actionAppearance) {
streams.action.hint.value = { streams.action.hint.value = {
actionId, x, y, requester, actionId, x, y, requester,

View file

@ -1,7 +1,7 @@
export function enableAnonymousActionHint(ctx) { export function enableAnonymousActionHint(ctx) {
const {services, actionService} = ctx;
return function(actionId) { return function(actionId) {
const {services, actionService} = ctx;
let {left, top} = services.dom.viewerContainer.getBoundingClientRect(); let {left, top} = services.dom.viewerContainer.getBoundingClientRect();
actionService.showHintFor({ actionService.showHintFor({
actionId, actionId,

View file

@ -93,8 +93,12 @@ export function activate(ctx: ApplicationContext) {
} }
}) })
const updateParams = mutator => workingRequest$.update((req: WorkingRequest) => produce(req, draft => mutator(draft.params))); const updateParams = mutator => workingRequest$.update((req: WorkingRequest) => produce(req, draft => {
const updateState = mutator => state$.update((state: WizardState) => produce(state, mutator)); mutator(draft.params)
}));
const updateState = mutator => state$.update((state: WizardState) => produce(state, draft => {
mutator(draft);
}));
const updateParam = (path: ParamsPath, value: OperationParamValue) => { const updateParam = (path: ParamsPath, value: OperationParamValue) => {
updateParams(params => { updateParams(params => {
// if (operation.onParamsUpdate) { // if (operation.onParamsUpdate) {
@ -137,7 +141,7 @@ export function activate(ctx: ApplicationContext) {
applyWorkingRequest: () => { applyWorkingRequest: () => {
let {type, params} = getWorkingRequest(); let {type, params} = getWorkingRequest();
let request = clone({type, params}); let request = clone({type, params});
const setError = error => state$.mutate(state => state.error = error); const setError = error => updateState(state => state.error = error);
if (insertOperation$.value) { if (insertOperation$.value) {
ctx.craftService.modify(request, cancel, setError); ctx.craftService.modify(request, cancel, setError);
} else { } else {

View file

@ -47,7 +47,7 @@ function registerCoreOperations(ctx: WorkbenchesLoaderInputContext) {
planeOperation, planeOperation,
// boxOperation, // boxOperation,
// extrudeOperation, // extrudeOperation,
cutOperation, // cutOperation,
revolveOperation, revolveOperation,
filletOperation, filletOperation,
createDatumOperation, createDatumOperation,