diff --git a/web/app/math/vec.js b/modules/math/vec.js similarity index 98% rename from web/app/math/vec.js rename to modules/math/vec.js index e0e15ea2..ab49a4f5 100644 --- a/web/app/math/vec.js +++ b/modules/math/vec.js @@ -193,6 +193,10 @@ export function polynomial(coefs, vectors) { return out; } +export function fromXYZ({x, y, z}) { + return [x, y, z]; +} + export const AXIS_X3 = [1,0,0]; export const AXIS_Y3 = [0,1,0]; export const AXIS_Z3 = [0,0,1]; diff --git a/modules/scene/objects/meshLine.js b/modules/scene/objects/meshLine.js index d090c994..92342879 100644 --- a/modules/scene/objects/meshLine.js +++ b/modules/scene/objects/meshLine.js @@ -1,4 +1,4 @@ -import * as vec from '../../../web/app/math/vec'; +import * as vec from 'math/vec'; import {perpendicularVector} from '../../../web/app/math/math'; import {Face3, Geometry, Vector3} from 'three'; diff --git a/modules/scene/objects/scalableLine.js b/modules/scene/objects/scalableLine.js index 21ecf465..285f1592 100644 --- a/modules/scene/objects/scalableLine.js +++ b/modules/scene/objects/scalableLine.js @@ -1,6 +1,6 @@ import {Face3, FaceColors, Geometry, Mesh, MeshBasicMaterial, MeshPhongMaterial} from 'three'; import {advancePseudoFrenetFrame, frenetFrame, pseudoFrenetFrame} from '../../../web/app/brep/geom/curves/frenetFrame'; -import * as vec from '../../../web/app/math/vec'; +import * as vec from 'math/vec'; import {viewScaleFactor} from '../scaleHelper'; import {arrToThree} from 'math/vectorAdapters'; import {ORIGIN} from '../../../web/app/math/l3space'; diff --git a/modules/scene/sceneSetup.js b/modules/scene/sceneSetup.js index 31db82de..ba7e156b 100644 --- a/modules/scene/sceneSetup.js +++ b/modules/scene/sceneSetup.js @@ -173,8 +173,11 @@ export default class SceneSetUp { return raycaster; } - raycast(event, objects) { - let raycaster = this.createRaycaster(event.offsetX, event.offsetY); + raycast(event, objects, logInfoOut = null) { + const raycaster = this.createRaycaster(event.offsetX, event.offsetY); + if (logInfoOut !== null) { + logInfoOut.ray = raycaster.ray + } return raycaster.intersectObjects( objects, true ); } diff --git a/modules/ui/components/controls/Field.jsx b/modules/ui/components/controls/Field.jsx index 58c77e97..5fe76d76 100644 --- a/modules/ui/components/controls/Field.jsx +++ b/modules/ui/components/controls/Field.jsx @@ -3,6 +3,6 @@ import React from 'react'; import ls from './Field.less' import cx from 'classnames'; -export default function Field({active, ...props}) { - return
+export default function Field({active, name, ...props}) { + return } diff --git a/modules/voxels/octree.js b/modules/voxels/octree.js index 625d4130..3d721c52 100644 --- a/modules/voxels/octree.js +++ b/modules/voxels/octree.js @@ -1,4 +1,4 @@ -import * as vec from "../../web/app/math/vec"; +import * as vec from "math/vec"; export class Node { diff --git a/test/coreTests/subjects/modellerTPI.js b/test/coreTests/subjects/modellerTPI.js index 9c1f1f07..132294ad 100644 --- a/test/coreTests/subjects/modellerTPI.js +++ b/test/coreTests/subjects/modellerTPI.js @@ -53,7 +53,7 @@ export default ctx => { } function select(from, to) { - ctx.services.pickControl.pickFromRay(from, to, ALL_EXCLUDING_SOLID_KINDS); + ctx.services.pickControl.simulatePickFromRay(from, to); } function selectFirst(type) { diff --git a/test/coreTests/subjects/sketcherTPI.js b/test/coreTests/subjects/sketcherTPI.js index d023fa86..6a7da9b6 100644 --- a/test/coreTests/subjects/sketcherTPI.js +++ b/test/coreTests/subjects/sketcherTPI.js @@ -1,26 +1,9 @@ import * as sketcher_utils from '../utils/sketcherUtils' -import {decapitalize} from '../../../modules/gems/capitalize'; import {genSerpinskiImpl} from '../../../web/app/utils/genSerpinski'; import {distance} from '../../../web/app/math/math'; export function createSubjectFromInPlaceSketcher(ctx) { - let actions = {}; - for (const actionId of Object.keys(ctx.streams.action.state)) { - if (actionId.startsWith('sketch')) { - let oldId = decapitalize(actionId.substring(6)); - actions[oldId] = { - action: () => ctx.services.action.run(actionId) - }; - actions.addBezierCurve = actions.addCubicBezierSpline; - } - } - - const oldStyleSketcherApp = { - viewer: ctx.services.sketcher.inPlaceEditor.viewer, - actions - }; - - return createSketcherTPI(oldStyleSketcherApp); + return createSketcherTPI(ctx.services.sketcher.inPlaceEditor.sketcherAppContext); } export function createSketcherTPI(context) { diff --git a/test/coreTests/utils/sketcherUtils.js b/test/coreTests/utils/sketcherUtils.js index 138e4229..4e98c6ea 100644 --- a/test/coreTests/utils/sketcherUtils.js +++ b/test/coreTests/utils/sketcherUtils.js @@ -73,7 +73,7 @@ export function addArc(ctx, cX, cY, aX, aY, bX, bY) { [bX, bY] = modelToScreen(ctx.viewer, bX, bY); [cX, cY] = modelToScreen(ctx.viewer, cX, cY); - ctx.actions['addArc'].action(); + ctx.actions.ArcTool.invoke(ctx); moveAndClickXY(ctx, cX, cY); moveAndClickXY(ctx, aX, aY); @@ -166,12 +166,12 @@ export class TestSegment { } } -export function modelToScreen(x, y) { - if (this.screenToModelMatrix) { - let modelToScreenMx = this.screenToModelMatrix.invert(); +export function modelToScreen(viewer, x, y) { + if (viewer.screenToModelMatrix) { + let modelToScreenMx = viewer.screenToModelMatrix.invert(); [x, y] = modelToScreenMx.apply3([x, y, 0]); } - x /= this.retinaPxielRatio; - y = (this.canvas.height - y) / this.retinaPxielRatio; + x /= viewer.retinaPxielRatio; + y = (viewer.canvas.height - y) / viewer.retinaPxielRatio; return [x, y]; } \ No newline at end of file diff --git a/test/cypress/integration/part3d/wizards.spec.js b/test/cypress/integration/part3d/wizards.spec.js index 1cc0d5a3..948b257d 100644 --- a/test/cypress/integration/part3d/wizards.spec.js +++ b/test/cypress/integration/part3d/wizards.spec.js @@ -16,13 +16,37 @@ import {defineCypressTests} from "../../../coreTests/defineCypress"; describe("Wizrds", () => { - afterEach(() => { - cy.screenshot(); + beforeEach(() => { + cy.openModeller(); }); - it("plane wizrd should open", () => { - createDatum(); + // afterEach(() => { + // cy.screenshot(); + // }); + it("plane wizard should open", () => { + cy.getActionButton('PLANE').click(); + cy.get('.wizard').should('have.attr', 'data-operation-id', 'PLANE'); + cy.getActiveWizardField('depth').find('input').type('100'); + cy.get('.wizard .dialog-ok').click(); + cy.selectRaycasting([-119, 29, 167], [23, -15, 33]) + }); + + it("extrube wizard should work", () => { + cy.getActionButton('PLANE').click(); + cy.get('.wizard').should('have.attr', 'data-operation-id', 'PLANE'); + cy.getActiveWizardField('depth').find('input').type('100'); + cy.get('.wizard .dialog-ok').click(); + cy.selectRaycasting([-119, 29, 167], [23, -15, 33]); + cy.openSketcher().then(sketcher => { + sketcher.addRectangle(0, 0, 80, 100); + cy.commitSketch(); + }); + cy.getActionButton('EXTRUDE').click(); + cy.get('.wizard .dialog-ok').click(); + cy.selectRaycasting([-18, 67, 219], [120, 25, 81]); + cy.get('.float-view-btn[data-view="selection"]').click(); + cy.get('.selection-view [data-entity="face"] li').should('have.text', 'S:1/F:5'); }); diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index ca4d256f..f69ae04e 100644 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -1,25 +1,38 @@ -// *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add("login", (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) +import modellerUISubject from "../../coreTests/subjects/modellerTPI"; + + +Cypress.Commands.add("openModeller", () => { + return cy.visit("http://localhost:3000?test&LOG.PICK=true");; +}); + + +Cypress.Commands.add("getActionButton", (actionId) => { + return cy.get(`[data-action-id='${actionId}']`); +}); + + +Cypress.Commands.add("getActiveWizardField", (fieldName) => { + + return cy.get(`.wizard [data-field-name='${fieldName}']`); + +}); + +Cypress.Commands.add("selectRaycasting", (from, to) => { + return cy.window().then(win => { + win.__CAD_APP.services.pickControl.simulatePickFromRay(from, to); + win.__DEBUG__.AddSegment3(from, to); + }); +}); + +Cypress.Commands.add("openSketcher", () => { + return cy.getModellerTPI().then(tpi => tpi.openSketcher()); +}); + +Cypress.Commands.add("commitSketch", () => { + return cy.getModellerTPI().then(tpi => tpi.commitSketch()); +}); + + +Cypress.Commands.add("getModellerTPI", () => { + return cy.window().then(win => modellerUISubject(win.__CAD_APP)); +}); diff --git a/web/app/brep/geom/curves/bezierCubic.js b/web/app/brep/geom/curves/bezierCubic.js index 79bd78a2..a23b95fd 100644 --- a/web/app/brep/geom/curves/bezierCubic.js +++ b/web/app/brep/geom/curves/bezierCubic.js @@ -1,4 +1,4 @@ -import * as vec from '../../../math/vec'; +import * as vec from 'math/vec'; export function cubicBezierPoint(p0, p1, p2, p3, t) { const mt = 1 - t; diff --git a/web/app/brep/geom/curves/boundedCurve.js b/web/app/brep/geom/curves/boundedCurve.js index 315a2735..a83f6639 100644 --- a/web/app/brep/geom/curves/boundedCurve.js +++ b/web/app/brep/geom/curves/boundedCurve.js @@ -1,4 +1,4 @@ -import * as vec from '../../../math/vec'; +import * as vec from 'math/vec'; import InvertedCurve from './invertedCurve'; export default class BoundedCurve { diff --git a/web/app/brep/geom/curves/closestPoint.js b/web/app/brep/geom/curves/closestPoint.js index 4e14b13f..3a3fac0c 100644 --- a/web/app/brep/geom/curves/closestPoint.js +++ b/web/app/brep/geom/curves/closestPoint.js @@ -1,4 +1,4 @@ -import * as vec from '../../../math/vec'; +import * as vec from 'math/vec'; import newtonIterations, {newtonIterationsOnInterval} from './newtonIterations'; import {curveTessParams} from '../impl/curve/curve-tess'; diff --git a/web/app/brep/geom/curves/cubicHermiteIntepolation.js b/web/app/brep/geom/curves/cubicHermiteIntepolation.js index b608552b..0e540ea5 100644 --- a/web/app/brep/geom/curves/cubicHermiteIntepolation.js +++ b/web/app/brep/geom/curves/cubicHermiteIntepolation.js @@ -1,4 +1,4 @@ -import * as vec from '../../../math/vec'; +import * as vec from 'math/vec'; import {cubicBezierDer1, cubicBezierDer2, cubicBezierPoint} from './bezierCubic'; import {closestToCurveParam} from './closestPoint'; import InvertedCurve from './invertedCurve'; diff --git a/web/app/brep/geom/curves/frenetFrame.js b/web/app/brep/geom/curves/frenetFrame.js index 6227f02c..10eee36a 100644 --- a/web/app/brep/geom/curves/frenetFrame.js +++ b/web/app/brep/geom/curves/frenetFrame.js @@ -1,4 +1,4 @@ -import * as vec from '../../../math/vec'; +import * as vec from 'math/vec'; import {perpendicularVector} from '../../../math/math'; export function frenetFrame(D1, D2) { diff --git a/web/app/brep/geom/curves/intersectionCurve.js b/web/app/brep/geom/curves/intersectionCurve.js index c175d873..e455649a 100644 --- a/web/app/brep/geom/curves/intersectionCurve.js +++ b/web/app/brep/geom/curves/intersectionCurve.js @@ -1,6 +1,6 @@ import {TOLERANCE, veq3} from '../tolerance'; import {surfaceClosestParam} from '../impl/nurbs-ext'; -import * as vec from '../../../math/vec'; +import * as vec from 'math/vec'; import CubicHermiteInterpolation from './cubicHermiteIntepolation'; import InvertedCurve from './invertedCurve'; import {genericCurveSplit} from './boundedCurve'; diff --git a/web/app/brep/geom/curves/invertedCurve.js b/web/app/brep/geom/curves/invertedCurve.js index c3e6c635..9685ffff 100644 --- a/web/app/brep/geom/curves/invertedCurve.js +++ b/web/app/brep/geom/curves/invertedCurve.js @@ -1,4 +1,4 @@ -import * as vec from '../../../math/vec'; +import * as vec from 'math/vec'; export default class InvertedCurve { diff --git a/web/app/brep/geom/impl/curve/curve-tess.js b/web/app/brep/geom/impl/curve/curve-tess.js index 235684d7..71bf5bef 100644 --- a/web/app/brep/geom/impl/curve/curve-tess.js +++ b/web/app/brep/geom/impl/curve/curve-tess.js @@ -1,4 +1,4 @@ -import * as vec from "../../../../math/vec"; +import * as vec from "math/vec"; export default function curveTess(curve, min, max, tessTol, scale) { return curveTessParams(curve, min, max, tessTol, scale).map(u => curve.point(u)); diff --git a/web/app/brep/geom/impl/curve/curves-isec.js b/web/app/brep/geom/impl/curve/curves-isec.js index 8af2b1cf..d5c4e7d4 100644 --- a/web/app/brep/geom/impl/curve/curves-isec.js +++ b/web/app/brep/geom/impl/curve/curves-isec.js @@ -1,4 +1,4 @@ -import * as vec from "../../../../math/vec"; +import * as vec from "math/vec"; import {TOLERANCE, TOLERANCE_SQ} from '../../tolerance'; import * as math from '../../../../math/math' import {fmin_bfgs} from "../../../../math/optim"; diff --git a/web/app/brep/geom/impl/nurbs-ext.js b/web/app/brep/geom/impl/nurbs-ext.js index 4ed9ac41..406a9c77 100644 --- a/web/app/brep/geom/impl/nurbs-ext.js +++ b/web/app/brep/geom/impl/nurbs-ext.js @@ -1,4 +1,4 @@ -import * as vec from "../../../math/vec"; +import * as vec from "math/vec"; import * as math from '../../../math/math' import {eqEps, TOLERANCE, TOLERANCE_01, TOLERANCE_SQ} from '../tolerance'; import {fmin_bfgs} from "../../../math/optim"; diff --git a/web/app/brep/geom/intersection/surfaceSurface.js b/web/app/brep/geom/intersection/surfaceSurface.js index 5b40c30a..dd07a91c 100644 --- a/web/app/brep/geom/intersection/surfaceSurface.js +++ b/web/app/brep/geom/intersection/surfaceSurface.js @@ -1,7 +1,7 @@ import {NUMERICAL_SOLVE_TOL, TOLERANCE, TOLERANCE_01, TOLERANCE_SQ} from '../tolerance'; import {curveDomain, curvePoint, meshesIntersect, surfaceMaxDegree} from '../impl/nurbs-ext'; import {IntersectionCurve} from '../curves/intersectionCurve'; -import * as vec from '../../../math/vec'; +import * as vec from 'math/vec'; export function surfaceIntersect(surfaceA, surfaceB) { const tessA = verb.eval.Tess.rationalSurfaceAdaptive(surfaceA); diff --git a/web/app/brep/io/brepIO.js b/web/app/brep/io/brepIO.js index 0c49cba7..0a361794 100644 --- a/web/app/brep/io/brepIO.js +++ b/web/app/brep/io/brepIO.js @@ -1,7 +1,7 @@ import BrepBuilder, {createBoundingSurfaceFrom2DPoints, createBoundingSurfaceFromBBox} from '../brep-builder'; import VertexFactory from '../vertexFactory'; import NurbsSurface from '../geom/surfaces/nurbsSurface'; -import * as vec from '../../math/vec'; +import * as vec from 'math/vec'; import {BrepSurface} from '../geom/surfaces/brepSurface'; import {Plane} from '../geom/impl/plane'; import Vector from '../../../../modules/math/vector'; diff --git a/web/app/cad/actions/ActionButtonBehavior.jsx b/web/app/cad/actions/ActionButtonBehavior.jsx index e8a9796d..a03e5ad0 100644 --- a/web/app/cad/actions/ActionButtonBehavior.jsx +++ b/web/app/cad/actions/ActionButtonBehavior.jsx @@ -18,6 +18,7 @@ export function ActionButtonBehavior({children, actionId}) { const actionService = ctx.services.action; return children({ + 'data-action-id': actionId, onClick: e => actionService.run(actionId, e), onMouseEnter: e => { updateCoords(e); diff --git a/web/app/cad/craft/wizard/components/Wizard.jsx b/web/app/cad/craft/wizard/components/Wizard.jsx index 7febdbca..8b09a206 100644 --- a/web/app/cad/craft/wizard/components/Wizard.jsx +++ b/web/app/cad/craft/wizard/components/Wizard.jsx @@ -60,6 +60,8 @@ export default class Wizard extends React.Component { onClose={this.cancel} onKeyDown={this.onKeyDown} setFocus={this.focusFirstInput} + className='Wizard' + data-operation-id={operation.id} controlButtons={<>