From d41dee0c552a30724a146965ae4272a268777fc5 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 2 Feb 2012 14:53:14 -0800 Subject: Integrating Pan and Zoom tool and snap manager fixes. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 51 ++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'js/stage/stage.reel/stage.js') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 8c4efd58..9e2df5a2 100644 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -787,14 +787,9 @@ exports.Stage = Montage.create(Component, { var userContent = this.application.ninja.currentDocument.documentRoot; if (userContent) { - var w = userContent.offsetWidth, - h = userContent.offsetHeight; - if(userContent.width) - w = userContent.width; - if(userContent.height) - h = userContent.height; - var localPt = [ w/2, h/2, 0]; - var globalPt = this.stageDeps.viewUtils.localToGlobal( localPt, userContent ); + var w = this._canvas.width, + h = this._canvas.height; + var globalPt = [w/2, h/2, 0]; this.stageDeps.viewUtils.setStageZoom( globalPt, value/100 ); @@ -811,6 +806,36 @@ exports.Stage = Montage.create(Component, { } }, + getPlaneForView: + { + value: function( side ) + { + var plane = [0,0,1,0]; + switch(side) + { + case "top": + plane = [0,1,0,0]; + plane[3] = this.application.ninja.currentDocument.documentRoot.offsetHeight / 2.0; + break; + + case "side": + plane = [1,0,0,0]; + plane[3] = this.application.ninja.currentDocument.documentRoot.offsetWidth / 2.0; + break; + + case "front": + plane = [0,0,1,0]; + break; + + default: + console.log( "unrecognized view in snapManager.getPlaneForView: " + side ); + break; + } + + return plane; + } + }, + setStageView: { value: function(side) { var mat, @@ -821,32 +846,26 @@ exports.Stage = Montage.create(Component, { currentDoc.elementModel.props3D.ResetRotationValues(); - switch(side) { + switch(side){ case "top": mat = Matrix.RotationX(Math.PI * 270.0/180.0); - drawUtils.drawXY = drawUtils.drawYZ = false; drawUtils.drawXZ = isDrawingGrid; - workingPlane = [0,1,0,0]; break; case "side": mat = Matrix.RotationY(Math.PI * 270/180); - drawUtils.drawXY = drawUtils.drawXZ = false; drawUtils.drawYZ = isDrawingGrid; - workingPlane = [1,0,0,0]; break; case "front": mat = Matrix.I(4); - drawUtils.drawYZ = drawUtils.drawXZ = false; drawUtils.drawXY = isDrawingGrid; - workingPlane = [0,0,1,0]; break; } - + workingPlane = this.getPlaneForView( side ); this.stageDeps.viewUtils.setMatrixForElement(currentDoc, mat, false); -- cgit v1.2.3