From 8b55612fae39da92091e126181784d7cf85f83f2 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Mon, 3 Nov 2014 23:44:46 -0800 Subject: [PATCH] fix accept/visitor for the SketchObjects --- web/app/canvas.js | 16 ++++++++++------ web/app/fetchers.js | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/web/app/canvas.js b/web/app/canvas.js index bcd143b0..5af5018e 100644 --- a/web/app/canvas.js +++ b/web/app/canvas.js @@ -122,12 +122,12 @@ TCAD.TWO.Viewer.prototype.search = function(x, y, buffer, deep, onlyPoints) { var objs = this.layers[i].objects; for (var j = 0; j < objs.length; j++) { var l = unreachable + 1; - var hit = !objs[j].visit(true, function(o) { + var hit = !objs[j].acceptV(true, function(o) { if (onlyPoints && o._class !== 'TCAD.TWO.EndPoint') { return false; } l = o.normalDistance(aim); - if (l > 0 && l <= buffer) { + if (l >= 0 && l <= buffer) { pickResult.push(o); return false; } @@ -340,15 +340,19 @@ TCAD.TWO.SketchObject = function() { this.layer = null; }; -TCAD.TWO.SketchObject.prototype.visit = function(onlyVisible, h) { - if (!this.visible) return true; +TCAD.TWO.SketchObject.prototype.accept = function(visitor) { + return this.acceptV(false, visitor); +}; + +TCAD.TWO.SketchObject.prototype.acceptV = function(onlyVisible, visitor) { + if (!this.visible) return false; for (var i = 0; i < this.children.length; i++) { var child = this.children[i]; - if (!child.visit(onlyVisible, h)) { + if (!child.acceptV(onlyVisible, visitor)) { return false; } } - return h(this); + return visitor(this); }; TCAD.TWO.SketchObject.prototype.validate = function() { diff --git a/web/app/fetchers.js b/web/app/fetchers.js index 1b307287..52998859 100644 --- a/web/app/fetchers.js +++ b/web/app/fetchers.js @@ -17,7 +17,7 @@ TCAD.TWO.ParametricManager.prototype._fetchTwoPoints = function(objs) { TCAD.TWO.ParametricManager.prototype._fetchPoints = function(objs) { var points = []; for (var i = 0; i < objs.length; ++i) { - objs[i].visit(false, function(o) { + objs[i].accept(function(o) { if (o._class === 'TCAD.TWO.EndPoint') { points.push(o); }