From 4abc8ae1d75e64f5b032b6f22f5b44902c2dc7f0 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Tue, 10 Feb 2015 00:36:27 -0800 Subject: [PATCH] highlight constraints --- web/app/parametric.js | 45 +++++++++++++++++++++++++++++++++++++++++++ web/sketcher.html | 19 +----------------- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/web/app/parametric.js b/web/app/parametric.js index ecd8ce5f..0b293a2d 100644 --- a/web/app/parametric.js +++ b/web/app/parametric.js @@ -477,6 +477,10 @@ TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.Coincident.prototype.NAME] = f return new TCAD.TWO.Constraints.Coincident(refs(data[0]), refs(data[1])); }; +TCAD.TWO.Constraints.Coincident.prototype.getObjects = function() { + return [this.a, this.b]; +}; + // ------------------------------------------------------------------------------------------------------------------ // TCAD.TWO.Constraints.Lock = function(p, c) { @@ -501,6 +505,11 @@ TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.Lock.prototype.NAME] = functio return new TCAD.TWO.Constraints.Lock(refs(data[0]), data[1]); }; + +TCAD.TWO.Constraints.Lock.prototype.getObjects = function() { + return [this.p]; +}; + // ------------------------------------------------------------------------------------------------------------------ // TCAD.TWO.Constraints.Parallel = function(l1, l2) { @@ -525,6 +534,10 @@ TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.Parallel.prototype.NAME] = fun return new TCAD.TWO.Constraints.Parallel(refs(data[0]), refs(data[1])); }; +TCAD.TWO.Constraints.Parallel.prototype.getObjects = function() { + return [this.l1, this.l2]; +}; + // ------------------------------------------------------------------------------------------------------------------ // TCAD.TWO.Constraints.Perpendicular = function(l1, l2) { @@ -549,6 +562,10 @@ TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.Perpendicular.prototype.NAME] return new TCAD.TWO.Constraints.Perpendicular(refs(data[0]), refs(data[1])); }; +TCAD.TWO.Constraints.Perpendicular.prototype.getObjects = function() { + return [this.l1, this.l2]; +}; + // ------------------------------------------------------------------------------------------------------------------ // TCAD.TWO.Constraints.P2LDistance = function(p, l, d) { @@ -574,6 +591,10 @@ TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.P2LDistance.prototype.NAME] = return new TCAD.TWO.Constraints.P2LDistance(refs(data[0]), refs(data[1]), data[2]); }; +TCAD.TWO.Constraints.P2LDistance.prototype.getObjects = function() { + return [this.p, this.l]; +}; + // ------------------------------------------------------------------------------------------------------------------ // TCAD.TWO.Constraints.P2LDistanceV = function(p, l, d) { @@ -628,6 +649,10 @@ TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.P2PDistance.prototype.NAME] = return new TCAD.TWO.Constraints.P2PDistance(refs(data[0]), refs(data[1]), data[2]); }; +TCAD.TWO.Constraints.P2PDistance.prototype.getObjects = function() { + return [this.p1, this.p2]; +}; + // ------------------------------------------------------------------------------------------------------------------ // TCAD.TWO.Constraints.P2PDistanceV = function(p1, p2, d) { @@ -678,6 +703,10 @@ TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.Radius.prototype.NAME] = funct return new TCAD.TWO.Constraints.Radius(refs(data[0]), data[1]); }; +TCAD.TWO.Constraints.Radius.prototype.getObjects = function() { + return [this.arc]; +}; + // ------------------------------------------------------------------------------------------------------------------ // TCAD.TWO.Constraints.RR = function(arc1, arc2) { @@ -699,6 +728,10 @@ TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.RR.prototype.NAME] = function( return new TCAD.TWO.Constraints.RR(refs(data[0]), refs(data[1])); }; +TCAD.TWO.Constraints.RR.prototype.getObjects = function() { + return [this.arc1, this.arc2]; +}; + // ------------------------------------------------------------------------------------------------------------------ // TCAD.TWO.Constraints.Vertical = function(line) { @@ -719,6 +752,10 @@ TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.Vertical.prototype.NAME] = fun return new TCAD.TWO.Constraints.Vertical(refs(data[0])); }; +TCAD.TWO.Constraints.Vertical.prototype.getObjects = function() { + return [this.line]; +}; + // ------------------------------------------------------------------------------------------------------------------ // TCAD.TWO.Constraints.Horizontal = function(line) { @@ -739,6 +776,10 @@ TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.Horizontal.prototype.NAME] = f return new TCAD.TWO.Constraints.Horizontal(refs(data[0])); }; +TCAD.TWO.Constraints.Horizontal.prototype.getObjects = function() { + return [this.line]; +}; + // ------------------------------------------------------------------------------------------------------------------ // TCAD.TWO.Constraints.Tangent = function(arc, line) { @@ -764,4 +805,8 @@ TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.Tangent.prototype.NAME] = func return new TCAD.TWO.Constraints.Tangent(refs(data[0]), refs(data[1])); }; +TCAD.TWO.Constraints.Tangent.prototype.getObjects = function() { + return [this.arc, this.line]; +}; + // ------------------------------------------------------------------------------------------------------------------ // diff --git a/web/sketcher.html b/web/sketcher.html index 2ac8f978..791aa5a4 100644 --- a/web/sketcher.html +++ b/web/sketcher.html @@ -244,24 +244,7 @@ }, hover : function(item) { - var sdataArr = item.constr.getSolveData(); - var visited = {}; - var toSelect = []; - - function collect(obj) { - if (obj !== undefined && visited[obj.id] === undefined) { - toSelect.push(obj); - visited[obj.id] = obj; - collect(obj.parent); - } - } - for (var i = 0; i < sdataArr.length; i++) { - var params = sdataArr[i][1]; - for (var j = 0; j < params.length; j++) { - collect(params[j].obj); - } - } - app.viewer.select(toSelect, true); + app.viewer.select(item.constr.getObjects(), true); app.viewer.refresh(); }