aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes
diff options
context:
space:
mode:
authorKruti Shah2012-06-12 13:09:11 -0700
committerKruti Shah2012-06-12 13:09:11 -0700
commitd648c842905c7c53e0f89b943982493d2b79f56e (patch)
treeeb5585f92061975215f6d19305a8d1b76262e2fc /js/helper-classes
parentbedb38e14887b29eae3cdf1c8d435259c920257c (diff)
parentcf3b96822665751dae7a64644db3cb3960733c3d (diff)
downloadninja-d648c842905c7c53e0f89b943982493d2b79f56e.tar.gz
Merge branch 'refs/heads/TimelineUberjd' into TimelineUber
Conflicts: js/controllers/elements/element-controller.js js/document/_toDelete/html-document.js js/panels/Timeline/Layer.reel/Layer.js Signed-off-by: Kruti Shah <kruti.shah@motorola.com>
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js27
-rwxr-xr-xjs/helper-classes/3D/math-utils.js11
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js27
-rwxr-xr-xjs/helper-classes/3D/view-utils.js53
4 files changed, 53 insertions, 65 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index 871b832d..bef1e435 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -112,7 +112,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
112 this.eventManager.addEventListener("elementsRemoved", this, false); 112 this.eventManager.addEventListener("elementsRemoved", this, false);
113 this.eventManager.addEventListener("elementChange", this, false); 113 this.eventManager.addEventListener("elementChange", this, false);
114 this.eventManager.addEventListener("elementChanging", this, false); 114 this.eventManager.addEventListener("elementChanging", this, false);
115 this.eventManager.addEventListener("closeDocument", this, false);
116 this.eventManager.addEventListener("elementReplaced", this, false); 115 this.eventManager.addEventListener("elementReplaced", this, false);
117 } 116 }
118 }, 117 },
@@ -126,7 +125,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
126 //initialize with current document 125 //initialize with current document
127 this._eltArray = []; 126 this._eltArray = [];
128 this._planesArray = []; 127 this._planesArray = [];
129 this.setDrawingSurfaceElement(stage.canvas); 128 this.setDrawingSurfaceElement(stage.gridCanvas);
130 this.setSourceSpaceElement( this.application.ninja.currentDocument.model.documentRoot); 129 this.setSourceSpaceElement( this.application.ninja.currentDocument.model.documentRoot);
131 this.setWorkingPlane( [0,0,1,0] ); 130 this.setWorkingPlane( [0,0,1,0] );
132 131
@@ -164,15 +163,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
164 } 163 }
165 }, 164 },
166 165
167 handleCloseDocument:{
168 value: function() {
169 if(this.application.ninja.documentController._documents.length === 0){
170 this._eltArray.length = 0;
171 this._planesArray.length = 0;
172 }
173 }
174 },
175
176 handleElementAdded: { 166 handleElementAdded: {
177 value: function(event) { 167 value: function(event) {
178 var elements = event.detail; 168 var elements = event.detail;
@@ -276,8 +266,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
276 stage = this.application.ninja.stage, 266 stage = this.application.ninja.stage,
277 minLeft = stage.userPaddingLeft, 267 minLeft = stage.userPaddingLeft,
278 minTop = stage.userPaddingTop, 268 minTop = stage.userPaddingTop,
279 docLeft = stage.documentOffsetLeft, 269 docLeft = stage.userContentLeft,
280 docTop = stage.documentOffsetTop, 270 docTop = stage.userContentTop,
281 l, 271 l,
282 t, 272 t,
283 plane, 273 plane,
@@ -307,7 +297,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
307 } 297 }
308 298
309 if(!changed) { 299 if(!changed) {
310 stage.layout.draw();
311 this.drawWorkingPlane(); 300 this.drawWorkingPlane();
312 this.draw3DCompass(); 301 this.draw3DCompass();
313 } 302 }
@@ -628,11 +617,11 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
628 { 617 {
629 value: function () 618 value: function ()
630 { 619 {
620 this.application.ninja.stage.clearGridCanvas();
631 if (!this.isDrawingGrid()) return; 621 if (!this.isDrawingGrid()) return;
632 622
633 var saveContext = this.getDrawingSurfaceElement(); 623 var saveContext = this.getDrawingSurfaceElement();
634 //this.setDrawingSurfaceElement(window.stageManager.layoutCanvas); 624 this.setDrawingSurfaceElement(this.application.ninja.stage.gridCanvas);
635 this.setDrawingSurfaceElement(this.application.ninja.stage.layoutCanvas);
636 625
637 // 3 coordinate axes for the plane 626 // 3 coordinate axes for the plane
638 var zAxis = [this._workingPlane[0], this._workingPlane[1], this._workingPlane[2]]; 627 var zAxis = [this._workingPlane[0], this._workingPlane[1], this._workingPlane[2]];
@@ -1217,7 +1206,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
1217 // set the element to be the viewport object - temporarily 1206 // set the element to be the viewport object - temporarily
1218 var tmpCanvas = this.application.ninja.stage.canvas; 1207 var tmpCanvas = this.application.ninja.stage.canvas;
1219 var tmpStage = this.application.ninja.currentDocument.model.documentRoot; 1208 var tmpStage = this.application.ninja.currentDocument.model.documentRoot;
1220 this.viewUtils.pushViewportObj( tmpCanvas ); 1209// this.viewUtils.pushViewportObj( tmpCanvas );
1221 1210
1222 // save the source space object and set to the target object 1211 // save the source space object and set to the target object
1223 var saveSource = this._sourceSpaceElt; 1212 var saveSource = this._sourceSpaceElt;
@@ -1228,7 +1217,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
1228 var saveLineWidth = this._lineWidth; 1217 var saveLineWidth = this._lineWidth;
1229 1218
1230 var origLeft = 60; 1219 var origLeft = 60;
1231 var origTop = this.snapManager.getStageHeight() - 60; 1220 var origTop = tmpCanvas.height - 60;
1232 1221
1233 var mat = this.viewUtils.getMatrixFromElement( this._sourceSpaceElt ); 1222 var mat = this.viewUtils.getMatrixFromElement( this._sourceSpaceElt );
1234 var tMat = Matrix.Translation([origLeft,origTop,0]); 1223 var tMat = Matrix.Translation([origLeft,origTop,0]);
@@ -1290,7 +1279,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
1290 this.drawArrowHead(rO, zO); 1279 this.drawArrowHead(rO, zO);
1291 1280
1292 // restore the state 1281 // restore the state
1293 this.viewUtils.popViewportObj(); 1282// this.viewUtils.popViewportObj();
1294 this._drawingContext.restore(); 1283 this._drawingContext.restore();
1295 this.setDrawingSurfaceElement(saveContext); 1284 this.setDrawingSurfaceElement(saveContext);
1296 this._lineColor = saveColor; 1285 this._lineColor = saveColor;
diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js
index 2f0283a9..35ee8112 100755
--- a/js/helper-classes/3D/math-utils.js
+++ b/js/helper-classes/3D/math-utils.js
@@ -928,17 +928,18 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, {
928 return 0; 928 return 0;
929 } 929 }
930 //TODO testing...remove this block 930 //TODO testing...remove this block
931 console.log("getAxisAngleBetween3DVectors Angle: "+angle);
932 if (isNaN(angle)){ 931 if (isNaN(angle)){
933 console.log("getAxisAngleBetween3DVectors Angle is NaN"); 932 console.log("Warning! getAxisAngleBetween3DVectors Angle is NaN");
934 } 933 }
935 //TODO end testing block 934 //TODO end testing block
936 //optionally, if axis is provided, create the axis of rotation as well 935 //optionally, if axis is provided, create the axis of rotation as well
937 var rotAxis = VecUtils.vecCross(3, v1n, v2n); 936 var rotAxis = VecUtils.vecCross(3, v1n, v2n);
938 rotAxis = VecUtils.vecNormalize(3, rotAxis, 1); 937 rotAxis = VecUtils.vecNormalize(3, rotAxis, 1);
939 axis[0] = rotAxis[0]; 938 if (axis){
940 axis[1] = rotAxis[1]; 939 axis[0] = rotAxis[0];
941 axis[2] = rotAxis[2]; 940 axis[1] = rotAxis[1];
941 axis[2] = rotAxis[2];
942 }
942 return angle; 943 return angle;
943 } 944 }
944 }, 945 },
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 069c6022..a8b6e739 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -21,8 +21,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
21 /////////////////////////////////////////////////////////////////////// 21 ///////////////////////////////////////////////////////////////////////
22 // Instance variables 22 // Instance variables
23 /////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////
24 drawingCanvas: { value: null, writable: true}, 24
25 25 currentStage: { value: null },
26
26 // we keep a stack of working planes to facilitate working on other planes temporarily 27 // we keep a stack of working planes to facilitate working on other planes temporarily
27 _workingPlaneStack : { value: [], writable: true }, 28 _workingPlaneStack : { value: [], writable: true },
28 29
@@ -83,14 +84,14 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
83 popWorkingPlane : { value: function () { workingPlane = this._workingPlaneStack.pop(); return workingPlane; }}, 84 popWorkingPlane : { value: function () { workingPlane = this._workingPlaneStack.pop(); return workingPlane; }},
84 85
85 getStageWidth : { value: function () { 86 getStageWidth : { value: function () {
86 return parseInt(this.application.ninja.currentDocument.model.documentRoot.offsetWidth); 87 return parseInt(this.currentStage.offsetWidth);
87 }}, 88 }},
88 89
89 getStageHeight : { value: function () { 90 getStageHeight : { value: function () {
90 return parseInt(this.application.ninja.currentDocument.model.documentRoot.offsetHeight); 91 return parseInt(this.currentStage.offsetHeight);
91 }}, 92 }},
92 93
93 getStage : { value: function() { return this.application.ninja.currentDocument.model.documentRoot; }}, 94 getStage : { value: function() { return this.currentStage; }},
94 95
95 getGridVertexHitRad : { value: function() { return this._gridVertexHitRad; }}, 96 getGridVertexHitRad : { value: function() { return this._gridVertexHitRad; }},
96 getGridEdgeHitRad : { value: function() { return this._gridEdgeHitRad; }}, 97 getGridEdgeHitRad : { value: function() { return this._gridEdgeHitRad; }},
@@ -480,10 +481,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
480 { 481 {
481 var snapRec = this._elementCache[i]; 482 var snapRec = this._elementCache[i];
482 var elt = snapRec.getElement(); 483 var elt = snapRec.getElement();
483 if (elt.elementModel) 484 elt.elementModel.isIn2DSnapCache = false;
484 elt.elementModel.isIn2DSnapCache = false; 485
485 else
486 console.log( "element in the 2D cache does not have an elementModel" );
487 } 486 }
488 487
489 this._elementCache = null; 488 this._elementCache = null;
@@ -540,10 +539,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
540 snapRec.init( elt ); 539 snapRec.init( elt );
541 this._elementCache.push( snapRec ); 540 this._elementCache.push( snapRec );