From 22e664cdbb4bdf54cde87c0c3223e321e18ea372 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 19 Jun 2012 21:34:35 -0700 Subject: IKNINJA-1671 - GIO: 3D rotate widget is offset from the object when rotated in negative space. I fixed this temporarily by disabling the auto stage scroll calculations when we modify matrices. The correct fix will be to update any matrices and local2Global caches if we update the stage's padding (which I'm doing in a separate fix for a single draw cycle for the stage, but that fix is not ready yet). Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 46 +++++++++++++++++++++++--------------- js/tools/SelectionTool.js | 17 +++++++++++++- 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..177c844f 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, { // TODO - Check why handleElementChange is being fired before handleAddElement handleElementChange: { value: function(event) { - this._elementChangeHelper(event); + this._elementChangeHelper(event, false); } }, handleElementChanging: { value: function(event) { - this._elementChangeHelper(event); + this._elementChangeHelper(event, true); } }, _elementChangeHelper: { - value: function(event) { + value: function(event, isChanging) { if(!event.detail || !event.detail.data) { return; } @@ -273,35 +273,45 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { l, t, plane, - changed = false; + changed = false, + adjustStagePadding = !isChanging || (event.detail.data.prop !== "matrix"); for(var i=0; i < len; i++) { plane = els[i].elementModel.props3D.elementPlane; if(plane) { plane.init(); - l = plane._rect.m_left - docLeft; - t = plane._rect.m_top - docTop; - if(l < minLeft) { - minLeft = l; - } - if(t < minTop) { - minTop = t; + if(adjustStagePadding) { + l = plane._rect.m_left - docLeft; + t = plane._rect.m_top - docTop; + if(l < minLeft) { + minLeft = l; + } + if(t < minTop) { + minTop = t; + } } } } - if(minLeft !== stage.userPaddingLeft) { - stage.userPaddingLeft = minLeft; - changed = true; - } - if(minTop !== stage.userPaddingTop) { - stage.userPaddingTop = minTop; - changed = true; + if(adjustStagePadding) { + if(minLeft !== stage.userPaddingLeft) { + stage.userPaddingLeft = minLeft; + changed = true; + } + if(minTop !== stage.userPaddingTop) { + stage.userPaddingTop = minTop; + changed = true; + } } if(!changed) { this.drawWorkingPlane(); this.draw3DCompass(); } + + // TODO - Remove this once all stage drawing is consolidated into a single draw cycle + if(!isChanging) { + this.application.ninja.toolsData.selectedToolInstance.captureSelectionDrawn(null); + } } } }, diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 8b644d4a..8c3a9a25 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -47,6 +47,20 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { } }, + _areElementsIn2D : { + value: function () { + if(this.application.ninja.selectedElements.length) { + var len = this.application.ninja.selectedElements.length; + for(var i = 0; i < len; i++) { + if(!MathUtils.isIdentityMatrix(this.application.ninja.selectedElements[i].elementModel.getProperty("mat"))) { + return false; + } + } + } + return true; + } + }, + startDraw: { value: function(event) { this.drawData = null; @@ -70,7 +84,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { if(this._canSnap) { this.initializeSnapping(event); - this._use3DMode = !this._areElementsOnSamePlane(); +// this._use3DMode = !this._areElementsOnSamePlane(); + this._use3DMode = !this._areElementsIn2D(); // console.log("use3DMode = " + this._use3DMode); } else -- cgit v1.2.3 From 6a0a5f6e7dec5e8ced6e228e7bbfcc1181f46c26 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 20 Jun 2012 11:55:55 -0700 Subject: Fix for error when using ZoomTool. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 177c844f..8ddd0d52 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -309,7 +309,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { } // TODO - Remove this once all stage drawing is consolidated into a single draw cycle - if(!isChanging) { + if(!isChanging && this.application.ninja.toolsData.selectedToolInstance.captureSelectionDrawn) { this.application.ninja.toolsData.selectedToolInstance.captureSelectionDrawn(null); } } -- cgit v1.2.3