mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 08:25:19 +01:00
fix extrude-cut tests
This commit is contained in:
parent
bf19c9577e
commit
32b2291aa9
13 changed files with 61 additions and 50 deletions
|
|
@ -150,7 +150,7 @@ export const ExtrudeOperation: OperationDescriptor<ExtrudeParams> = {
|
|||
|
||||
masking: [
|
||||
{
|
||||
id: 'CUT2',
|
||||
id: 'CUT',
|
||||
label: 'Cut',
|
||||
icon: 'img/cad/cut',
|
||||
info: 'makes a cut based on 2D sketch',
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export const ModelerWorkspace: WorkbenchConfig = {
|
|||
ui: {
|
||||
toolbar: [
|
||||
'DATUM_CREATE', 'PLANE', 'EditFace', '-',
|
||||
"EXTRUDE", "CUT2", "REVOLVE", "LOFT", "SWEEP", "-",
|
||||
"EXTRUDE", "CUT", "REVOLVE", "LOFT", "SWEEP", "-",
|
||||
"BOOLEAN", "-",
|
||||
"SHELL_TOOL", "FILLET_TOOL", "SCALE_BODY","-",
|
||||
"MIRROR_BODY", "PATTERN_LINEAR", "PATTERN_RADIAL", "-",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@ import {genSerpinskiImpl} from '../../../web/app/utils/genSerpinski';
|
|||
import {distance} from 'math/commons';
|
||||
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import {extrudeCube} from '../utils/scripts';
|
||||
|
||||
export const TEST_MODE = 'modellerUI';
|
||||
export const only = true;
|
||||
|
||||
export async function testCutMid(env, ui) {
|
||||
await extrudeCube(ui);
|
||||
|
|
@ -9,9 +10,10 @@ export async function testCutMid(env, ui) {
|
|||
let sui = ui.openSketcher();
|
||||
sui.addRectangle(-50, -50, 50, 50);
|
||||
ui.commitSketch();
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardContext.updateParam('height', 50);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
@ -24,9 +26,10 @@ export async function testCutCOI1Faces(env, ui) {
|
|||
let sui = ui.openSketcher();
|
||||
sui.addRectangle(0, 0, 80, 100);
|
||||
ui.commitSketch();
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardContext.updateParam('height', 50);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
@ -39,9 +42,10 @@ export async function testCutCOI2Faces(env, ui) {
|
|||
let sui = ui.openSketcher();
|
||||
sui.addRectangle(0, 0, 100, 100);
|
||||
ui.commitSketch();
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardContext.updateParam('length', 50);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
@ -54,9 +58,10 @@ export async function testCutCOI3Faces(env, ui) {
|
|||
let sui = ui.openSketcher();
|
||||
sui.addRectangle(0, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardContext.updateParam('length', 50);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
@ -69,9 +74,10 @@ export async function testCutCOI4Faces(env, ui) {
|
|||
let sui = ui.openSketcher();
|
||||
sui.addRectangle(-100, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardContext.updateParam('length', 50);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
@ -86,9 +92,10 @@ export async function testCutMidAllWay(env, ui) {
|
|||
let sui = ui.openSketcher();
|
||||
sui.addRectangle(-50, -50, 50, 50);
|
||||
ui.commitSketch();
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardContext.updateParam('length', 200);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
@ -101,9 +108,10 @@ export async function testCutCOI1FacesAllWay(env, ui) {
|
|||
let sui = ui.openSketcher();
|
||||
sui.addRectangle(0, 0, 80, 100);
|
||||
ui.commitSketch();
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardContext.updateParam('length', 200);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
@ -116,9 +124,10 @@ export async function testCutCOI2FacesAllWay(env, ui) {
|
|||
let sui = ui.openSketcher();
|
||||
sui.addRectangle(0, 0, 100, 100);
|
||||
ui.commitSketch();
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardContext.updateParam('length', 200);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
@ -131,13 +140,15 @@ export async function testCutCOI3FacesAllWay(env, ui) {
|
|||
let sui = ui.openSketcher();
|
||||
sui.addRectangle(0, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardContext.updateParam('length', 200);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
}
|
||||
testCutCOI3FacesAllWay.only = true
|
||||
|
||||
export async function testCutCOI4FacesAllWay(env, ui) {
|
||||
await extrudeCube(ui);
|
||||
|
|
@ -146,9 +157,10 @@ export async function testCutCOI4FacesAllWay(env, ui) {
|
|||
let sui = ui.openSketcher();
|
||||
sui.addRectangle(-100, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardContext.updateParam('length', 200);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,8 @@ export async function testExtrudeMid(env, ui) {
|
|||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardContext.updateParam('length', 50);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
}
|
||||
|
||||
export async function testExtrudeCOI1Faces(env, ui) {
|
||||
|
|
@ -27,7 +25,7 @@ export async function testExtrudeCOI1Faces(env, ui) {
|
|||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardContext.updateParam('length', 50);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
@ -42,7 +40,7 @@ export async function testExtrudeCOI2Faces(env, ui) {
|
|||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardContext.updateParam('length', 50);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
@ -57,7 +55,7 @@ export async function testExtrudeCOI3Faces(env, ui) {
|
|||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardContext.updateParam('length', 50);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
@ -72,7 +70,7 @@ export async function testExtrudeCOI4Faces(env, ui) {
|
|||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardContext.updateParam('length', 50);
|
||||
await ui.wizardOK();
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -47,11 +47,8 @@ export async function testExtrudeFromSketch(env, ui) {
|
|||
|
||||
}
|
||||
|
||||
testExtrudeFromSketch.only = true
|
||||
|
||||
export async function testExtrudeArc(env, ui) {
|
||||
let sketcherUI = await createPlaneAndOpenSketcher(ui);
|
||||
let sketchedFace = ui.context.services.selection.face.single;
|
||||
let [sketcherUI, sketchedFace] = await createPlaneAndOpenSketcher(ui);
|
||||
let arc = sketcherUI.addArc(0, 0, 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.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardContext.updateParam('length', 200);
|
||||
|
||||
await ui.wizardOK();
|
||||
|
||||
|
|
@ -88,8 +85,7 @@ export async function testExtrudeArc(env, ui) {
|
|||
}
|
||||
|
||||
export async function testExtrudeCircle(env, ui) {
|
||||
let sketcherUI = await createPlaneAndOpenSketcher(ui);
|
||||
let sketchedFace = ui.context.services.selection.face.single;
|
||||
let [sketcherUI, sketchedFace] = await createPlaneAndOpenSketcher(ui);
|
||||
let circle = sketcherUI.addCircle(100, 100, 100);
|
||||
|
||||
ui.commitSketch();
|
||||
|
|
@ -97,7 +93,7 @@ export async function testExtrudeCircle(env, ui) {
|
|||
ui.selectFaces([0, 0, -10], [0, 0, 10]);
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardContext.updateParam('length', 200);
|
||||
|
||||
await ui.wizardOK();
|
||||
|
||||
|
|
@ -118,8 +114,7 @@ export async function testExtrudeCircle(env, ui) {
|
|||
}
|
||||
|
||||
export async function testExtrudeEllipse(env, ui) {
|
||||
let sketcherUI = await createPlaneAndOpenSketcher(ui);
|
||||
let sketchedFace = ui.context.services.selection.face.single;
|
||||
let [sketcherUI, sketchedFace] = await createPlaneAndOpenSketcher(ui);
|
||||
let ellipse = sketcherUI.addEllipse(-100, 100, 100, 100, 0, 150);
|
||||
|
||||
ui.commitSketch();
|
||||
|
|
@ -127,7 +122,7 @@ export async function testExtrudeEllipse(env, ui) {
|
|||
ui.selectFaces([0, 0, -10], [0, 0, 10]);
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardContext.updateParam('length', 200);
|
||||
|
||||
await ui.wizardOK();
|
||||
|
||||
|
|
@ -158,7 +153,7 @@ export async function testExtrudeEllipticalArc(env, ui) {
|
|||
ui.selectFaces([0, 0, -10], [0, 0, 10]);
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardContext.updateParam('length', 200);
|
||||
|
||||
await ui.wizardOK();
|
||||
|
||||
|
|
@ -179,8 +174,7 @@ export async function testExtrudeEllipticalArc(env, ui) {
|
|||
}
|
||||
|
||||
export async function testExtrudeBezier(env, ui) {
|
||||
let sketcherUI = await createPlaneAndOpenSketcher(ui);
|
||||
let sketchedFace = ui.context.services.selection.face.single;
|
||||
let [sketcherUI, sketchedFace] = await createPlaneAndOpenSketcher(ui);
|
||||
let bezier = sketcherUI.addBezier(-100, 100, 100, 100, 0, 150);
|
||||
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.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardContext.updateParam('length', 200);
|
||||
|
||||
await ui.wizardOK();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ import {createPlaneAndOpenSketcher} from '../utils/scripts';
|
|||
export const TEST_MODE = 'modellerUI';
|
||||
|
||||
export async function testExtrudePrism(env, ui) {
|
||||
let sketcherUI = await createPlaneAndOpenSketcher(ui);
|
||||
let sketchedFace = ui.context.services.selection.face.single;
|
||||
let [sketcherUI, sketchedFace] = await createPlaneAndOpenSketcher(ui);
|
||||
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] );
|
||||
|
|
@ -17,7 +16,7 @@ export async function testExtrudePrism(env, ui) {
|
|||
ui.selectFaces([0, 0, -10], [0, 0, 10]);
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 2000);
|
||||
ui.wizardContext.updateParam('height', 2000);
|
||||
ui.wizardContext.updateParam('prism', 0.1);
|
||||
await ui.wizardOK();
|
||||
env.fail();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {createPlaneAndOpenSketcher, extrudeCube} from '../utils/scripts';
|
|||
export const TEST_MODE = 'modellerUI';
|
||||
|
||||
export async function testLoftOver2Sections(env, ui) {
|
||||
let sui = await createPlaneAndOpenSketcher(ui);
|
||||
let [sui, sketchedFace] = await createPlaneAndOpenSketcher(ui);
|
||||
sui.addRectangle(-100, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ export async function testLoftOver2Sections(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);
|
||||
ui.commitSketch();
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ export async function testLoftOver3Sections(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);
|
||||
ui.commitSketch();
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ export async function createPlaneAndOpenSketcher(ui) {
|
|||
}
|
||||
|
||||
export async function extrudeCube(ui) {
|
||||
let sketcherUI = await createPlaneAndOpenSketcher(ui);
|
||||
let [sketcherUI, sketchedFace] = await createPlaneAndOpenSketcher(ui);
|
||||
sketcherUI.addRectangle(-100, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
ui.selectFaces([0, 0, -10], [0, 0, 10]);
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardContext.updateParam('length', 200);
|
||||
await ui.wizardOK();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ export function activate(context: ApplicationContext) {
|
|||
function showHintFor(request: HintRequest) {
|
||||
if (request) {
|
||||
let {actionId, x, y, requester} = request;
|
||||
let actionState = streams.action.state[actionId].value;
|
||||
let actionAppearance = streams.action.appearance[actionId].value;
|
||||
let actionState = streams.action.state[actionId]?.value;
|
||||
let actionAppearance = streams.action.appearance[actionId]?.value;
|
||||
if (actionState && actionAppearance) {
|
||||
streams.action.hint.value = {
|
||||
actionId, x, y, requester,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
export function enableAnonymousActionHint(ctx) {
|
||||
const {services, actionService} = ctx;
|
||||
return function(actionId) {
|
||||
const {services, actionService} = ctx;
|
||||
let {left, top} = services.dom.viewerContainer.getBoundingClientRect();
|
||||
actionService.showHintFor({
|
||||
actionId,
|
||||
|
|
|
|||
|
|
@ -93,8 +93,12 @@ export function activate(ctx: ApplicationContext) {
|
|||
}
|
||||
})
|
||||
|
||||
const updateParams = mutator => workingRequest$.update((req: WorkingRequest) => produce(req, draft => mutator(draft.params)));
|
||||
const updateState = mutator => state$.update((state: WizardState) => produce(state, mutator));
|
||||
const updateParams = mutator => workingRequest$.update((req: WorkingRequest) => produce(req, draft => {
|
||||
mutator(draft.params)
|
||||
}));
|
||||
const updateState = mutator => state$.update((state: WizardState) => produce(state, draft => {
|
||||
mutator(draft);
|
||||
}));
|
||||
const updateParam = (path: ParamsPath, value: OperationParamValue) => {
|
||||
updateParams(params => {
|
||||
// if (operation.onParamsUpdate) {
|
||||
|
|
@ -137,7 +141,7 @@ export function activate(ctx: ApplicationContext) {
|
|||
applyWorkingRequest: () => {
|
||||
let {type, params} = getWorkingRequest();
|
||||
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) {
|
||||
ctx.craftService.modify(request, cancel, setError);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ function registerCoreOperations(ctx: WorkbenchesLoaderInputContext) {
|
|||
planeOperation,
|
||||
// boxOperation,
|
||||
// extrudeOperation,
|
||||
cutOperation,
|
||||
// cutOperation,
|
||||
revolveOperation,
|
||||
filletOperation,
|
||||
createDatumOperation,
|
||||
|
|
|
|||
Loading…
Reference in a new issue