aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes
diff options
context:
space:
mode:
authorJonathan Duran2012-02-29 13:23:30 -0800
committerJonathan Duran2012-02-29 13:23:30 -0800
commit59757653a5c49ac0db45c5d4f93e3493c1f08e44 (patch)
tree8193046c6b1dddaedfd59d954e862a734bfb0a93 /js/helper-classes
parent681d55a9cdc4e790d9e1742dc13ce62e42b6a516 (diff)
downloadninja-59757653a5c49ac0db45c5d4f93e3493c1f08e44.tar.gz
Squashed commit of the following:
commit 2b9f63089534356607ad7e0ddde6f22e42d04f80 Merge: 98d491f a89e30a Author: Valerio Virgillito <valerio@motorola.com> Date: Wed Feb 29 12:12:11 2012 -0800 Merge pull request #88 from mqg734/ToolFixes Fix for performance issue when moving shapes. commit 98d491f7e57ff5a9b091e332d7d1e81061e39efa Merge: 052d980 d417b33 Author: Valerio Virgillito <valerio@motorola.com> Date: Wed Feb 29 12:10:57 2012 -0800 Merge branch 'SnapManagerFixes' of https://github.com/mqg734/ninja-internal into integration-candidate commit 052d9805a6f0a3a90d6849eb94eabffb7ec26962 Merge: 3d233f2 2f3e4d1 Author: Valerio Virgillito <valerio@motorola.com> Date: Wed Feb 29 12:10:03 2012 -0800 Merge branch 'integration-candidate' of github.com:Motorola-Mobility/ninja-internal into integration-candidate commit 3d233f25cff057fff5c5a75e4c4b40e88c22a8f5 Merge: 3dbe798 209e078 Author: Valerio Virgillito <valerio@motorola.com> Date: Wed Feb 29 12:09:43 2012 -0800 Merge branch 'NiveshColor' of https://github.com/mqg734/ninja-internal into integration-candidate commit 2f3e4d12aa15077d3cc9794862156e57b7815e68 Merge: 850f3a1 0996a51 Author: Valerio Virgillito <valerio@motorola.com> Date: Wed Feb 29 12:06:21 2012 -0800 Merge pull request #87 from joseeight/FileIO-Build-Candidate Fixes to preview caching issues commit 850f3a1f7ab81ec80b6de1c49f2d2bbcbfe87c8e Merge: 1568367 5f777eb Author: Valerio Virgillito <valerio@motorola.com> Date: Wed Feb 29 12:05:48 2012 -0800 Merge pull request #86 from imix23ways/Timeline Timeline commit 1568367213e760463f3ee29a531aa345fda6bd6d Merge: 3dbe798 271a8f2 Author: Valerio Virgillito <valerio@motorola.com> Date: Wed Feb 29 12:03:23 2012 -0800 Merge pull request #85 from pushkarjoshi/brushtool Brushtool commit a89e30ab834a48be32b6122e0c8ac1e0c3ed43e8 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Wed Feb 29 11:58:28 2012 -0800 Fix for performance issue when moving shapes. We don't need to call render except if the geometry and materials change. This is more easy to see with shapes like the brush tool. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 271a8f2b29d87d12c81d03e3f1e2c05b816a138d Author: Pushkar Joshi <pushkar@motorola.com> Date: Wed Feb 29 11:50:41 2012 -0800 prevent extremely long path rendering (temporary fix) commit 0996a519afccbed526912807c70c20d598e9cae7 Merge: 98f1cfc 03d277d Author: Jose Antonio Marquez <kgq387@motorola.com> Date: Wed Feb 29 11:46:59 2012 -0800 Merge branch 'refs/heads/FileIO' into FileIO-Build-Candidate commit 03d277db80b6cea9a25320c0575ae2bf7a6d7e6e Author: Jose Antonio Marquez <kgq387@motorola.com> Date: Wed Feb 29 11:46:44 2012 -0800 Preview Fix Adding save all logic before preview, temporary fix. commit 46fb52be241dced940d46629c809a09c86ed4438 Author: Pushkar Joshi <pushkar@motorola.com> Date: Wed Feb 29 11:38:33 2012 -0800 changed the registration point of the brush tool icon and added a temporary check to prevent extremely long brush strokes commit 98f1cfc58f545702a18166ab216362d667c18915 Merge: da83f44 bb3e42b Author: Jose Antonio Marquez <kgq387@motorola.com> Date: Wed Feb 29 11:29:09 2012 -0800 Merge branch 'refs/heads/FileIO' into FileIO-Build-Candidate commit bb3e42b531848b400670df6caf0f3ce02adf1243 Author: Jose Antonio Marquez <kgq387@motorola.com> Date: Wed Feb 29 11:28:58 2012 -0800 Fix: Caching issue with chrome tab API Using window.open to test movie. commit f000a3cced9adbfff1d7aa641e6eb42ad6edf7e8 Author: Pushkar Joshi <pushkar@motorola.com> Date: Wed Feb 29 10:21:06 2012 -0800 change in comment only commit 795329d2225ff3b760f7f0ea3bb6b5e68f6c6b5b Author: Jose Antonio Marquez <kgq387@motorola.com> Date: Wed Feb 29 10:07:53 2012 -0800 Making class level url template variable Created a class level variable for the URL to be parsed out of the user files. commit f931c48a7d0bcf1222cf05787e3294839ed0b9fb Author: Pushkar Joshi <pushkar@motorola.com> Date: Wed Feb 29 09:47:41 2012 -0800 resample the brush stroke so we don't have gaps if the path is drawn rapidly, and, allow to change the stroke color, and, more efficient stroke rendering by drawing translated radial gradients (instead of creating new gradients for each stroke sample) commit d417b3315f1aa6dd52fea10cbf5f17a213ef8726 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Wed Feb 29 06:50:51 2012 -0800 SnapManager fixes for sag tags. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 209e0781e926212bbaaad9e8ca4b61a0c389b30f Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Tue Feb 28 17:19:42 2012 -0800 We need to remove color buttons from the color model when updating the PI for selection change. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit b43efdcbfa671a46d1edaeb1555f508fe2ad0338 Merge: 16d6a90 f2ab699 Author: Pushkar Joshi <pushkar@motorola.com> Date: Tue Feb 28 14:55:08 2012 -0800 Merge branch 'pentool' into brushtool commit 16d6a90579cdafede931a9c818689fad2e622d8b Merge: 03ca7a5 63307c9 Author: Pushkar Joshi <pushkar@motorola.com> Date: Tue Feb 28 14:19:25 2012 -0800 Merge branch 'pentool' into brushtool commit 03ca7a5ed13c25faaa9100bb666e062fd15335e6 Merge: fcb12cc 053fc63 Author: Pushkar Joshi <pushkar@motorola.com> Date: Fri Feb 24 12:08:49 2012 -0800 Merge branch 'pentool' into brushtool Conflicts: imports/codemirror/mode/scheme/scheme.js js/tools/BrushTool.js commit fcb12cc09eb3cd3b42bd215877ba18f449275b75 Author: Pushkar Joshi <pushkar@motorola.com> Date: Fri Feb 10 14:16:56 2012 -0800 render the brush stroke as a sequence of rectangles, with each rectangle having its own linear gradient commit 6bb00e69713bd7131b2bc0a15e4e0cb6071d616c Merge: 5f42bd1 666ae3e Author: Pushkar Joshi <pushkar@motorola.com> Date: Thu Feb 9 13:42:59 2012 -0800 Merge branch 'master' into brushtool commit 5f42bd1f7723483d374cdd3fe51ef8298c86a1a2 Merge: abeb9f1 fba39db Author: Pushkar Joshi <pushkar@motorola.com> Date: Thu Feb 9 10:55:58 2012 -0800 Merge branch 'pentool' into brushtool commit abeb9f1e23679200bb2f4a3ccbcebfb37645975c Author: Pushkar Joshi <pushkar@motorola.com> Date: Thu Feb 9 10:45:50 2012 -0800 first phase of simple resampling to prevent tiny segments Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js6
-rwxr-xr-xjs/helper-classes/3D/view-utils.js3
-rwxr-xr-xjs/helper-classes/RDGE/GLBrushStroke.js175
3 files changed, 169 insertions, 15 deletions
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 94202dc5..372be345 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -597,7 +597,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
597 } 597 }
598 598
599 // TODO - Don't traverse components' children 599 // TODO - Don't traverse components' children
600 if(elt.elementModel && elt.elementModel.isComponent) 600// if(elt.elementModel && elt.elementModel.isComponent)
601 if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG"))))
601 { 602 {
602 return; 603 return;
603 } 604 }
@@ -1007,7 +1008,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1007 } 1008 }
1008 1009
1009 // TODO - Don't traverse components' children 1010 // TODO - Don't traverse components' children
1010 if(elt.elementModel && elt.elementModel.isComponent) 1011// if(elt.elementModel && elt.elementModel.isComponent)
1012 if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG"))))
1011 { 1013 {
1012 return; 1014 return;
1013 } 1015 }
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index bedda8bf..c1f59397 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -580,7 +580,8 @@ exports.ViewUtils = Montage.create(Component, {
580 if (elt.style.height) h = MathUtils.styleToNumber(elt.style.height); 580 if (elt.style.height) h = MathUtils.styleToNumber(elt.style.height);
581 } 581 }
582 582
583 if (elt instanceof SVGSVGElement) { 583// if (elt instanceof SVGSVGElement) {
584 if(elt.nodeName.toLowerCase() === "svg") {
584 if(w instanceof SVGAnimatedLength) 585 if(w instanceof SVGAnimatedLength)
585 w = w.animVal.value; 586 w = w.animVal.value;
586 if(h instanceof SVGAnimatedLength) 587 if(h instanceof SVGAnimatedLength)
diff --git a/js/helper-classes/RDGE/GLBrushStroke.js b/js/helper-classes/RDGE/GLBrushStroke.js
index fdf1595c..5d773c2d 100755
--- a/js/helper-classes/RDGE/GLBrushStroke.js
+++ b/js/helper-classes/RDGE/GLBrushStroke.js
@@ -34,6 +34,13 @@ function GLBrushStroke() {
34 this._strokeMaterial; 34 this._strokeMaterial;
35 this._strokeStyle = "Solid"; 35 this._strokeStyle = "Solid";
36 36
37 //the wetness of the brush (currently this is multiplied to the square of the stroke width, but todo should be changed to not depend on stroke width entirely
38 //smaller value means more samples for the path
39 this._WETNESS_FACTOR = 0.25;
40
41 //prevent extremely long paths that can take a long time to render
42 this._MAX_ALLOWED_SAMPLES = 500;
43
37 //drawing context 44 //drawing context
38 this._world = null; 45 this._world = null;
39 46
@@ -67,7 +74,25 @@ function GLBrushStroke() {
67 74
68 this.getNumPoints = function () { return this._Points.length; } 75 this.getNumPoints = function () { return this._Points.length; }
69 this.getPoint = function (index) { return this._Points[index]; } 76 this.getPoint = function (index) { return this._Points[index]; }
70 this.addPoint = function (anchorPt) { this._Points.push(anchorPt); this._dirty=true; } 77 this.addPoint = function (pt)
78 {
79 //add the point only if it is some epsilon away from the previous point
80 var numPoints = this._Points.length;
81 if (numPoints>0) {
82 var threshold = this._WETNESS_FACTOR*this._strokeWidth;
83 var prevPt = this._Points[numPoints-1];
84 var diffPt = [prevPt[0]-pt[0], prevPt[1]-pt[1]];
85 var diffPtMag = Math.sqrt(diffPt[0]*diffPt[0] + diffPt[1]*diffPt[1]);
86 if (diffPtMag>threshold){
87 this._Points.push(pt);
88 this._dirty=true;
89 }
90 }else{
91 this._Points.push(pt);
92 this._dirty=true;
93 }
94 }
95
71 this.insertPoint = function(pt, index){ this._Points.splice(index, 0, pt); this._dirty=true;} 96 this.insertPoint = function(pt, index){ this._Points.splice(index, 0, pt); this._dirty=true;}
72 this.isDirty = function(){return this._dirty;} 97 this.isDirty = function(){return this._dirty;}
73 this.makeDirty = function(){this._dirty=true;} 98 this.makeDirty = function(){this._dirty=true;}
@@ -111,10 +136,45 @@ function GLBrushStroke() {
111 136
112 this.computeMetaGeometry = function(){ 137 this.computeMetaGeometry = function(){
113 if (this._dirty){ 138 if (this._dirty){
139 var numPoints = this._Points.length;
140
141 //**** add samples to the path if needed...linear interpolation for now
142 if (numPoints>1) {
143 var threshold = this._WETNESS_FACTOR*this._strokeWidth;
144 var prevPt = this._Points[0];
145 var prevIndex = 0;
146 for (var i=1;i<numPoints;i++){
147 var pt = this._Points[i];
148 var diff = [pt[0]-prevPt[0], pt[1]-prevPt[1]];
149 var distance = Math.sqrt(diff[0]*diff[0]+diff[1]*diff[1]);
150 if (distance>threshold){
151 //insert points along the prev. to current point
152 var numNewPoints = Math.floor(distance/threshold);
153 for (var j=0;j<numNewPoints;j++){
154 var param = (j+1)/(numNewPoints+1);
155 var newpt = [prevPt[0]+ diff[0]*param, prevPt[1]+ diff[1]*param];
156 //insert new point before point i
157 this._Points.splice(i, 0, [newpt[0], newpt[1], 0]);
158 i++;
159 }
160 this._dirty=true;
161 }
162 prevPt=pt;
163 //update numPoints to match the new length
164 numPoints = this._Points.length;
165
166 //end this function if the numPoints has gone above the max. size specified
167 if (numPoints> this._MAX_ALLOWED_SAMPLES){
168 console.log("leaving the resampling because numPoints is greater than limit:"+this._MAX_ALLOWED_SAMPLES);
169 break;
170 }
171 }
172 }
173
114 // *** compute the bounding box ********* 174 // *** compute the bounding box *********
115 this._BBoxMin = [Infinity, Infinity, Infinity]; 175 this._BBoxMin = [Infinity, Infinity, Infinity];
116 this._BBoxMax = [-Infinity, -Infinity, -Infinity]; 176 this._BBoxMax = [-Infinity, -Infinity, -Infinity];
117 var numPoints = this._Points.length; 177 numPoints = this._Points.length;
118 if (numPoints === 0) { 178 if (numPoints === 0) {
119 this._BBoxMin = [0, 0, 0]; 179 this._BBoxMin = [0, 0, 0];
120 this._BBoxMax = [0, 0, 0]; 180 this._BBoxMax = [0, 0, 0];
@@ -167,7 +227,8 @@ function GLBrushStroke() {
167 var bboxWidth = bboxMax[0] - bboxMin[0]; 227 var bboxWidth = bboxMax[0] - bboxMin[0];
168 var bboxHeight = bboxMax[1] - bboxMin[1]; 228 var bboxHeight = bboxMax[1] - bboxMin[1];
169 ctx.clearRect(0, 0, bboxWidth, bboxHeight); 229 ctx.clearRect(0, 0, bboxWidth, bboxHeight);
170/* 230
231 /*
171 ctx.lineWidth = this._strokeWidth; 232 ctx.lineWidth = this._strokeWidth;
172 ctx.strokeStyle = "black"; 233 ctx.strokeStyle = "black";
173 if (this._strokeColor) 234 if (this._strokeColor)
@@ -185,30 +246,120 @@ function GLBrushStroke() {
185 ctx.lineTo(pt[0]-bboxMin[0], pt[1]-bboxMin[1]); 246 ctx.lineTo(pt[0]-bboxMin[0], pt[1]-bboxMin[1]);
186 } 247 }
187 ctx.stroke(); 248 ctx.stroke();
188 */ 249 */
250
251 /*
252 var isDebug = false;
253 var prevPt = this._Points[0];
254 var prevX = prevPt[0]-bboxMin[0];
255 var prevY = prevPt[1]-bboxMin[1];
256 prevPt = [prevX,prevY];
257 for (var i = 1; i < numPoints; i++) {
258 var pt = this._Points[i];
259 ctx.globalCompositeOperation = 'source-over';
260 var x = pt[0]-bboxMin[0];
261 var y = pt[1]-bboxMin[1];
262 pt = [x,y];
263
264 //vector from prev to current pt
265 var seg = VecUtils.vecSubtract(2, pt, prevPt);
266 var segDir = VecUtils.vecNormalize(2, seg, 1.0);
267
268 var segMidPt = VecUtils.vecInterpolate(2, pt, prevPt, 0.5);
269 var w2 = this._strokeWidth*0.5;
270 var segDirOrtho = [w2*segDir[1], -w2*segDir[0]];
271
272 //add half the strokewidth to the segMidPt
273 var lgStart = VecUtils.vecAdd(2, segMidPt, segDirOrtho);
274 var lgEnd = VecUtils.vecSubtract(2, segMidPt, segDirOrtho);
275
276 ctx.save();
277 ctx.beginPath();
278
279 if (isDebug) {
280 ctx.strokeStyle="black";
281 ctx.lineWidth = 1;
282