From bbdd0a00dc16fdbf5c86bffdc09a13ee06a49d58 Mon Sep 17 00:00:00 2001 From: "Val Erastov (xibyte)" Date: Tue, 10 Mar 2020 18:26:26 -0700 Subject: [PATCH] fix bezier curve --- web/app/sketcher/shapes/bezier-curve.js | 7 ++++--- web/app/sketcher/tools/bezier-curve.js | 9 +++++++-- web/app/sketcher/tools/rectangle.js | 1 - 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/web/app/sketcher/shapes/bezier-curve.js b/web/app/sketcher/shapes/bezier-curve.js index 6134ffc5..7f4514e7 100644 --- a/web/app/sketcher/shapes/bezier-curve.js +++ b/web/app/sketcher/shapes/bezier-curve.js @@ -1,4 +1,3 @@ -import {Ref} from './ref' import {SketchObject} from './sketch-object' import {Segment} from './segment' import {LUT} from '../../math/bezier-cubic' @@ -6,8 +5,6 @@ import {ConvexHull2D} from '../../math/convex-hull' import * as draw_utils from '../shapes/draw-utils' import * as math from '../../math/math'; -import {Arc} from "./arc"; -import {EndPoint} from "./point"; export class BezierCurve extends SketchObject { @@ -26,6 +23,10 @@ export class BezierCurve extends SketchObject { } } + stabilize(viewer) { + this.children.forEach(c => c.stabilize(viewer)); + } + visitParams(callback) { this.a.visitParams(callback); this.b.visitParams(callback); diff --git a/web/app/sketcher/tools/bezier-curve.js b/web/app/sketcher/tools/bezier-curve.js index e1915732..1d67899b 100644 --- a/web/app/sketcher/tools/bezier-curve.js +++ b/web/app/sketcher/tools/bezier-curve.js @@ -4,6 +4,7 @@ import {BezierCurve} from '../shapes/bezier-curve' import {Constraints} from '../parametric' import Vector from 'math/vector'; import * as math from '../../math/math' +import {AlgNumConstraint, ConstraintDefinitions} from "../constr/ANConstraints"; export class BezierCurveTool extends Tool { @@ -35,12 +36,16 @@ export class BezierCurveTool extends Tool { this.viewer.activeLayer.add(this.curve); this.viewer.refresh(); } else { + this.viewer.parametricManager.startTransaction(); this.snapIfNeed(this.curve.b); if (this.otherCurveEndPoint != null) { - this.viewer.parametricManager.add(new Constraints.Parallel(this.otherCurveEndPoint.parent, this.curve.a.parent)); + const smoothingConstr = new AlgNumConstraint(ConstraintDefinitions.Parallel, [this.otherCurveEndPoint.parent, this.curve.a.parent]); + smoothingConstr.initConstants(); + this.viewer.parametricManager.add(smoothingConstr); } + this.curve.stabilize(this.viewer); + this.viewer.parametricManager.finishTransaction(); this.viewer.toolManager.releaseControl(); - this.viewer.refresh(); } } diff --git a/web/app/sketcher/tools/rectangle.js b/web/app/sketcher/tools/rectangle.js index 09c222ee..aecf9037 100644 --- a/web/app/sketcher/tools/rectangle.js +++ b/web/app/sketcher/tools/rectangle.js @@ -1,7 +1,6 @@ import {Tool} from './tool' import {EndPoint} from '../shapes/point' import {Segment} from '../shapes/segment' -import {Constraints} from '../parametric' import {AlgNumConstraint, ConstraintDefinitions} from "../constr/ANConstraints";