diff options
author | Pushkar Joshi | 2012-06-06 07:54:11 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-06-06 07:54:11 -0700 |
commit | cfa1402ac2ce831a83a9d4263d06c452c157a414 (patch) | |
tree | adb8f1f1ad1c4dd1e7e9eee1bd206f1ec338d20c /js/helper-classes/3D | |
parent | 8606ee7ec851cb0a971e7556eba5d9386f1b3639 (diff) | |
parent | 5ba54dc275b07e7b2d0ed14751761d1e663d3d14 (diff) | |
download | ninja-cfa1402ac2ce831a83a9d4263d06c452c157a414.tar.gz |
Merge branch 'pentool' into brushtool
Diffstat (limited to 'js/helper-classes/3D')
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 23 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 13 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 53 |
3 files changed, 43 insertions, 46 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 871b832d..eef28dce 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]]; |
@@ -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]); |
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.docu |