aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-20 15:30:21 -0700
committerValerio Virgillito2012-06-20 15:30:21 -0700
commitd21185cecb8a1ddf9c6aeeb6e4d9f8745c90058c (patch)
treee76e776b8e1211b6696a7b1b4951d80f4b4e5714 /js
parentb3767590598fb5c102c8c3d40167653cd5961348 (diff)
parent6a0a5f6e7dec5e8ced6e228e7bbfcc1181f46c26 (diff)
downloadninja-d21185cecb8a1ddf9c6aeeb6e4d9f8745c90058c.tar.gz
Merge pull request #315 from mqg734/IKNinja_1671
IKNINJA-1671 - GIO: 3D rotate widget is offset from the object when rotated in negative space.
Diffstat (limited to 'js')
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js46
-rwxr-xr-xjs/tools/SelectionTool.js17
2 files changed, 44 insertions, 19 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index 6a84c86b..8ddd0d52 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -247,18 +247,18 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
247 // TODO - Check why handleElementChange is being fired before handleAddElement 247 // TODO - Check why handleElementChange is being fired before handleAddElement
248 handleElementChange: { 248 handleElementChange: {
249 value: function(event) { 249 value: function(event) {
250 this._elementChangeHelper(event); 250 this._elementChangeHelper(event, false);
251 } 251 }
252 }, 252 },
253 253
254 handleElementChanging: { 254 handleElementChanging: {
255 value: function(event) { 255 value: function(event) {
256 this._elementChangeHelper(event); 256 this._elementChangeHelper(event, true);
257 } 257 }
258 }, 258 },
259 259
260 _elementChangeHelper: { 260 _elementChangeHelper: {
261 value: function(event) { 261 value: function(event, isChanging) {
262 if(!event.detail || !event.detail.data) { 262 if(!event.detail || !event.detail.data) {
263 return; 263 return;
264 } 264 }
@@ -273,35 +273,45 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
273 l, 273 l,
274 t, 274 t,
275 plane, 275 plane,
276 changed = false; 276 changed = false,
277 adjustStagePadding = !isChanging || (event.detail.data.prop !== "matrix");
277 for(var i=0; i < len; i++) { 278 for(var i=0; i < len; i++) {
278 plane = els[i].elementModel.props3D.elementPlane; 279 plane = els[i].elementModel.props3D.elementPlane;
279 if(plane) { 280 if(plane) {
280 plane.init(); 281 plane.init();
281 l = plane._rect.m_left - docLeft; 282 if(adjustStagePadding) {
282 t = plane._rect.m_top - docTop; 283 l = plane._rect.m_left - docLeft;
283 if(l < minLeft) { 284 t = plane._rect.m_top - docTop;
284 minLeft = l; 285 if(l < minLeft) {
285 } 286 minLeft = l;
286 if(t < minTop) { 287 }
287 minTop = t; 288 if(t < minTop) {
289 minTop = t;
290 }
288 } 291 }
289 } 292 }
290 } 293 }
291 294
292 if(minLeft !== stage.userPaddingLeft) { 295 if(adjustStagePadding) {
293 stage.userPaddingLeft = minLeft; 296 if(minLeft !== stage.userPaddingLeft) {
294 changed = true; 297 stage.userPaddingLeft = minLeft;
295 } 298 changed = true;
296 if(minTop !== stage.userPaddingTop) { 299 }
297 stage.userPaddingTop = minTop; 300 if(minTop !== stage.userPaddingTop) {
298 changed = true; 301 stage.userPaddingTop = minTop;
302 changed = true;
303 }
299 } 304 }
300 305
301 if(!changed) { 306 if(!changed) {
302 this.drawWorkingPlane(); 307 this.drawWorkingPlane();
303 this.draw3DCompass(); 308 this.draw3DCompass();
304 } 309 }
310
311 // TODO - Remove this once all stage drawing is consolidated into a single draw cycle
312 if(!isChanging && this.application.ninja.toolsData.selectedToolInstance.captureSelectionDrawn) {
313 this.application.ninja.toolsData.selectedToolInstance.captureSelectionDrawn(null);
314 }
305 } 315 }
306 } 316 }
307 }, 317 },
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index 9bd885a4..a0d5bc26 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -47,6 +47,20 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
47 } 47 }
48 }, 48 },
49 49
50 _areElementsIn2D : {
51 value: function () {
52 if(this.application.ninja.selectedElements.length) {
53 var len = this.application.ninja.selectedElements.length;
54 for(var i = 0; i < len; i++) {
55 if(!MathUtils.isIdentityMatrix(this.application.ninja.selectedElements[i].elementModel.getProperty("mat"))) {
56 return false;
57 }
58 }
59 }
60 return true;
61 }
62 },
63
50 startDraw: { 64 startDraw: {
51 value: function(event) { 65 value: function(event) {
52 this.drawData = null; 66 this.drawData = null;
@@ -70,7 +84,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
70 if(this._canSnap) 84 if(this._canSnap)
71 { 85 {
72 this.initializeSnapping(event); 86 this.initializeSnapping(event);
73 this._use3DMode = !this._areElementsOnSamePlane(); 87// this._use3DMode = !this._areElementsOnSamePlane();
88 this._use3DMode = !this._areElementsIn2D();
74// console.log("use3DMode = " + this._use3DMode); 89// console.log("use3DMode = " + this._use3DMode);
75 } 90 }
76 else 91 else