From 0f2b7cf2e1aae16e3cf4e699ab7e3ca83deb1529 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 23 Apr 2012 11:32:15 -0700 Subject: limits --- js/tools/PanTool.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index 0537a27b..ce7606a1 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js @@ -331,10 +331,26 @@ exports.PanTool = Montage.create(toolBase, if (!this._altKeyDown) delta[2] = 0; - var transMat = Matrix.Translation( delta ); - this._worldPt = wPt; + + // limit the change + var ucMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.documentRoot); + var tooMuch = false + if ((ucMat[12] > 12000) && (delta[0] > 0)) tooMuch = true; + if ((ucMat[12] < -12000) && (delta[0] < 0)) tooMuch = true; + if ((ucMat[13] > 12000) && (delta[1] > 0)) tooMuch = true; + if ((ucMat[13] < -12000) && (delta[1] < 0)) tooMuch = true; + if ((ucMat[14] > 12000) && (delta[2] > 0)) tooMuch = true; + if ((ucMat[14] < -12000) && (delta[2] < 0)) tooMuch = true; + if (tooMuch) + { + this._isDrawing = false; + delta = [0,0,0]; + } + else + this._worldPt = wPt; // update everything + var transMat = Matrix.Translation( delta ); this.applyDeltaMat( transMat ); } } -- cgit v1.2.3 From 27c1ba250a7db26cf24dd456d20af9ff1649e638 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 23 Apr 2012 17:04:48 -0700 Subject: canvas interaction --- js/tools/OvalTool.js | 2 +- js/tools/ShapeTool.js | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'js/tools') diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index e8e88d1d..6edec811 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js @@ -66,7 +66,7 @@ exports.OvalTool = Montage.create(ShapeTool, { var world = this.getGLWorld(canvas, this.options.use3D); var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); - var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); + var yOffset = -(canvas.height/2 - (top - canvas.offsetTop + h/2)); var oval = new Circle(); //GLCircle(); oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index f3b5e92d..b2948fe7 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -54,9 +54,9 @@ exports.ShapeTool = Montage.create(DrawingTool, { }, HandleLeftButtonUp: - { - value: function (event) - { + { + value: function (event) + { var drawData; drawData = this.getDrawingData(); @@ -69,24 +69,26 @@ exports.ShapeTool = Montage.create(DrawingTool, { drawData.planeMat, drawData.midPt, canvas, true); canvas.elementModel.isShape = true; - this.application.ninja.elementMediator.addElements(canvas, elementModel.data); } else { canvas = this._targetedElement; + if (!canvas.getAttribute( "data-RDGE-id" )) + canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() ); canvas.elementModel.controller = ShapesController; if(!canvas.elementModel.shapeModel) { canvas.elementModel.shapeModel = Montage.create(ShapeModel); } } + this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data); } - this.endDraw(event); + this.endDraw(event); - this._isDrawing = false; - this._hasDraw=false; + this._isDrawing = false; + this._hasDraw=false; - this.DrawHandles(); - } - }, + this.DrawHandles(); + } + }, onAddElements: { value: function(el) { -- cgit v1.2.3 From 4b83774cdbfbf30add9a8fa2f11b1c4ff35179fa Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 26 Apr 2012 12:50:57 -0700 Subject: canvas interaction --- js/tools/ShapeTool.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index b2948fe7..74e692b6 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -69,6 +69,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { drawData.planeMat, drawData.midPt, canvas, true); canvas.elementModel.isShape = true; + this.application.ninja.elementMediator.addElements(canvas, elementModel.data); } else { canvas = this._targetedElement; if (!canvas.getAttribute( "data-RDGE-id" )) @@ -77,8 +78,8 @@ exports.ShapeTool = Montage.create(DrawingTool, { if(!canvas.elementModel.shapeModel) { canvas.elementModel.shapeModel = Montage.create(ShapeModel); } + this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data); } - this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data); } this.endDraw(event); @@ -213,7 +214,20 @@ exports.ShapeTool = Montage.create(DrawingTool, { _useExistingCanvas: { value: function() { - return (this._targetedElement && !ShapesController.isElementAShape(this._targetedElement)); + var target; + if (this._targetedElement && (this._targetedElement.nodeName === "CANVAS") && !ShapesController.isElementAShape(this._targetedElement)) + target = this._targetedElement; + else + { + var container = this.application.ninja.currentSelectedContainer; + if (container && (container.nodeName === "CANVAS")) + { + target = container; + this._targetedElement = target; + } + } + + return target; } } -- cgit v1.2.3 From e73fba18b095f0c270f5d954e5993c155b488c73 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 27 Apr 2012 13:52:40 -0700 Subject: Creating shapes in a container --- js/tools/SelectionTool.js | 2 ++ js/tools/ShapeTool.js | 2 ++ js/tools/drawing-tool-base.js | 13 +++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 7033ee3d..9c9aee93 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -222,8 +222,10 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { value: function(event) { if(this.application.ninja.selectedElements.length > 0) { this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0]; + console.log( "setting container to selected element" ); } else { this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot; + console.log( "setting container to stage" ); } } }, diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 74e692b6..90b403a4 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -64,6 +64,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { if(drawData) { var canvas; if(!this._useExistingCanvas()) { + console.log( "creating a new canvas" ); canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, drawData.planeMat, drawData.midPt, canvas, true); @@ -71,6 +72,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { canvas.elementModel.isShape = true; this.application.ninja.elementMediator.addElements(canvas, elementModel.data); } else { + console.log( "inserting shape into container" ); canvas = this._targetedElement; if (!canvas.getAttribute( "data-RDGE-id" )) canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() ); diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 2283dfab..0b51aa28 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -41,11 +41,20 @@ exports.DrawingToolBase = Montage.create(Montage, { // do the snap var hitRec = snapManager.snap(x, y, true); + var dragPlane; if (hitRec) { // set up the working plane and convert the hit record to be working plane relative - var dragPlane = snapManager.setupDragPlanes( hitRec ); - var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); + if (hitRec.getElement() === snapManager.application.ninja.currentSelectedContainer) + { + dragPlane = viewUtils.getUnprojectedElementPlane( hitRec.getElement() ); + snapManager.setupDragPlaneFromPlane( dragPlane ); + } + else + { + dragPlane = snapManager.setupDragPlanes( hitRec ); + } + var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); var pt = hitRec.getScreenPoint(); return( [wpHitRec, pt[0], pt[1]] ); -- cgit v1.2.3 From 48e442977ef1630e0f664265a7142320b55d7d20 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 27 Apr 2012 14:35:01 -0700 Subject: added a console.log to show the working plane during a drag --- js/tools/drawing-tool-base.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/tools') diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 0b51aa28..2e652d42 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -53,6 +53,7 @@ exports.DrawingToolBase = Montage.create(Montage, { { dragPlane = snapManager.setupDragPlanes( hitRec ); } + console.log( "drag plane: " + dragPlane ); var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); var pt = hitRec.getScreenPoint(); -- cgit v1.2.3 From 9c8fbdd11fdbe9ae73d57147de84b799c5a87652 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 30 Apr 2012 16:15:47 -0700 Subject: Squashed commit of stage architecture Signed-off-by: Valerio Virgillito --- js/tools/SelectionTool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 9c9aee93..f7b583b5 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -753,10 +753,10 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { var zoomFactor = 1; var viewPort = this.application.ninja.stage._viewport; - if (viewPort.style && viewPort.style.zoom) - { + if (viewPort && viewPort.style && viewPort.style.zoom) { zoomFactor = Number(viewPort.style.zoom); } + var tmpMat = viewUtils.getLocalToGlobalMatrix( item ); for (var j=0; j<4; j++) { @@ -865,7 +865,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { var zoomFactor = 1; var viewPort = this.application.ninja.stage._viewport; - if (viewPort.style && viewPort.style.zoom) + if (viewPort && viewPort.style && viewPort.style.zoom) { zoomFactor = Number(viewPort.style.zoom); } -- cgit v1.2.3 From fb47c04b0a4d65f53d975311754aa0dd8a8a3f69 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 30 Apr 2012 16:31:37 -0700 Subject: Removing some console logs Signed-off-by: Valerio Virgillito --- js/tools/SelectionTool.js | 2 -- js/tools/ShapeTool.js | 2 -- js/tools/drawing-tool-base.js | 1 - 3 files changed, 5 deletions(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index f7b583b5..855c7b8c 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -222,10 +222,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { value: function(event) { if(this.application.ninja.selectedElements.length > 0) { this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0]; - console.log( "setting container to selected element" ); } else { this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot; - console.log( "setting container to stage" ); } } }, diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index c0681200..8f45891d 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -64,7 +64,6 @@ exports.ShapeTool = Montage.create(DrawingTool, { if(drawData) { var canvas; if(!this._useExistingCanvas()) { - console.log( "creating a new canvas" ); canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, drawData.planeMat, drawData.midPt, canvas, true); @@ -72,7 +71,6 @@ exports.ShapeTool = Montage.create(DrawingTool, { canvas.elementModel.isShape = true; this.application.ninja.elementMediator.addElements(canvas, elementModel.data); } else { - console.log( "inserting shape into container" ); canvas = this._targetedElement; if (!canvas.getAttribute( "data-RDGE-id" )) canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() ); diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 2e652d42..0b51aa28 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -53,7 +53,6 @@ exports.DrawingToolBase = Montage.create(Montage, { { dragPlane = snapManager.setupDragPlanes( hitRec ); } - console.log( "drag plane: " + dragPlane ); var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); var pt = hitRec.getScreenPoint(); -- cgit v1.2.3