From b1aabfed5c00c9bd743e548f93b2489fddbee502 Mon Sep 17 00:00:00 2001 From: "Val Erastov (xibyte)" Date: Tue, 10 Mar 2020 19:46:49 -0700 Subject: [PATCH] prepare for ellipse constraints --- web/app/sketcher/constr/ANConstraints.js | 21 +++++++++++++++++++++ web/app/sketcher/shapes/ellipse.js | 9 +++------ web/app/sketcher/shapes/param.js | 4 ++++ web/app/sketcher/tools/ellipse.js | 4 ++-- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/web/app/sketcher/constr/ANConstraints.js b/web/app/sketcher/constr/ANConstraints.js index e700b0be..3f89b942 100644 --- a/web/app/sketcher/constr/ANConstraints.js +++ b/web/app/sketcher/constr/ANConstraints.js @@ -180,6 +180,27 @@ export const ConstraintDefinitions = { }, + PointOnEllipse: { + id: 'PointOnEllipse', + name: 'Point On Ellipse', + + defineParamsScope: ([pt, ellipse], callback) => { + ellipse.visitParams(callback); + callback(new Param(0, 't')); + pt.visitParams(callback); + }, + + collectPolynomials: (polynomials, [p1x,p1y, p2x,p2y, r, t, px, py]) => { + const ellipsePoly = (p, t, p0, p1, p2, p3) => new Polynomial() + .monomial(-1); + + + polynomials.push(ellipsePoly()); + polynomials.push(ellipsePoly()); + }, + + }, + PointInMiddle: { id: 'PointInMiddle', name: 'Middle Point', diff --git a/web/app/sketcher/shapes/ellipse.js b/web/app/sketcher/shapes/ellipse.js index a817ae19..1a166013 100644 --- a/web/app/sketcher/shapes/ellipse.js +++ b/web/app/sketcher/shapes/ellipse.js @@ -1,10 +1,7 @@ -import {Ref} from './ref' import {SketchObject} from './sketch-object' -import {Constraints} from '../parametric' import * as math from '../../math/math'; -import {Circle} from "./circle"; -import {EndPoint} from "./point"; +import {Param} from "./param"; export class Ellipse extends SketchObject { @@ -14,9 +11,9 @@ export class Ellipse extends SketchObject { this.ep2 = ep2; this.addChild(this.ep1); this.addChild(this.ep2); - this.r = new Ref(0); + this.r = new Param(0, 'R'); + this.r.enforceVisualLimit = true; this.r.set(this.radiusX * 0.5); - this.r.obj = this; } recoverIfNecessary() { diff --git a/web/app/sketcher/shapes/param.js b/web/app/sketcher/shapes/param.js index e6ebd2f2..27f32b94 100644 --- a/web/app/sketcher/shapes/param.js +++ b/web/app/sketcher/shapes/param.js @@ -22,4 +22,8 @@ export class Param { return this.debugSymbol + this.id; } + visitParams(callback) { + callback(this); + } + } \ No newline at end of file diff --git a/web/app/sketcher/tools/ellipse.js b/web/app/sketcher/tools/ellipse.js index ce77701e..9133e90d 100644 --- a/web/app/sketcher/tools/ellipse.js +++ b/web/app/sketcher/tools/ellipse.js @@ -111,7 +111,7 @@ export class EllipseTool extends Tool { } solveRequest(rough) { - this.solver = this.viewer.parametricManager.prepare([this.ellipse.r]); - this.solver.solve(rough, 1); + this.viewer.parametricManager.prepare([this.ellipse.r]); + this.viewer.parametricManager.solve(rough); } } \ No newline at end of file