From 5561e7cc43ae9f7cb9d1217ac02f9f136000e79c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 13 Apr 2012 13:37:17 -0700 Subject: fixed stage rotation Signed-off-by: Valerio Virgillito --- js/tools/Rotate3DToolBase.js | 35 ++++++++++++++++++++++++----------- js/tools/RotateObject3DTool.js | 1 + js/tools/RotateStage3DTool.js | 5 ++--- js/tools/modifier-tool-base.js | 3 +++ 4 files changed, 30 insertions(+), 14 deletions(-) (limited to 'js') diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js index 9f23040f..2e121b0b 100755 --- a/js/tools/Rotate3DToolBase.js +++ b/js/tools/Rotate3DToolBase.js @@ -21,6 +21,10 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { _inLocalMode: { value: true, enumerable: true }, + rotateStage: { + value: false + }, + drawWithoutSnapping: { value: function(event) @@ -54,8 +58,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { this._origin[0] += dx; this._origin[1] += dy; - - if(this.application.ninja.selectedElements.length === 1) { + if( this.rotateStage || (this.application.ninja.selectedElements.length === 1)) { this._startOriginArray[0][0] += dx; this._startOriginArray[0][1] += dy; } @@ -128,7 +131,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { } } - if(this._inLocalMode && (this.application.ninja.selectedElements.length === 1) ) + if(this._inLocalMode && (this.application.ninja.selectedElements.length === 1 || this.rotateStage) ) { this._rotateLocally(mat); } @@ -144,10 +147,15 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { _rotateLocally: { value: function (rotMat) { - var len = this.application.ninja.selectedElements.length; + var selectedElements = this.application.ninja.selectedElements; + + if(this.rotateStage) { + selectedElements = [this.application.ninja.currentDocument.documentRoot]; + } + var len = selectedElements.length; for(var i = 0; i < len; i++) { - var elt = this.application.ninja.selectedElements[i].elementModel.getProperty("elt"); - var curMat = this.application.ninja.selectedElements[i].elementModel.getProperty("mat"); + var elt = selectedElements[i].elementModel.getProperty("elt"); + var curMat = selectedElements[i].elementModel.getProperty("mat"); // pre-translate by the transformation center var tMat = Matrix.I(4); @@ -171,7 +179,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { glmat4.multiply(mat, tMat, mat); // while moving, set inline style to improve performance - viewUtils.setMatrixForElement(this.application.ninja.selectedElements[i], mat, true ); + viewUtils.setMatrixForElement(selectedElements[i], mat, true ); } } }, @@ -333,16 +341,21 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { return; } - var elt, eltCtr, ctrOffset, matInv; + var elt, element, eltCtr, ctrOffset, matInv; - if(this.application.ninja.selectedElements.length === 1) { + if(this.rotateStage || (this.application.ninja.selectedElements.length === 1)) { elt = this._target; if(shouldUpdateCenter) { - eltCtr = this.application.ninja.selectedElements[0].elementModel.getProperty("ctr"); + if(this.rotateStage) { + element = this.application.ninja.currentDocument.documentRoot; + } else { + element = this.application.ninja.selectedElements[0]; + } + eltCtr = element.elementModel.getProperty("ctr"); ctrOffset = vecUtils.vecSubtract(3, this._origin, eltCtr); - matInv = this.application.ninja.selectedElements[0].elementModel.getProperty("matInv"); + matInv = element.elementModel.getProperty("matInv"); ctrOffset = MathUtils.transformVector(ctrOffset, matInv); elt.elementModel.props3D.m_transformCtr = ctrOffset; diff --git a/js/tools/RotateObject3DTool.js b/js/tools/RotateObject3DTool.js index 27352231..902cf05d 100755 --- a/js/tools/RotateObject3DTool.js +++ b/js/tools/RotateObject3DTool.js @@ -18,6 +18,7 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, { _initializeToolHandles: { value: function() { + this.rotateStage = false; if(!this._handles) { this._handles = []; diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index adbf1b62..a980bf73 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -7,10 +7,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, Rotate3DToolBase = require("js/tools/Rotate3DToolBase").Rotate3DToolBase, toolHandleModule = require("js/stage/tool-handle"), - snapManager = require("js/helper-classes/3D/snap-manager").SnapManager, viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, - drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, ElementsMediator = require("js/mediators/element-mediator").ElementMediator; exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { @@ -23,6 +21,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { _initializeToolHandles: { value: function() { + this.rotateStage = true; if(!this._handles) { this._handles = []; @@ -149,6 +148,6 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { // this.UpdateSelection(true); this.Configure(true); } - } + } }); diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 6de5d06c..8cd21a29 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -809,7 +809,10 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { if(!this._activateOriginHandle) { this.application.ninja.stage.drawNow = true; + var canSnap = this._canSnap; + this._canSnap = true; this.doSelection(event); + this._canSnap = canSnap; } } -- cgit v1.2.3