aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-06-04 11:03:11 -0700
committerJose Antonio Marquez2012-06-04 11:03:11 -0700
commitb6c6c194d4768cf03adee55e8ebe53428cbea2a1 (patch)
treeaaeb5301d1361a1d3a681ebd5c01dd618a712c2e /js/helper-classes
parentf02b6c98b193cc4cb7755a098b548efddf15c1bb (diff)
parentc1ec69879028220b0c3f11ad6e24035bf527802c (diff)
downloadninja-b6c6c194d4768cf03adee55e8ebe53428cbea2a1.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into Components
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js21
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js13
-rwxr-xr-xjs/helper-classes/3D/view-utils.js53
3 files changed, 42 insertions, 45 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index 871b832d..a793b643 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]];
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 069c6022..e3756f32 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; }},
@@ -2124,7 +2125,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
2124 if (hitRec) 2125 if (hitRec)
2125 { 2126 {
2126 var saveContext = drawUtils.getDrawingSurfaceElement(); 2127 var saveContext = drawUtils.getDrawingSurfaceElement();
2127 drawUtils.setDrawingSurfaceElement(this.drawingCanvas); 2128 drawUtils.setDrawingSurfaceElement(this.application.ninja.stage.drawingCanvas);
2128 var context = drawUtils.getDrawingContext(); 2129 var context = drawUtils.getDrawingContext();
2129 if (context) 2130 if (context)
2130 { 2131 {
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index a3d09404..5a128408 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -24,6 +24,9 @@ exports.ViewUtils = Montage.create(Component, {
24 // keep a stack of viewport objects 24 // keep a stack of viewport objects
25 _viewportObjStack: { value: []}, 25 _viewportObjStack: { value: []},
26 26
27 _rootElement: { value: null},
28 _stageElement: { value: null},
29
27 /////////////////////////////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////
28 // Property accessors 31 // Property accessors
29 /////////////////////////////////////////////////////////////////////// 32 ///////////////////////////////////////////////////////////////////////
@@ -36,6 +39,13 @@ exports.ViewUtils = Montage.create(Component, {
36 }, 39 },
37 getViewportObj: { value: function() { return this.m_viewportObj; } }, 40 getViewportObj: { value: function() { return this.m_viewportObj; } },
38 41
42 setRootElement: { value: function( elt ) { this._rootElement = elt; } },
43 getRootElement: { value: function () { return this._rootElement; } },
44
45 setStageElement: { value: function( elt ) { this._stageElement = elt; } },
46 getStageElement: { value: function () { return this._stageElement; } },
47
48
39 getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, 49 getPerspectiveDistance: { value: function () { return this._perspectiveDist; } },
40 50
41 /////////////////////////////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////
@@ -195,7 +205,12 @@ exports.ViewUtils = Montage.create(Component, {
195 205
196 getPerspectiveDistFromElement: { 206 getPerspectiveDistFromElement: {
197 value: function( elt ) { 207 value: function( elt ) {
198 return ElementsMediator.getPerspectiveDist(elt); 208 var pDist = ElementsMediator.getPerspectiveDist(elt);
209 if(pDist === "none") {
210 return null;
211 } else {
212 return pDist;
213 }
199 } 214 }
200 }, 215 },
201 216
@@ -280,7 +295,7 @@ exports.ViewUtils = Montage.create(Component, {
280 // into stage world space. 295 // into stage world space.
281 postViewToStageWorld: { 296 postViewToStageWorld: {
282 value: function( localPt, elt ) { 297 value: function( localPt, elt ) {
283 if ((elt == null) || (elt === this.application.ninja.currentDocument.model.documentRoot)) return localPt; 298 if ((elt == null) || (elt === this._stageElement)) return localPt;
284 299
285 // get the 3D transformation and 2D offset from the element 300 // get the 3D transformation and 2D offset from the element
286 var pt = localPt.slice(0); 301 var pt = localPt.slice(0);
@@ -307,7 +322,7 @@ exports.ViewUtils = Montage.create(Component, {
307 this.popViewportObj(); 322 this.popViewportObj();
308 323
309 // check if we are done 324 // check if we are done
310 if (parent === this.application.ninja.currentDocument.model.documentRoot) break; 325 if (parent === this._stageElement) break;
311 326
312 if (this.elementHas3D( parent )) 327 if (this.elementHas3D( parent ))
313 { 328 {
@@ -339,10 +354,10 @@ exports.ViewUtils = Montage.create(Component, {
339// if (child === this.application.ninja.currentDocument.model.documentRoot) break; 354// if (child === this.application.ninja.currentDocument.model.documentRoot) break;
340// child = child.offsetParent; 355// child = child.offsetParent;
341 356
342 if (child === this.application.ninja.currentDocument.model.documentRoot) break; 357 if (child === this._stageElement)