From 51b4e61d6c6df5e88e9a5dfcdfd7944e2a3f64e7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 30 Jan 2012 13:25:15 -0800 Subject: Syncing stage view when rotating stage. Signed-off-by: Nivesh Rajbhandari --- js/tools/SelectionTool.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 5f2a959f..862b2e88 100644 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -180,7 +180,6 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { this._handleMode = null; this._delta = null; this.DrawHandles(); - console.log( "move: (" + dx + ", " + dy + ")" ); } this.endDraw(event); -- cgit v1.2.3 From d6e80f16b70034ba8cc7193f4359f764ce28f68b Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 30 Jan 2012 16:20:45 -0800 Subject: Forgot to remove a require in previous checkin. Signed-off-by: Nivesh Rajbhandari --- js/tools/drawing-tool-base.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/tools') diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 6fc34911..cd895102 100644 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -10,7 +10,6 @@ var Component = require("montage/ui/component").Component; var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; -var Properties3D = require("js/helper-classes/Properties3D").Properties3D; var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; exports.DrawingToolBase = Montage.create(Montage, { -- cgit v1.2.3 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/tools/PanTool.js | 33 +++++++++++++-------------------- js/tools/ZoomTool.js | 39 ++++++++++----------------------------- 2 files changed, 23 insertions(+), 49 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index ba40b020..71301d46 100644 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js @@ -19,6 +19,7 @@ exports.PanTool = Montage.create(toolBase, _globalPt :{value: [0,0] , writable:true}, _globalToUCWorld :{value: [] , writable:true}, _lastGPt :{value: [0,0], writable:true}, + _lastY :{value: 0, writable:true}, Configure: { value: function ( doActivate ) @@ -43,6 +44,7 @@ exports.PanTool = Montage.create(toolBase, HandleLeftButtonDown: { value : function ( event ) { this._isDrawing = true; + this.isDrawing = true; this.mouseDown( event ); } @@ -68,6 +70,7 @@ exports.PanTool = Montage.create(toolBase, this.application.ninja.stage.clearDrawingCanvas(); this._hasDraw = false; this._isDrawing = false; + this.isDrawing = false; } } }, @@ -77,7 +80,6 @@ exports.PanTool = Montage.create(toolBase, if(event.altKey) { this._altKeyDown = true; - //console.log( "altKeyDown" ); } } }, @@ -87,7 +89,6 @@ exports.PanTool = Montage.create(toolBase, if(event.keyCode === Keyboard.ALT) { this._altKeyDown = false; - console.log( "altKeyUp" ); } } }, @@ -220,6 +221,7 @@ exports.PanTool = Montage.create(toolBase, var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); this._lastGPt = this._globalPt.slice(); + this._lastY = this._lastGPt[1]; // set up the matrices we will be needing var eltToStageWorldMat = glmat4.multiply( ucMat, viewUtils.getObjToStageWorldMatrix(elt, true), []); @@ -275,14 +277,19 @@ exports.PanTool = Montage.create(toolBase, { if (this._isDrawing) { - //console.log( "PanTool.mouseMove (drag)" ); - // get the global screen point var gPt = [point.x, point.y, this._globalPt[2]]; + if (this._altKeyDown) + { + var dy = 5*(point.y - this._lastY); + this._globalPt[2] += dy; + gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; + } // update the scrollbars var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); this._lastGPt = gPt.slice(); + this._lastY = point.y; var oldLeft = this.application.ninja.stage._iframeContainer.scrollLeft, oldTop = this.application.ninja.stage._iframeContainer.scrollTop; @@ -297,27 +304,13 @@ exports.PanTool = Montage.create(toolBase, this.updateGlobalToUCWorldMatrix(); var wPt = MathUtils.transformAndDivideHomogeneousPoint( gPt, this._globalToUCWorld ); - //console.log( "wPt: " + wPt ); var delta = vecUtils.vecSubtract( 3, wPt, this._worldPt ); - if (this._altKeyDown) - { - //console.log( "moveZ" ); - var dist = vecUtils.vecMag(2, delta); - delta[0] = 0; delta[1] = 0; delta[2] = dist; - var dy = point.y - this._globalPt[1]; - if (dy < 0) delta[2] = -delta[2]; - } - else - { - console.log( "NOT MOVING Z" ); + + if (!this._altKeyDown) delta[2] = 0; - } var transMat = Matrix.Translation( delta ); this._worldPt = wPt; - if (this._altKeyDown) - this._globalPt[1] = point.y; - // update everything this.applyDeltaMat( transMat ); } diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js index cabf3a3d..4b6705c1 100644 --- a/js/tools/ZoomTool.js +++ b/js/tools/ZoomTool.js @@ -74,10 +74,12 @@ exports.ZoomTool = Montage.create(DrawingTool, { if(wasSelected) { this.AddCustomFeedback(); this.eventManager.addEventListener( "toolDoubleClick", this, false); + this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false); } else { this.RemoveCustomFeedback(); this.eventManager.removeEventListener( "toolDoubleClick", this, false); + this.application.ninja.stage.drawingCanvas.removeEventListener("mousewheel", this, false); } } }, @@ -138,9 +140,11 @@ exports.ZoomTool = Montage.create(DrawingTool, { { value : function (event) { - // check for some reasonable amount of mouse movement - var dx = Math.abs(event.layerX - this.downPoint.x), - dy = Math.abs(event.layerY - this.downPoint.y); + var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, + new WebKitPoint(event.pageX, event.pageY)); + // check for some reasonable amount of mouse movement + var dx = Math.abs(point.x - this.downPoint.x), + dy = Math.abs(point.y - this.downPoint.y); if ((dx >= 4) || (dy >= 4)) { @@ -238,19 +242,6 @@ exports.ZoomTool = Montage.create(DrawingTool, { var p1 = [this._layerX, this._layerY, 0]; globalPt = vecUtils.vecAdd(3, p0, p1); vecUtils.vecScale(3, globalPt, 0.5); - - var hitRec = snapManager.snap( globalPt[0], globalPt[1], true ); - if (hitRec) - { - var elt = hitRec.getElement(); - if (elt) - { -// console.log( "hit: " + hitRec.getElement().id ); - var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); - var localPt = hitRec.calculateElementPreTransformScreenPoint(); - globalPt = MathUtils.transformAndDivideHomogeneousPoint( localPt, localToGlobalMat ); - } - } } else if (this._mode === "doubleClickReset") { @@ -270,19 +261,9 @@ exports.ZoomTool = Montage.create(DrawingTool, { } else if (this._mode === "mouseWheelZoom") { - 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]; - globalPt = viewUtils.localToGlobal( localPt, userContent ); - } - else - globalPt = [0,0,0]; + var w = this.application.ninja.stage._canvas.width, + h = this.application.ninja.stage._canvas.height; + globalPt = [w/2, h/2, 0]; } else { -- cgit v1.2.3