diff options
author | Armen Kesablyan | 2012-02-07 16:55:34 -0800 |
---|---|---|
committer | Armen Kesablyan | 2012-02-07 16:55:34 -0800 |
commit | 10f0ad4c15f090b2d0d50d11e4c7aaf291e9eb0e (patch) | |
tree | 12b31910a3c7c7fa2ee0b26d8aaa611710e139a5 /js/helper-classes/3D/draw-utils.js | |
parent | 7f8730c3add146f1ba107e6fc22d1f5a8348ed8b (diff) | |
parent | 668510892537eaaeb2e11520831d87b44b2489b7 (diff) | |
download | ninja-10f0ad4c15f090b2d0d50d11e4c7aaf291e9eb0e.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into text-tool
Conflicts:
_scss/compass_app_log.txt
css/ninja.css
Diffstat (limited to 'js/helper-classes/3D/draw-utils.js')
-rw-r--r-- | js/helper-classes/3D/draw-utils.js | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 3fd6e8fc..c07391db 100644 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -71,6 +71,9 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
71 | 71 | ||
72 | _selectionCtr : {value: null, writable: true }, | 72 | _selectionCtr : {value: null, writable: true }, |
73 | 73 | ||
74 | // Properties that require element planes to be updated | ||
75 | _updatePlaneProps : {value: ["matrix", "left", "top", "width", "height"], writable: false }, | ||
76 | |||
74 | /////////////////////////////////////////////////////////////////////// | 77 | /////////////////////////////////////////////////////////////////////// |
75 | // Property accessors | 78 | // Property accessors |
76 | /////////////////////////////////////////////////////////////////////// | 79 | /////////////////////////////////////////////////////////////////////// |
@@ -107,6 +110,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
107 | 110 | ||
108 | this.eventManager.addEventListener("elementAdded", this, false); | 111 | this.eventManager.addEventListener("elementAdded", this, false); |
109 | this.eventManager.addEventListener("elementDeleted", this, false); | 112 | this.eventManager.addEventListener("elementDeleted", this, false); |
113 | this.eventManager.addEventListener("deleteSelection", this, false); | ||
114 | this.eventManager.addEventListener("elementChange", this, false); | ||
110 | } | 115 | } |
111 | }, | 116 | }, |
112 | 117 | ||
@@ -123,6 +128,65 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
123 | } | 128 | } |
124 | }, | 129 | }, |
125 | 130 | ||
131 | handleDeleteSelection: { | ||
132 | value: function(event) { | ||
133 | this.drawWorkingPlane(); | ||
134 | } | ||
135 | }, | ||
136 | |||
137 | _shouldUpdatePlanes: { | ||
138 | value: function(props) { | ||
139 | if(!props) | ||
140 | { | ||
141 | return false; | ||
142 | } | ||
143 | else if (typeof props === "string") | ||
144 | { | ||
145 | return (this._updatePlaneProps.indexOf(props) !== -1); | ||
146 | } | ||
147 | |||
148 | for (var p in props) | ||
149 | { | ||
150 | if(this._updatePlaneProps.indexOf(p) !== -1) | ||
151 | { | ||
152 | return true; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | return false; | ||
157 | } | ||
158 | }, | ||
159 | |||
160 | // TODO - Check why handleElementChange is being fired before handleAddElement | ||
161 | handleElementChange: { | ||
162 | value: function(event) { | ||
163 | if(!event.detail || !event.detail.data) | ||
164 | { | ||
165 | return; | ||
166 | } | ||
167 | var els = event.detail.data.els; | ||
168 | if(els && this._shouldUpdatePlanes(event.detail.data.prop)) | ||
169 | { | ||
170 | var len = els.length, | ||
171 | i = 0, | ||
172 | item, | ||
173 | el; | ||
174 | |||
175 | for(i=0; i < len; i++) { | ||
176 | item = els[i]; | ||
177 | el = item._element || item; | ||
178 | if(el.elementModel.props3D.elementPlane) | ||
179 | { | ||
180 | el.elementModel.props3D.elementPlane.init(); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | this.application.ninja.stage.layout.draw(); | ||
185 | this.drawWorkingPlane(); | ||
186 | this.draw3DCompass(); | ||
187 | } | ||
188 | } | ||
189 | }, | ||
126 | 190 | ||
127 | /////////////////////////////////////////////////////////////////////// | 191 | /////////////////////////////////////////////////////////////////////// |
128 | // Methods | 192 | // Methods |
@@ -150,6 +214,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
150 | plane.setElement( elt ); | 214 | plane.setElement( elt ); |
151 | plane.init(); | 215 | plane.init(); |
152 | this._planesArray.push( plane ); | 216 | this._planesArray.push( plane ); |
217 | elt.elementModel.props3D.elementPlane = plane; | ||
153 | } | 218 | } |
154 | }, | 219 | }, |
155 | 220 | ||
@@ -166,6 +231,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
166 | 231 | ||
167 | // Then remove the element | 232 | // Then remove the element |
168 | this._eltArray.splice(i, 1); | 233 | this._eltArray.splice(i, 1); |
234 | |||
235 | // TODO - May need to delete props3D and elementPlane as well | ||
169 | return; | 236 | return; |
170 | } | 237 | } |
171 | } | 238 | } |
@@ -1040,7 +1107,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
1040 | var tmpCanvas = this.application.ninja.stage.canvas; | 1107 | var tmpCanvas = this.application.ninja.stage.canvas; |
1041 | var tmpStage = this.application.ninja.currentDocument.documentRoot; | 1108 | var tmpStage = this.application.ninja.currentDocument.documentRoot; |
1042 | this.viewUtils.pushViewportObj( tmpCanvas ); | 1109 | this.viewUtils.pushViewportObj( tmpCanvas ); |
1043 | var tmpStage = this.application.ninja.currentDocument.documentRoot; | ||
1044 | 1110 | ||
1045 | // save the source space object and set to the target object | 1111 | // save the source space object and set to the target object |
1046 | var saveSource = this._sourceSpaceElt; | 1112 | var saveSource = this._sourceSpaceElt; |
@@ -1064,7 +1130,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
1064 | var resMat = glmat4.multiply( tMat, mat, [] ); | 1130 | var resMat = glmat4.multiply( tMat, mat, [] ); |
1065 | var origin = [0,0,0,1]; | 1131 | var origin = [0,0,0,1]; |
1066 | 1132 | ||
1067 | var arrowSize = 50; | 1133 | var zoomFactor = this.application.ninja.documentBar.zoomFactor/100.0; |
1134 | var arrowSize = 50 / zoomFactor; | ||
1068 | var xAxis = [arrowSize,0,0,1]; | 1135 | var xAxis = [arrowSize,0,0,1]; |
1069 | //var rO = resMat.multiply(origin); | 1136 | //var rO = resMat.multiply(origin); |
1070 | var rO = glmat4.multiplyVec3( resMat, origin, []); | 1137 | var rO = glmat4.multiplyVec3( resMat, origin, []); |