diff options
author | Pushkar Joshi | 2012-02-02 11:28:45 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-02-02 11:28:45 -0800 |
commit | acc500d1f1c76f4e7c93ae1cfea8d925ca95e7b9 (patch) | |
tree | 877f8ca734228c11050b037ce82fc0d1e1303193 /js/tools | |
parent | 4d4de64472603426a73b26cc98ba8206190949b8 (diff) | |
parent | 4222db97e353fb65fab787ba5927d16d9fa4e1f7 (diff) | |
download | ninja-acc500d1f1c76f4e7c93ae1cfea8d925ca95e7b9.tar.gz |
Merge branch 'working' of c:/Code/github/emueller/ninja-internal/ into pentool
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/PanTool.js | 31 | ||||
-rw-r--r-- | js/tools/SelectionTool.js | 1 | ||||
-rw-r--r-- | js/tools/ZoomTool.js | 31 | ||||
-rw-r--r-- | js/tools/drawing-tool-base.js | 1 |
4 files changed, 18 insertions, 46 deletions
diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index ba40b020..55a03674 100644 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js | |||
@@ -19,6 +19,7 @@ exports.PanTool = Montage.create(toolBase, | |||
19 | _globalPt :{value: [0,0] , writable:true}, | 19 | _globalPt :{value: [0,0] , writable:true}, |
20 | _globalToUCWorld :{value: [] , writable:true}, | 20 | _globalToUCWorld :{value: [] , writable:true}, |
21 | _lastGPt :{value: [0,0], writable:true}, | 21 | _lastGPt :{value: [0,0], writable:true}, |
22 | _lastY :{value: 0, writable:true}, | ||
22 | 23 | ||
23 | Configure: { | 24 | Configure: { |
24 | value: function ( doActivate ) | 25 | value: function ( doActivate ) |
@@ -43,6 +44,7 @@ exports.PanTool = Montage.create(toolBase, | |||
43 | HandleLeftButtonDown: { | 44 | HandleLeftButtonDown: { |
44 | value : function ( event ) { | 45 | value : function ( event ) { |
45 | this._isDrawing = true; | 46 | this._isDrawing = true; |
47 | this.isDrawing = true; | ||
46 | 48 | ||
47 | this.mouseDown( event ); | 49 | this.mouseDown( event ); |
48 | } | 50 | } |
@@ -68,6 +70,7 @@ exports.PanTool = Montage.create(toolBase, | |||
68 | this.application.ninja.stage.clearDrawingCanvas(); | 70 | this.application.ninja.stage.clearDrawingCanvas(); |
69 | this._hasDraw = false; | 71 | this._hasDraw = false; |
70 | this._isDrawing = false; | 72 | this._isDrawing = false; |
73 | this.isDrawing = false; | ||
71 | } | 74 | } |
72 | } | 75 | } |
73 | }, | 76 | }, |
@@ -220,6 +223,7 @@ exports.PanTool = Montage.create(toolBase, | |||
220 | var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); | 223 | var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); |
221 | 224 | ||
222 | this._lastGPt = this._globalPt.slice(); | 225 | this._lastGPt = this._globalPt.slice(); |
226 | this._lastY = this._lastGPt[1]; | ||
223 | 227 | ||
224 | // set up the matrices we will be needing | 228 | // set up the matrices we will be needing |
225 | var eltToStageWorldMat = glmat4.multiply( ucMat, viewUtils.getObjToStageWorldMatrix(elt, true), []); | 229 | var eltToStageWorldMat = glmat4.multiply( ucMat, viewUtils.getObjToStageWorldMatrix(elt, true), []); |
@@ -275,14 +279,19 @@ exports.PanTool = Montage.create(toolBase, | |||
275 | { | 279 | { |
276 | if (this._isDrawing) | 280 | if (this._isDrawing) |
277 | { | 281 | { |
278 | //console.log( "PanTool.mouseMove (drag)" ); | ||
279 | |||
280 | // get the global screen point | 282 | // get the global screen point |
281 | var gPt = [point.x, point.y, this._globalPt[2]]; | 283 | var gPt = [point.x, point.y, this._globalPt[2]]; |
284 | if (this._altKeyDown) | ||
285 | { | ||
286 | var dy = 5*(point.y - this._lastY); | ||
287 | this._globalPt[2] += dy; | ||
288 | gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; | ||
289 | } | ||
282 | 290 | ||
283 | // update the scrollbars | 291 | // update the scrollbars |
284 | var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); | 292 | var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); |
285 | this._lastGPt = gPt.slice(); | 293 | this._lastGPt = gPt.slice(); |
294 | this._lastY = point.y; | ||
286 | 295 | ||
287 | var oldLeft = this.application.ninja.stage._iframeContainer.scrollLeft, | 296 | var oldLeft = this.application.ninja.stage._iframeContainer.scrollLeft, |
288 | oldTop = this.application.ninja.stage._iframeContainer.scrollTop; | 297 | oldTop = this.application.ninja.stage._iframeContainer.scrollTop; |
@@ -297,27 +306,13 @@ exports.PanTool = Montage.create(toolBase, | |||
297 | this.updateGlobalToUCWorldMatrix(); | 306 | this.updateGlobalToUCWorldMatrix(); |
298 | 307 | ||
299 | var wPt = MathUtils.transformAndDivideHomogeneousPoint( gPt, this._globalToUCWorld ); | 308 | var wPt = MathUtils.transformAndDivideHomogeneousPoint( gPt, this._globalToUCWorld ); |
300 | //console.log( "wPt: " + wPt ); | ||
301 | var delta = vecUtils.vecSubtract( 3, wPt, this._worldPt ); | 309 | var delta = vecUtils.vecSubtract( 3, wPt, this._worldPt ); |
302 | if (this._altKeyDown) | 310 | |
303 | { | 311 | if (!this._altKeyDown) |
304 | //console.log( "moveZ" ); | ||
305 | var dist = vecUtils.vecMag(2, delta); | ||
306 | delta[0] = 0; delta[1] = 0; delta[2] = dist; | ||
307 | var dy = point.y - this._globalPt[1]; | ||
308 | if (dy < 0) delta[2] = -delta[2]; | ||
309 | } | ||
310 | else | ||
311 | { | ||
312 | console.log( "NOT MOVING Z" ); | ||
313 | delta[2] = 0; | 312 | delta[2] = 0; |
314 | } | ||
315 | var transMat = Matrix.Translation( delta ); | 313 | var transMat = Matrix.Translation( delta ); |
316 | this._worldPt = wPt; | 314 | this._worldPt = wPt; |
317 | 315 | ||
318 | if (this._altKeyDown) | ||
319 | this._globalPt[1] = point.y; | ||
320 | |||
321 | // update everything | 316 | // update everything |
322 | this.applyDeltaMat( transMat ); | 317 | this.applyDeltaMat( transMat ); |
323 | } | 318 | } |
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, { | |||
180 | this._handleMode = null; | 180 | this._handleMode = null; |
181 | this._delta = null; | 181 | this._delta = null; |
182 | this.DrawHandles(); | 182 | this.DrawHandles(); |
183 | console.log( "move: (" + dx + ", " + dy + ")" ); | ||
184 | } | 183 | } |
185 | 184 | ||
186 | this.endDraw(event); | 185 | this.endDraw(event); |
diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js index cabf3a3d..73297d16 100644 --- a/js/tools/ZoomTool.js +++ b/js/tools/ZoomTool.js | |||
@@ -74,10 +74,12 @@ exports.ZoomTool = Montage.create(DrawingTool, { | |||
74 | if(wasSelected) { | 74 | if(wasSelected) { |
75 | this.AddCustomFeedback(); | 75 | this.AddCustomFeedback(); |
76 | this.eventManager.addEventListener( "toolDoubleClick", this, false); | 76 | this.eventManager.addEventListener( "toolDoubleClick", this, false); |
77 | this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false); | ||
77 | 78 | ||
78 | } else { | 79 | } else { |
79 | this.RemoveCustomFeedback(); | 80 | this.RemoveCustomFeedback(); |
80 | this.eventManager.removeEventListener( "toolDoubleClick", this, false); | 81 | this.eventManager.removeEventListener( "toolDoubleClick", this, false); |
82 | this.application.ninja.stage.drawingCanvas.removeEventListener("mousewheel", this, false); | ||
81 | } | 83 | } |
82 | } | 84 | } |
83 | }, | 85 | }, |
@@ -238,19 +240,6 @@ exports.ZoomTool = Montage.create(DrawingTool, { | |||
238 | var p1 = [this._layerX, this._layerY, 0]; | 240 | var p1 = [this._layerX, this._layerY, 0]; |
239 | globalPt = vecUtils.vecAdd(3, p0, p1); | 241 | globalPt = vecUtils.vecAdd(3, p0, p1); |
240 | vecUtils.vecScale(3, globalPt, 0.5); | 242 | vecUtils.vecScale(3, globalPt, 0.5); |
241 | |||
242 | var hitRec = snapManager.snap( globalPt[0], globalPt[1], true ); | ||
243 | if (hitRec) | ||
244 | { | ||
245 | var elt = hitRec.getElement(); | ||
246 | if (elt) | ||
247 | { | ||
248 | // console.log( "hit: " + hitRec.getElement().id ); | ||
249 | var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); | ||
250 | var localPt = hitRec.calculateElementPreTransformScreenPoint(); | ||
251 | globalPt = MathUtils.transformAndDivideHomogeneousPoint( localPt, localToGlobalMat ); | ||
252 | } | ||
253 | } | ||
254 | } | 243 | } |
255 | else if (this._mode === "doubleClickReset") | 244 | else if (this._mode === "doubleClickReset") |
256 | { | 245 | { |
@@ -270,19 +259,9 @@ exports.ZoomTool = Montage.create(DrawingTool, { | |||
270 | } | 259 | } |
271 | else if (this._mode === "mouseWheelZoom") | 260 | else if (this._mode === "mouseWheelZoom") |
272 | { | 261 | { |
273 | if (userContent) | 262 | var w = this.application.ninja.stage._canvas.width, |
274 | { | 263 | h = this.application.ninja.stage._canvas.height; |
275 | var w = userContent.offsetWidth, | 264 | globalPt = [w/2, h/2, 0]; |
276 | h = userContent.offsetHeight; | ||
277 | if(userContent.width) | ||
278 | w = userContent.width; | ||
279 | if(userContent.height) | ||
280 | h = userContent.height; | ||
281 | var localPt = [ w/2, h/2, 0]; | ||
282 | globalPt = viewUtils.localToGlobal( localPt, userContent ); | ||
283 | } | ||
284 | else | ||
285 | globalPt = [0,0,0]; | ||
286 | } | 265 | } |
287 | else | 266 | else |
288 | { | 267 | { |
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; | |||
10 | var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; | 10 | var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; |
11 | var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; | 11 | var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; |
12 | var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; | 12 | var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; |
13 | var Properties3D = require("js/helper-classes/Properties3D").Properties3D; | ||
14 | var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; | 13 | var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; |
15 | 14 | ||
16 | exports.DrawingToolBase = Montage.create(Montage, { | 15 | exports.DrawingToolBase = Montage.create(Montage, { |