diff options
author | Valerio Virgillito | 2012-02-06 11:02:14 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-06 11:02:14 -0800 |
commit | 671a27069db6a121507c2b342653aede685cff67 (patch) | |
tree | 77e9f1499c400229273f880c9d365115b411b227 /js/helper-classes | |
parent | e58204970e398ce3a36a52bbf72d120c7ffdc167 (diff) | |
parent | 1b0c5c0e7ebf9dda95a624da546aaece268631ad (diff) | |
download | ninja-671a27069db6a121507c2b342653aede685cff67.tar.gz |
Merge pull request #15 from mqg734/ToolFixes
Adding, deleting and modifying elements now keep the element planes and PI in sync.
Diffstat (limited to 'js/helper-classes')
-rw-r--r-- | js/helper-classes/3D/draw-utils.js | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index fd96af4d..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,7 @@ 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); | ||
110 | this.eventManager.addEventListener("elementChange", this, false); | 114 | this.eventManager.addEventListener("elementChange", this, false); |
111 | } | 115 | } |
112 | }, | 116 | }, |
@@ -124,11 +128,44 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
124 | } | 128 | } |
125 | }, | 129 | }, |
126 | 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 | }, | ||
127 | 159 | ||
160 | // TODO - Check why handleElementChange is being fired before handleAddElement | ||
128 | handleElementChange: { | 161 | handleElementChange: { |
129 | value: function(event) { | 162 | value: function(event) { |
163 | if(!event.detail || !event.detail.data) | ||
164 | { | ||
165 | return; | ||
166 | } | ||
130 | var els = event.detail.data.els; | 167 | var els = event.detail.data.els; |
131 | if(els) | 168 | if(els && this._shouldUpdatePlanes(event.detail.data.prop)) |
132 | { | 169 | { |
133 | var len = els.length, | 170 | var len = els.length, |
134 | i = 0, | 171 | i = 0, |
@@ -138,10 +175,15 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
138 | for(i=0; i < len; i++) { | 175 | for(i=0; i < len; i++) { |
139 | item = els[i]; | 176 | item = els[i]; |
140 | el = item._element || item; | 177 | el = item._element || item; |
141 | el.elementModel.props3D.elementPlane.init(); | 178 | if(el.elementModel.props3D.elementPlane) |
179 | { | ||
180 | el.elementModel.props3D.elementPlane.init(); | ||
181 | } | ||
142 | } | 182 | } |
143 | 183 | ||
184 | this.application.ninja.stage.layout.draw(); | ||
144 | this.drawWorkingPlane(); | 185 | this.drawWorkingPlane(); |
186 | this.draw3DCompass(); | ||
145 | } | 187 | } |
146 | } | 188 | } |
147 | }, | 189 | }, |
@@ -1065,7 +1107,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
1065 | var tmpCanvas = this.application.ninja.stage.canvas; | 1107 | var tmpCanvas = this.application.ninja.stage.canvas; |
1066 | var tmpStage = this.application.ninja.currentDocument.documentRoot; | 1108 | var tmpStage = this.application.ninja.currentDocument.documentRoot; |
1067 | this.viewUtils.pushViewportObj( tmpCanvas ); | 1109 | this.viewUtils.pushViewportObj( tmpCanvas ); |
1068 | var tmpStage = this.application.ninja.currentDocument.documentRoot; | ||
1069 | 1110 | ||
1070 | // save the source space object and set to the target object | 1111 | // save the source space object and set to the target object |
1071 | var saveSource = this._sourceSpaceElt; | 1112 | var saveSource = this._sourceSpaceElt; |