From 8423cceac4f45f3d08d92ae969d17d488674717f Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 2 Apr 2012 16:28:09 -0700 Subject: Translate 3D fix for multi-selection Z translation --- js/tools/Translate3DToolBase.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/tools') diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index 18e2b610..bd2b3af1 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -147,8 +147,8 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, _translateGlobally: { value: function (transMat) { - //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat ); //console.log( "_translateGlobally, transMat: " + transMat ); + //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat ); var len = this._targets.length, i = 0, item, @@ -160,6 +160,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, if (this._mode === 1) { + if (len > 1) curMat = this._targets[0].mat.slice(); var curInv = glmat4.inverse( curMat, [] ); transMat = glmat4.multiply( nMat, curInv, [] ); } -- cgit v1.2.3 From b6fa38e2680ccce73f4a195f9adffa552f1d237c Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 4 Apr 2012 12:37:43 -0700 Subject: turned off translation handles during a multi-object drag. --- js/tools/Translate3DToolBase.js | 175 ++++++++++++++++++++-------------------- js/tools/modifier-tool-base.js | 13 ++- 2 files changed, 100 insertions(+), 88 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index bd2b3af1..32132c9a 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -73,13 +73,13 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, var transMat = Matrix.Translation( delta ); - //console.log( "Translate: " + delta ); if(this._inLocalMode && (this._targets.length === 1) ) { this._translateLocally(transMat); } else { + console.log( "modifyElements delta: " + delta ); this._translateGlobally(transMat); } } @@ -147,23 +147,23 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, _translateGlobally: { value: function (transMat) { - //console.log( "_translateGlobally, transMat: " + transMat ); - //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat ); + //console.log( "_translateGlobally, transMat: " + transMat ); + //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat ); var len = this._targets.length, i = 0, item, elt, curMat = viewUtils.getMatrixFromElement( this._target ), - matInv = glmat4.inverse(this._startMat, []), - nMat = glmat4.multiply(transMat, this._startMat, [] ), - qMat = glmat4.multiply(matInv, nMat, []); - - if (this._mode === 1) - { - if (len > 1) curMat = this._targets[0].mat.slice(); - var curInv = glmat4.inverse( curMat, [] ); - transMat = glmat4.multiply( nMat, curInv, [] ); - } + matInv = glmat4.inverse(this._startMat, []), + nMat = glmat4.multiply(transMat, this._startMat, [] ), + qMat = glmat4.multiply(matInv, nMat, []); + + if (this._mode === 1) + { + if (len > 1) curMat = this._targets[0].mat.slice(); + var curInv = glmat4.inverse( curMat, [] ); + transMat = glmat4.multiply( nMat, curInv, [] ); + } var shouldUpdateStartMat = true; @@ -185,27 +185,27 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, // glmat4.multiply(curMat, qMat, curMat); // // viewUtils.setMatrixForElement( elt, curMat, true); - curMat[12] += transMat[12]; - curMat[13] += transMat[13]; - curMat[14] += transMat[14]; - viewUtils.setMatrixForElement( elt, curMat, true); + curMat[12] += transMat[12]; + curMat[13] += transMat[13]; + curMat[14] += transMat[14]; + viewUtils.setMatrixForElement( elt, curMat, true); if(shouldUpdateStartMat) { - //console.log( "\t\tshouldUpdateStartMat" ); + //console.log( "\t\tshouldUpdateStartMat" ); this._targets[i].mat = curMat; } } } }, - _updateTargets: { + _updateTargets: { value: function(addToUndoStack) - { - console.log( "_updateTargets" ); - var newStyles = [], - previousStyles = [], - len = this.application.ninja.selectedElements.length; + { + //console.log( "_updateTargets" ); + var newStyles = [], + previousStyles = [], + len = this.application.ninja.selectedElements.length; this._targets = []; for(var i = 0; i < len; i++) { @@ -215,47 +215,47 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, var curMatInv = glmat4.inverse(curMat, []); this._targets.push({elt:elt, mat:curMat, matInv:curMatInv}); - if(addToUndoStack) - { - var previousStyleStr = {dist:this._undoArray[i].dist, mat:MathUtils.scientificToDecimal(this._undoArray[i].mat.slice(0), 5)}; + if(addToUndoStack) + { + var previousStyleStr = {dist:this._undoArray[i].dist, mat:MathUtils.scientificToDecimal(this._undoArray[i].mat.slice(0), 5)}; - var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), mat:MathUtils.scientificToDecimal(curMat, 5)}; + var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), mat:MathUtils.scientificToDecimal(curMat, 5)}; - previousStyles.push(previousStyleStr); - newStyles.push(newStyleStr); - } + previousStyles.push(previousStyleStr); + newStyles.push(newStyleStr); + } } if(addToUndoStack) { - ElementsMediator.set3DProperties(this.application.ninja.selectedElements, - newStyles, - "Change", - "translateTool", - previousStyles - ); - if(this._origin && this._delta) - { - if(this._handleMode !== null) - { - this._origin[this._handleMode] += this._delta; - } - else - { - this._origin[0] += this._delta[0]; - this._origin[1] += this._delta[1]; - } - } - this._delta = null; - } - // Save previous value for undo/redo - this._undoArray = []; - for(i = 0, len = this._targets.length; i < len; i++) - { - var elt = this._targets[i].elt; - var _mat = viewUtils.getMatrixFromElement(elt); - var _dist = viewUtils.getPerspectiveDistFromElement(elt); - this._undoArray.push({mat:_mat, dist:_dist}); - } + ElementsMediator.set3DProperties(this.application.ninja.selectedElements, + newStyles, + "Change", + "translateTool", + previousStyles + ); + if(this._origin && this._delta) + { + if(this._handleMode !== null) + { + this._origin[this._handleMode] += this._delta; + } + else + { + this._origin[0] += this._delta[0]; + this._origin[1] += this._delta[1]; + } + } + this._delta = null; + } + // Save previous value for undo/redo + this._undoArray = []; + for(i = 0, len = this._targets.length; i < len; i++) + { + var elt = this._targets[i].elt; + var _mat = viewUtils.getMatrixFromElement(elt); + var _dist = viewUtils.getPerspectiveDistFromElement(elt); + this._undoArray.push({mat:_mat, dist:_dist}); + } } }, @@ -305,27 +305,27 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, } else { - if(this._origin) - { - if(this._delta) - { - if(this._handleMode !== null) - { + if(this._origin) + { + if(this._delta) + { + if(this._handleMode !== null) + { // this._origin[this._handleMode] = this._delta; - } - else - { - this._origin[0] += this._delta[0]; - this._origin[1] += this._delta[1]; - } - } - } - else - { - this._origin = drawUtils._selectionCtr.slice(0); - this._origin[0] += this.application.ninja.stage.userContentLeft; - this._origin[1] += this.application.ninja.stage.userContentTop; - } + } + else + { + this._origin[0] += this._delta[0]; + this._origin[1] += this._delta[1]; + } + } + } + else + { + this._origin = drawUtils._selectionCtr.slice(0); + this._origin[0] += this.application.ninja.stage.userContentLeft; + this._origin[1] += this.application.ninja.stage.userContentTop; + } } } } @@ -364,10 +364,13 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, } // Draw tool handles - - this._updateHandlesOrigin(); + + this._updateHandlesOrigin(); var base = this._origin.slice(0); +// if (this.isDrawing) +// console.log( "handle origin: " + base ); + var len = this.application.ninja.selectedElements.length; var lMode = this._inLocalMode; if(len === 1) @@ -397,10 +400,10 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, this._handles[1]._strokeStyle = 'rgba(0, 255, 0, 0.2)'; break; } - if( delta && (len > 1) ) - { - base[this._handleMode] += ~~delta; - } + if( delta && (len > 1) ) + { + base[this._handleMode] += ~~delta; + } } this._handles[0].draw(base, item, lMode); this._handles[1].draw(base, item, lMode); diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 07b28747..e684f58a 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -852,8 +852,10 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { } } - this.DrawHandles(this._delta); - if(this._canSnap) + if (!this._isDrawing || (this.application.ninja.selectedElements.length == 1)) + this.DrawHandles(this._delta); + + if(this._canSnap) { snapManager.drawLastHit(); } @@ -892,6 +894,13 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { this._delta = null; } this.endDraw(event); + + this.application.ninja.stage.draw(); + if (this._targets && (this._targets.length > 1)) + { + this._origin = null; + this._updateHandlesOrigin(); + } this.DrawHandles(); } }, -- cgit v1.2.3 From 16f62ca09cc428043e8fef8bdeea11a989e62bc0 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 4 Apr 2012 16:29:16 -0700 Subject: Cap fix for vecUtils. --- js/tools/TranslateObject3DTool.js | 3 ++- js/tools/modifier-tool-base.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index 7163f005..867bec7f 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js @@ -7,6 +7,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, + vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { @@ -128,7 +129,7 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { // only do quadrant snapping if the 4 corners of the element are in the drag plane - var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); + var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); this._shouldUseQuadPt = (sign == 0); var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index e684f58a..b6589cba 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -177,7 +177,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { } // only do quadrant snapping if the 4 corners of the element are in the drag plane - var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); + var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); this._shouldUseQuadPt = (sign == 0) var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); -- cgit v1.2.3 From 96bfeee2e6b735b87e8482d6e2cf24d5224c6417 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 5 Apr 2012 17:03:14 -0700 Subject: translate3DObject tool fixes. --- js/tools/Translate3DToolBase.js | 7 ++++--- js/tools/modifier-tool-base.js | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index 4799b840..2276178c 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -71,6 +71,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, this._delta = delta.slice(0); } + //console.log( "modifyElements delta: " + delta ); var transMat = Matrix.Translation( delta ); if(this._inLocalMode && (this._targets.length === 1) ) @@ -79,7 +80,6 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, } else { - console.log( "modifyElements delta: " + delta ); this._translateGlobally(transMat); } } @@ -148,7 +148,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, _translateGlobally: { value: function (transMat) { //console.log( "_translateGlobally, transMat: " + transMat ); - //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat ); + //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat[12] + ", " + transMat[13] + ", " + transMat[14] ); var len = this._targets.length, i = 0, item, @@ -167,7 +167,8 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, var shouldUpdateStartMat = true; - if(this._clickedOnStage) + //if (this._clickedOnStage) + if(this._clickedOnStage || ((this._handleMode === 2) && (this._targets.length > 1))) { shouldUpdateStartMat = false; } diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 2c9b484e..f9fd001c 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -405,6 +405,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { var index = this._snapIndex; var pt0; var useViewPoint = (this._inLocalMode && (this._targets.length === 1)); + //console.log( "useViewPoint: " + useViewPoint ); if (this._useQuadPt) { pt0 = this.GetQuadrantPoint(useViewPoint); @@ -427,6 +428,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { pt1 = MathUtils.transformPoint( pt1, this._startMat ); } + //console.log( "getMousePoints, useViewPoint: " + useViewPoint + ", " + pt0 + " => " + pt1 ); return {pt0:pt0, pt1:pt1}; } else -- cgit v1.2.3 From 48d4dd0f0570f4ac3556f228846ed0fd98a674e5 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 9 Apr 2012 16:47:56 -0700 Subject: setProperties to the montage undo/redo Signed-off-by: Valerio Virgillito --- js/tools/SelectionTool.js | 57 ++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 43 deletions(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 94cc6b83..6dec781b 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -372,46 +372,21 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { } } } - if(addToUndoStack) - { - if(!this._use3DMode) - { + + if(addToUndoStack) { + if(!this._use3DMode) { // if we have a delta, that means the transform handles were used and // we should update the width and height too. Otherwise, just update left and top. - if(this._delta) - { - ElementsMediator.setProperties(this.application.ninja.selectedElements, - { "left": newLeft, "top": newTop, "width": newWidth, "height": newHeight }, - "Change", - "selectionTool", - { "left" : previousLeft, "top" : previousTop, "width": previousWidth, "height": previousHeight} - ); - } - else - { - ElementsMediator.setProperties(this.application.ninja.selectedElements, - { "left": newLeft, "top": newTop }, - "Change", - "selectionTool", - { "left" : previousLeft, "top" : previousTop } - ); + if(this._delta) { + ElementsMediator.setProperties(this.application.ninja.selectedElements, {"left": newLeft, "top": newTop, "width": newWidth, "height": newHeight }, + { "left" : previousLeft, "top" : previousTop, "width": previousWidth, "height": previousHeight}, "Change", "selectionTool"); + } else { + ElementsMediator.setProperties(this.application.ninja.selectedElements, {"left": newLeft, "top": newTop }, {"left": previousLeft, "top": previousTop}, "Change", "selectionTool"); } - } - else - { + } else { // TODO - We don't support transform handles in 3d space for now - ElementsMediator.setProperties(this.application.ninja.selectedElements, - { "width": newWidth, "height": newHeight }, - "Change", - "selectionTool", - { "width": previousWidth, "height": previousHeight} - ); - ElementsMediator.set3DProperties(this.application.ninja.selectedElements, - newStyles, - "Change", - "translateTool", - previousStyles - ); + ElementsMediator.setProperties(this.application.ninja.selectedElements, {"width": newWidth, "height": newHeight }, {"width": previousWidth, "height": previousHeight}, "Change", "selectionTool"); + ElementsMediator.set3DProperties(this.application.ninja.selectedElements, newStyles, "Change", "translateTool", previousStyles); } } // Save previous value for undo/redo @@ -471,13 +446,9 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { } } - if(newLeft.length) - { - ElementsMediator.setProperties(this.application.ninja.selectedElements, - { "left": newLeft, "top": newTop }, "Changing", "SelectionTool" ); - } - else - { + if(newLeft.length) { + ElementsMediator.setProperties(this.application.ninja.selectedElements, {"left": newLeft, "top": newTop }, null, "Changing", "SelectionTool" ); + } else { NJevent("elementChanging", {type : "Changing", redraw: false}); } } -- cgit v1.2.3 From f522ce09d98bbb2812ed25bb942597d854d71a1c Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 11 Apr 2012 16:01:33 -0700 Subject: Rotate3D tool changes --- js/tools/Rotate3DToolBase.js | 38 ++++++++++- js/tools/RotateObject3DTool.js | 141 ++++++++++++++++++++++++++++++++++++++++- js/tools/modifier-tool-base.js | 1 + 3 files changed, 178 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js index eb2cdba4..e0c5abcb 100755 --- a/js/tools/Rotate3DToolBase.js +++ b/js/tools/Rotate3DToolBase.js @@ -56,17 +56,23 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { // move the transform origin handle var dx = pt1.x - pt0.x; var dy = pt1.y - pt0.y; + var dz = pt1.z - pt0.z; + this._origin[0] += dx; this._origin[1] += dy; + this._origin[2] += dz; var len = this._targets.length; if(len === 1) { this._startOriginArray[0][0] += dx; this._startOriginArray[0][1] += dy; + this._startOriginArray[0][2] += dz; + console.log( "Rotate3DToolBase.modifyElements, _startOriginArray[0]: " + this._startOriginArray[0] ); } this.downPoint.x = pt1.x; this.downPoint.y = pt1.y; + this.downPoint.z = pt1.z; this.DrawHandles(); return; } @@ -159,8 +165,23 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { // pre-translate by the transformation center var tMat = Matrix.I(4); + // _startOriginArray is the location of the center of rotation + // in view space of the element. It is currently calculated during the drag + // using delta's in global screen space, hence wrong. + // We can put the transformCenter back in element view space here, however + // it would be (much) more efficient to cache the localToGlobal and + // globalToLocal matrices. var transformCtr = this._startOriginArray[i]; + var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); + var globalToLocalMat = glmat4.inverse( localToGlobalMat, [] ); + var newTransformCtr = MathUtils.transformAndDivideHomogeneousPoint( this._origin, globalToLocalMat ); + viewUtils.pushViewportObj( elt ); + newTransformCtr = viewUtils.screenToView( newTransformCtr[0], newTransformCtr[1], newTransformCtr[2] ); + viewUtils.popViewportObj( elt ); + //console.log( "transformCtr: " + newTransformCtr ); + transformCtr = newTransformCtr; + tMat[12] = transformCtr[0]; tMat[13] = transformCtr[1]; tMat[14] = transformCtr[2]; @@ -267,6 +288,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { viewUtils.pushViewportObj( this.target ); var eltCtr = viewUtils.getCenterOfProjection(); + eltCtr[2] = 0; viewUtils.popViewportObj(); var ctrOffset = this.target.elementModel.props3D.m_transformCtr; @@ -277,6 +299,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { } this._origin = viewUtils.localToGlobal(eltCtr, this.target); + console.log( "Rotate3DToolBase.captureSelectionDrawn _origin: " + this._origin ); this._updateTargets(); this._setTransformOrigin(false); } @@ -533,6 +556,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { */ _showFeedbackOnMouseMove : { value: function (event) { + this._canSnap = false; if(this._target && this._handles) { var len = this._handles.length; @@ -550,7 +574,8 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { this.application.ninja.stage.drawingCanvas.style.cursor = "move"; this._handleMode = i; this._activateOriginHandle = true; - return; + this._canSnap = true; + return; } else if(c === 2) { @@ -569,6 +594,16 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { } }, + getMousePoints: { + value: function() + { + var pt0 = { x:this.downPoint.x, y:this.downPoint.y, z:this.downPoint.z }; + var pt1 = { x:this.upPoint.x, y:this.upPoint.y, z:this.upPoint.z }; + + return {pt0:pt0, pt1:pt1}; + } + }, + DrawHandles: { value: function (angle) { this.application.ninja.stage.clearDrawingCanvas(); @@ -594,6 +629,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { viewUtils.pushViewportObj( this.application.ninja.currentDocument.documentRoot ); } var base = this._origin; + //console.log( "Rotate3DToolBase.DrawHandles, base: " + base ); if( (this._handleMode !== null) && !this._activateOriginHandle ) { diff --git a/js/tools/RotateObject3DTool.js b/js/tools/RotateObject3DTool.js index 72af6eff..7b4ec083 100755 --- a/js/tools/RotateObject3DTool.js +++ b/js/tools/RotateObject3DTool.js @@ -4,7 +4,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Montage = require("montage/core/core").Montage; +var Montage = require("montage/core/core").Montage, + viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, + snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; var Rotate3DToolBase = require("js/tools/Rotate3DToolBase").Rotate3DToolBase; var toolHandleModule = require("js/stage/tool-handle"); @@ -54,6 +56,143 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, { } }, + initializeSnapping : { + value : function(event) + { + console.log( "initializeSnapping" ); + + this._mouseDownHitRec = null; + this._mouseUpHitRec = null; + + snapManager.clearAvoidList(); + snapManager.clearDragPlane(); + + // the translate tool does snap align to the bounds of the object only. + // turn off snap align to the cursor. This needs to be re-enabled in the mouse up method + snapManager.enableSnapAlign( false ); + + // snap to element and snap to grid are conditionally enabled based + // on the snap results of the mouse down. enable everything for the first snap + this._snapToElements = snapManager.elementSnapEnabledAppLevel(); + this._snapToGrid = snapManager.gridSnapEnabledAppLevel(); + + this._dragPlane = null; + this._clickedOnStage = false; + var do3DSnap = true; + + if(this._handleMode === null) + { + snapManager.enableElementSnap ( true ); + snapManager.enableGridSnap ( true ); + } +// else +// { +// this._delta = null; + // special case for z-translation +// if(this._handleMode === 0) +// { +// this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target); +// snapManager.setupDragPlaneFromPlane(this._dragPlane); +// do3DSnap = false; + +// snapManager.enableElementSnap ( false ); +// snapManager.enableGridSnap ( false ); +// } +// } + + if (this._targets) + { + var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, + new WebKitPoint(event.pageX, event.pageY)); + + // do the snap before setting up the avoid list to allow + // a snap on the mouse down + var hitRec = snapManager.snap(point.x, point.y, do3DSnap); + +// if(this._handleMode === 2) +// { +// // translate z doesn't snap to element so hitRec's element will always be different +// // from what the browser says we clicked on. So, skip this check. +// } +// else +// { +// // Check that hitRec's element matches element that browser says we clicked on +// // TODO - This is still not working when using a handle that is on top of an +// // element that is not currently selected +// var elt = this.application.ninja.stage.GetSelectableElement(event); +// if(elt && (elt !== hitRec.getElement())) +// { +// hitRec = snapManager.findHitRecordForElement(elt); +// } +// if(elt === this.application.ninja.currentSelectedContainer) +// { +// this._clickedOnStage = true; +// } +// } + + // we don't want to snap to selected objects during the drag +// var len = this._targets.length; +// for(var i=0; i --- js/tools/Rotate3DToolBase.js | 184 ++++++++++----------------- js/tools/RotateStage3DTool.js | 12 +- js/tools/SelectionTool.js | 254 ++++++++++++++++---------------------- js/tools/Translate3DToolBase.js | 158 +++++++++--------------- js/tools/TranslateObject3DTool.js | 17 ++- js/tools/modifier-tool-base.js | 35 +----- 6 files changed, 249 insertions(+), 411 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js index 696408bf..ae1856e8 100755 --- a/js/tools/Rotate3DToolBase.js +++ b/js/tools/Rotate3DToolBase.js @@ -44,27 +44,22 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { modifyElements: { value: function(data, event) { - var mat, - angle, - pt0 = data.pt0, - pt1 = data.pt1; + var mat, angle, pt0 = data.pt0, pt1 = data.pt1; - if(this._handleMode !== null) - { - if(this._activateOriginHandle) - { + if(this._handleMode !== null) { + if(this._activateOriginHandle) { // move the transform origin handle var dx = pt1.x - pt0.x; var dy = pt1.y - pt0.y; this._origin[0] += dx; this._origin[1] += dy; - var len = this._targets.length; - if(len === 1) - { + + if(this.application.ninja.selectedElements.length === 1) { this._startOriginArray[0][0] += dx; this._startOriginArray[0][1] += dy; } + this.downPoint.x = pt1.x; this.downPoint.y = pt1.y; this.DrawHandles(); @@ -133,7 +128,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { } } - if(this._inLocalMode && (this._targets.length === 1) ) + if(this._inLocalMode && (this.application.ninja.selectedElements.length === 1) ) { this._rotateLocally(mat); } @@ -149,12 +144,10 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { _rotateLocally: { value: function (rotMat) { - var len = this._targets.length; - for(var i = 0; i < len; i++) - { - var item = this._targets[i]; - var elt = item.elt; - var curMat = item.mat; + var len = this.application.ninja.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"); // pre-translate by the transformation center var tMat = Matrix.I(4); @@ -178,19 +171,17 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { glmat4.multiply(mat, tMat, mat); // while moving, set inline style to improve performance - viewUtils.setMatrixForElement( elt, mat, true ); + viewUtils.setMatrixForElement(this.application.ninja.selectedElements[i], mat, true ); } } }, _rotateGlobally: { value: function (rotMat) { - var len = this._targets.length; - for(var i = 0; i < len; i++) - { - var item = this._targets[i]; - var elt = item.elt; - var curMat = item.mat; + var len = this.application.ninja.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"); // pre-translate by the transformation center var tMat = Matrix.I(4); @@ -213,7 +204,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { glmat4.multiply(mat, curMat, mat); - viewUtils.setMatrixForElement( elt, mat, true ); + viewUtils.setMatrixForElement(this.application.ninja.selectedElements[i], mat, true ); } } }, @@ -254,7 +245,6 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { captureSelectionDrawn: { value: function(event){ this._origin = null; - this._targets = []; this._startOriginArray = null; var len = this.application.ninja.selectedElements.length; @@ -304,103 +294,75 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { }, _updateTargets: { - value: function(addToUndoStack) { - var newStyles = [], - previousStyles = [], - len = this.application.ninja.selectedElements.length; - this._targets = []; - for(var i = 0; i < len; i++) - { - var elt = this.application.ninja.selectedElements[i]; -// this._initProps3D(elt); + value: function(addToUndo) { + var mod3dObject = [], self = this; - - var curMat = viewUtils.getMatrixFromElement(elt); - var curMatInv = glmat4.inverse(curMat, []); - - viewUtils.pushViewportObj( elt ); + this.application.ninja.selectedElements.forEach(function(element) { + viewUtils.pushViewportObj(element); var eltCtr = viewUtils.getCenterOfProjection(); viewUtils.popViewportObj(); + eltCtr = viewUtils.localToGlobal(eltCtr, element); - eltCtr = viewUtils.localToGlobal(eltCtr, elt); + element.elementModel.setProperty("ctr", eltCtr); - this._targets.push({elt:elt, mat:curMat, matInv:curMatInv, ctr:eltCtr}); - if(addToUndoStack) - { - var previousStyleStr = {dist:this._undoArray[i].dist, mat:MathUtils.scientificToDecimal(this._undoArray[i].mat.slice(0), 5)}; + if(addToUndo) { + var previousMat = element.elementModel.getProperty("mat").slice(0); + var previousStyleStr = {dist:element.elementModel.getProperty("dist"), mat:MathUtils.scientificToDecimal(previousMat, 5)}; + var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(element), mat:MathUtils.scientificToDecimal(viewUtils.getMatrixFromElement(element), 5)}; - var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), mat:MathUtils.scientificToDecimal(curMat, 5)}; - - previousStyles.push(previousStyleStr); - newStyles.push(newStyleStr); + mod3dObject.push({element:element, properties:newStyleStr, previousProperties: previousStyleStr}); } + + }); + + if(addToUndo) { + ElementsMediator.set3DProperties(mod3dObject, "Change", "rotateTool"); } - if(addToUndoStack) - { - ElementsMediator.set3DProperties(this.application.ninja.selectedElements, - newStyles, - "Change", - "rotateTool", - previousStyles - ); - } - // Save previous value for undo/redo - this._undoArray = []; - for(i = 0, len = this._targets.length; i < len; i++) - { - var elt = this._targets[i].elt; - var _mat = viewUtils.getMatrixFromElement(elt); - var _dist = viewUtils.getPerspectiveDistFromElement(elt); - this._undoArray.push({mat:_mat, dist:_dist}); - } + + this.application.ninja.selectedElements.forEach(function(element) { + element.elementModel.setProperty("mat", viewUtils.getMatrixFromElement(element)); + element.elementModel.setProperty("matInv", glmat4.inverse(element.elementModel.getProperty("mat"), [])); + element.elementModel.setProperty("dist", viewUtils.getPerspectiveDistFromElement(element)); + }); } }, _setTransformOrigin: { value: function(shouldUpdateCenter) { - if(!this._origin) - { + if(!this._origin) { return; } - var len = this._targets.length; - var elt, - eltCtr, - ctrOffset, - matInv; - if( len === 1) - { + + var elt, eltCtr, ctrOffset, matInv; + + if(this.application.ninja.selectedElements.length === 1) { elt = this._target; - if(shouldUpdateCenter) - { - eltCtr = this._targets[0].ctr; + if(shouldUpdateCenter) { + console.log("get crt"); + eltCtr = this.application.ninja.selectedElements[0].elementModel.getProperty("ctr"); ctrOffset = vecUtils.vecSubtract(3, this._origin, eltCtr); - matInv = this._targets[0].matInv; + matInv = this.application.ninja.selectedElements[0].elementModel.getProperty("matInv"); ctrOffset = MathUtils.transformVector(ctrOffset, matInv); elt.elementModel.props3D.m_transformCtr = ctrOffset; - } - else - { + } else { this._startOriginArray = []; - var ctrOffset = this._target.elementModel.props3D.m_transformCtr; - if(!ctrOffset) - { + ctrOffset = this._target.elementModel.props3D.m_transformCtr; + if(!ctrOffset) { ctrOffset = [0,0,0]; } } this._startOriginArray[0] = ctrOffset; - } - else - { + } else { // Update transform ctr for all elements if transform origin was modified this._startOriginArray = []; + var len = this.application.ninja.selectedElements.length; for (var i = 0; i < len; i++) { - elt = this._targets[i].elt; - eltCtr = this._targets[i].ctr; + eltCtr = this.application.ninja.selectedElements[i].elementModel.getProperty("ctr"); ctrOffset = vecUtils.vecSubtract(3, this._origin, eltCtr); - matInv = this._targets[i].matInv; + matInv = this.application.ninja.selectedElements[i].elementModel.getProperty("matInv"); ctrOffset = MathUtils.transformVector(ctrOffset, matInv); this._startOriginArray[i] = ctrOffset; @@ -434,43 +396,27 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { } }, - Reset : { - value : function() - { - var item, - mat, - dist, - newStyles = [], - previousStyles = [], - len = this.application.ninja.selectedElements.length, - iMat; - for(var i = 0; i < len; i++) - { + Reset: { + value: function() { + var mat, iMat, dist, mod3dObject = [], self = this; + + this.application.ninja.selectedElements.forEach(function(element) { // Reset to the identity matrix - item = this.application.ninja.selectedElements[i]; iMat = Matrix.I(4); - mat = ElementsMediator.getMatrix(item); + mat = ElementsMediator.getMatrix(element); // iMat[12] = mat[12]; // iMat[13] = mat[13]; // iMat[14] = mat[14]; - dist = ElementsMediator.getPerspectiveDist(item); + dist = ElementsMediator.getPerspectiveDist(element); var previousStyleStr = {dist:dist, mat:mat}; - var newStyleStr = {dist:dist, mat:iMat}; - previousStyles.push(previousStyleStr); - newStyles.push(newStyleStr); - - } + mod3dObject.push({element:element, properties:newStyleStr, previousProperties: previousStyleStr}); + }); - ElementsMediator.set3DProperties(this.application.ninja.selectedElements, - newStyles, - "Change", - "rotateTool", - previousStyles - ); + ElementsMediator.set3DProperties(mod3dObject, "Change", "rotateTool"); this.isDrawing = false; this.endDraw(event); diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index f5cc4040..adbf1b62 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -62,7 +62,6 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { _updateTargets: { value: function(addToUndoStack) { - this._targets = []; var elt = this._target; var curMat = viewUtils.getMatrixFromElement(elt); @@ -74,7 +73,9 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { eltCtr = viewUtils.localToGlobal(eltCtr, elt); - this._targets.push({elt:elt, mat:curMat, matInv:curMatInv, ctr:eltCtr}); + elt.elementModel.setProperty("mat", curMat); + elt.elementModel.setProperty("matInv", curMatInv); + elt.elementModel.setProperty("ctr", eltCtr); ElementsMediator.setMatrix(elt, curMat, false, "rotateStage3DTool"); } @@ -83,7 +84,6 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { captureSelectionDrawn: { value: function(event){ this._origin = null; - this._targets = []; this._startOriginArray = null; var stage = this.application.ninja.currentDocument.documentRoot; @@ -93,12 +93,12 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { var eltCtr = viewUtils.getCenterOfProjection(); viewUtils.popViewportObj(); - this._targets = []; - var curMat = viewUtils.getMatrixFromElement(stage); var curMatInv = glmat4.inverse(curMat, []); - this._targets.push({elt:stage, mat:curMat, matInv:curMatInv, ctr:eltCtr}); + stage.elementModel.setProperty("mat", curMat); + stage.elementModel.setProperty("matInv", curMatInv); + stage.elementModel.setProperty("ctr", eltCtr); var ctrOffset = stage.elementModel.props3D.m_transformCtr; if(ctrOffset) diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 6dec781b..d9327f33 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -33,19 +33,16 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { _areElementsOnSamePlane : { value: function () { - if(this._targets && this._targets.length) - { - var len = this._targets.length; + if(this.application.ninja.selectedElements.length) { + var len = this.application.ninja.selectedElements.length; var plane = this.application.ninja.stage.stageDeps.snapManager.getDragPlane(); - for(var i = 0; i < len; i++) - { - var elt = this._targets[i].elt; - if(!this.application.ninja.stage.stageDeps.snapManager.elementIsOnPlane(elt, plane)) - { + for(var i = 0; i < len; i++) { + if(!this.application.ninja.stage.stageDeps.snapManager.elementIsOnPlane(this.application.ninja.selectedElements[i], plane)) { return false; } } } + return true; } }, @@ -296,160 +293,126 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { }, _updateTargets: { - value: function(addToUndoStack) { - var newLeft = [], - newTop = [], - newWidth = [], - newHeight = [], - newStyles = [], - previousLeft = [], - previousTop = [], - previousWidth = [], - previousHeight = [], - previousStyles = []; - var len = this.application.ninja.selectedElements.length; - this._targets = []; - for(var i = 0; i < len; i++) { - var elt = this.application.ninja.selectedElements[i]; - - var curMat = viewUtils.getMatrixFromElement(elt); - var curMatInv = glmat4.inverse(curMat, []); - - this._targets.push({elt:elt, mat:curMat, matInv:curMatInv}); - if(addToUndoStack) { - var prevX, - prevY, - prevW, - prevH, - _x, - _y, - _w, - _h, - previousMat, - previousStyleStr, - newStyleStr; - - if(!this._use3DMode) { - prevX = this._undoArray[i]._x; - prevY = this._undoArray[i]._y; - prevW = this._undoArray[i]._w; - prevH = this._undoArray[i]._h; - _x = parseInt(ElementsMediator.getProperty(elt, "left")); - _y = parseInt(ElementsMediator.getProperty(elt, "top")); - _w = parseInt(ElementsMediator.getProperty(elt, "width")); - _h = parseInt(ElementsMediator.getProperty(elt, "height")); - - previousLeft.push(prevX + "px"); - previousTop.push(prevY + "px"); - previousWidth.push(prevW + "px"); - previousHeight.push(prevH + "px"); - newLeft.push(_x + "px"); - newTop.push(_y + "px"); - newWidth.push(_w + "px"); - newHeight.push(_h + "px"); - } - else - { - previousMat = this._undoArray[i].mat.slice(0); - prevW = this._undoArray[i]._w; - prevH = this._undoArray[i]._h; - _w = parseInt(ElementsMediator.getProperty(elt, "width")); - _h = parseInt(ElementsMediator.getProperty(elt, "height")); - previousWidth.push(prevW + "px"); - previousHeight.push(prevH + "px"); - newWidth.push(_w + "px"); - newHeight.push(_h + "px"); - - previousStyleStr = {dist:this._undoArray[i].dist, - mat:MathUtils.scientificToDecimal(previousMat, 5)}; - newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), - mat:MathUtils.scientificToDecimal(curMat, 5)}; - previousStyles.push(previousStyleStr); - newStyles.push(newStyleStr); - - this._targets[i].mat = curMat; - this._targets[i].matInv = curMatInv; + value: function(addToUndo) { + var modObject = [], mod3dObject = [], self = this; + + this.application.ninja.selectedElements.forEach(function(element) { + + if(addToUndo) { + if(!self._use3DMode) { + var prevX = element.elementModel.getProperty("x"); + var prevY = element.elementModel.getProperty("y"); + var prevW = element.elementModel.getProperty("w"); + var prevH = element.elementModel.getProperty("h"); + var x = ElementsMediator.getProperty(element, "left"); + var y = ElementsMediator.getProperty(element, "top"); + var w = ElementsMediator.getProperty(element, "width"); + var h = ElementsMediator.getProperty(element, "height"); + + // if we have a delta, that means the transform handles were used and + // we should update the width and height too. Otherwise, just update left and top. + if(this.delta) { + modObject.push({element:element, properties:{left: x, top:y, width: w, height: h}, previousProperties: {left: prevX, top:prevY, width: prevW, height: prevH}}); + } else { + modObject.push({element:element, properties:{left: x, top:y}, previousProperties: {left: prevX, top:prevY}}); + } + + } else { + // Not using the 3d mode + var previousMat = element.elementModel.getProperty("mat").slice(0); + var prevW = element.elementModel.getProperty("w"); + var prevH = element.elementModel.getProperty("h"); + var w = ElementsMediator.getProperty(element, "width"); + var h = ElementsMediator.getProperty(element, "height"); + + var previousStyleStr = {dist:element.elementModel.getProperty("dist"), mat:MathUtils.scientificToDecimal(previousMat, 5)}; + var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(element), mat:MathUtils.scientificToDecimal(viewUtils.getMatrixFromElement(element), 5)}; + + modObject.push({element:element, properties:{width: w, height:h}, previousProperties: {width: prevW, height:prevH}}); + mod3dObject.push({element:element, properties:newStyleStr, previousProperties: previousStyleStr}); } } - } + }); - if(addToUndoStack) { + // Move them + if(addToUndo) { if(!this._use3DMode) { - // if we have a delta, that means the transform handles were used and - // we should update the width and height too. Otherwise, just update left and top. - if(this._delta) { - ElementsMediator.setProperties(this.application.ninja.selectedElements, {"left": newLeft, "top": newTop, "width": newWidth, "height": newHeight }, - { "left" : previousLeft, "top" : previousTop, "width": previousWidth, "height": previousHeight}, "Change", "selectionTool"); - } else { - ElementsMediator.setProperties(this.application.ninja.selectedElements, {"left": newLeft, "top": newTop }, {"left": previousLeft, "top": previousTop}, "Change", "selectionTool"); - } + ElementsMediator.setProperties(modObject, "Change", "SelectionTool" ); } else { // TODO - We don't support transform handles in 3d space for now - ElementsMediator.setProperties(this.application.ninja.selectedElements, {"width": newWidth, "height": newHeight }, {"width": previousWidth, "height": previousHeight}, "Change", "selectionTool"); - ElementsMediator.set3DProperties(this.application.ninja.selectedElements, newStyles, "Change", "translateTool", previousStyles); + ElementsMediator.setProperties(modObject, "Change", "SelectionTool" ); + ElementsMediator.set3DProperties(mod3dObject, "Change", "translateTool"); + } } - // Save previous value for undo/redo - this._undoArray = []; - for(i = 0, len = this._targets.length; i < len; i++) - { - var item = this._targets[i]; - _x = parseInt(ElementsMediator.getProperty(item.elt, "left")); - _y = parseInt(ElementsMediator.getProperty(item.elt, "top")); - _w = parseInt(ElementsMediator.getProperty(item.elt, "width")); - _h = parseInt(ElementsMediator.getProperty(item.elt, "height")); - var _mat = viewUtils.getMatrixFromElement(item.elt); - var _dist = viewUtils.getPerspectiveDistFromElement(item.elt); - this._undoArray.push({_x:_x, _y:_y, _w:_w, _h:_h, mat:_mat, dist:_dist}); - } + + this.application.ninja.selectedElements.forEach(function(element) { + element.elementModel.setProperty("x", ElementsMediator.getProperty(element, "left")); + element.elementModel.setProperty("y", ElementsMediator.getProperty(element, "top")); + element.elementModel.setProperty("w", ElementsMediator.getProperty(element, "width")); + element.elementModel.setProperty("h", ElementsMediator.getProperty(element, "height")); + element.elementModel.setProperty("mat", viewUtils.getMatrixFromElement(element)); + element.elementModel.setProperty("matInv", glmat4.inverse(element.elementModel.getProperty("mat"), [])); + element.elementModel.setProperty("dist", viewUtils.getPerspectiveDistFromElement(element)); + }); } }, _moveElements: { value: function (transMat) { - var len = this._targets.length, - i, - item, - elt, - curMat, - newLeft = [], - newTop = []; + var elt, curMat, targets = []; - var matInv = glmat4.inverse(this._startMat, []); - var nMat = glmat4.multiply(transMat, this._startMat, [] ); - var qMat = glmat4.multiply(matInv, nMat, []); +// var matInv = glmat4.inverse(this._startMat, []); +// var qMat = glmat4.multiply(matInv, nMat, []); + this._startMat = glmat4.multiply(transMat, this._startMat, [] ); - this._startMat = nMat; + var self = this; - for(i = 0; i < len; i++) - { - item = this._targets[i]; - elt = item.elt; - if(this._use3DMode) - { + this.application.ninja.selectedElements.forEach(function(element) { + if(self._use3DMode) { + curMat = element.elementModel.getProperty("mat"); + + curMat[12] += transMat[12]; + curMat[13] += transMat[13]; + curMat[14] += transMat[14]; + viewUtils.setMatrixForElement( element, curMat, true); + element.elementModel.setProperty("mat", curMat); + } else { + var x = (parseInt(ElementsMediator.getProperty(element, "left")) + transMat[12]) + "px"; + var y = (parseInt(ElementsMediator.getProperty(element, "top")) + transMat[13]) + "px"; + + targets.push({element:element, properties:{left:x , top:y}}); + } + }); + + /* + this._targets.forEach(function(item) { + elt = item.elt; + + if(self._use3DMode) { curMat = item.mat; curMat[12] += transMat[12]; curMat[13] += transMat[13]; curMat[14] += transMat[14]; viewUtils.setMatrixForElement( elt, curMat, true); - this._targets[i].mat = curMat; - } - else - { - var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + transMat[12]; - var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + transMat[13]; + item.mat = curMat; - newLeft.push(_x + "px"); - newTop.push(_y + "px"); + return NJevent("elementChanging", {type : "Changing", redraw: false}); + } else { + var x = (parseInt(ElementsMediator.getProperty(elt, "left")) + transMat[12]) + "px"; + var y = (parseInt(ElementsMediator.getProperty(elt, "top")) + transMat[13]) + "px"; + + targets.push({element:elt, properties:{left:x , top:y}}); } - } + }); + */ - if(newLeft.length) { - ElementsMediator.setProperties(this.application.ninja.selectedElements, {"left": newLeft, "top": newTop }, null, "Changing", "SelectionTool" ); + if(this._use3DMode) { + return NJevent("elementChanging", {type : "Changing", redraw: false}); } else { - NJevent("elementChanging", {type : "Changing", redraw: false}); + ElementsMediator.setProperties(targets, "Changing", "SelectionTool" ); } } }, @@ -457,15 +420,10 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { //------------------------------------------------------------------------- //Routines to modify the selected objects modifyElements : { - value : function(data, e