fix accept/visitor for the SketchObjects

This commit is contained in:
Val Erastov 2014-11-03 23:44:46 -08:00
parent 79ad72a620
commit 8b55612fae
2 changed files with 11 additions and 7 deletions

View file

@ -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() {

View file

@ -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);
}