From 59757653a5c49ac0db45c5d4f93e3493c1f08e44 Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Wed, 29 Feb 2012 13:23:30 -0800 Subject: Squashed commit of the following: commit 2b9f63089534356607ad7e0ddde6f22e42d04f80 Merge: 98d491f a89e30a Author: Valerio Virgillito Date: Wed Feb 29 12:12:11 2012 -0800 Merge pull request #88 from mqg734/ToolFixes Fix for performance issue when moving shapes. commit 98d491f7e57ff5a9b091e332d7d1e81061e39efa Merge: 052d980 d417b33 Author: Valerio Virgillito Date: Wed Feb 29 12:10:57 2012 -0800 Merge branch 'SnapManagerFixes' of https://github.com/mqg734/ninja-internal into integration-candidate commit 052d9805a6f0a3a90d6849eb94eabffb7ec26962 Merge: 3d233f2 2f3e4d1 Author: Valerio Virgillito Date: Wed Feb 29 12:10:03 2012 -0800 Merge branch 'integration-candidate' of github.com:Motorola-Mobility/ninja-internal into integration-candidate commit 3d233f25cff057fff5c5a75e4c4b40e88c22a8f5 Merge: 3dbe798 209e078 Author: Valerio Virgillito Date: Wed Feb 29 12:09:43 2012 -0800 Merge branch 'NiveshColor' of https://github.com/mqg734/ninja-internal into integration-candidate commit 2f3e4d12aa15077d3cc9794862156e57b7815e68 Merge: 850f3a1 0996a51 Author: Valerio Virgillito Date: Wed Feb 29 12:06:21 2012 -0800 Merge pull request #87 from joseeight/FileIO-Build-Candidate Fixes to preview caching issues commit 850f3a1f7ab81ec80b6de1c49f2d2bbcbfe87c8e Merge: 1568367 5f777eb Author: Valerio Virgillito Date: Wed Feb 29 12:05:48 2012 -0800 Merge pull request #86 from imix23ways/Timeline Timeline commit 1568367213e760463f3ee29a531aa345fda6bd6d Merge: 3dbe798 271a8f2 Author: Valerio Virgillito Date: Wed Feb 29 12:03:23 2012 -0800 Merge pull request #85 from pushkarjoshi/brushtool Brushtool commit a89e30ab834a48be32b6122e0c8ac1e0c3ed43e8 Author: Nivesh Rajbhandari Date: Wed Feb 29 11:58:28 2012 -0800 Fix for performance issue when moving shapes. We don't need to call render except if the geometry and materials change. This is more easy to see with shapes like the brush tool. Signed-off-by: Nivesh Rajbhandari commit 271a8f2b29d87d12c81d03e3f1e2c05b816a138d Author: Pushkar Joshi Date: Wed Feb 29 11:50:41 2012 -0800 prevent extremely long path rendering (temporary fix) commit 0996a519afccbed526912807c70c20d598e9cae7 Merge: 98f1cfc 03d277d Author: Jose Antonio Marquez Date: Wed Feb 29 11:46:59 2012 -0800 Merge branch 'refs/heads/FileIO' into FileIO-Build-Candidate commit 03d277db80b6cea9a25320c0575ae2bf7a6d7e6e Author: Jose Antonio Marquez Date: Wed Feb 29 11:46:44 2012 -0800 Preview Fix Adding save all logic before preview, temporary fix. commit 46fb52be241dced940d46629c809a09c86ed4438 Author: Pushkar Joshi Date: Wed Feb 29 11:38:33 2012 -0800 changed the registration point of the brush tool icon and added a temporary check to prevent extremely long brush strokes commit 98f1cfc58f545702a18166ab216362d667c18915 Merge: da83f44 bb3e42b Author: Jose Antonio Marquez Date: Wed Feb 29 11:29:09 2012 -0800 Merge branch 'refs/heads/FileIO' into FileIO-Build-Candidate commit bb3e42b531848b400670df6caf0f3ce02adf1243 Author: Jose Antonio Marquez Date: Wed Feb 29 11:28:58 2012 -0800 Fix: Caching issue with chrome tab API Using window.open to test movie. commit f000a3cced9adbfff1d7aa641e6eb42ad6edf7e8 Author: Pushkar Joshi Date: Wed Feb 29 10:21:06 2012 -0800 change in comment only commit 795329d2225ff3b760f7f0ea3bb6b5e68f6c6b5b Author: Jose Antonio Marquez Date: Wed Feb 29 10:07:53 2012 -0800 Making class level url template variable Created a class level variable for the URL to be parsed out of the user files. commit f931c48a7d0bcf1222cf05787e3294839ed0b9fb Author: Pushkar Joshi Date: Wed Feb 29 09:47:41 2012 -0800 resample the brush stroke so we don't have gaps if the path is drawn rapidly, and, allow to change the stroke color, and, more efficient stroke rendering by drawing translated radial gradients (instead of creating new gradients for each stroke sample) commit d417b3315f1aa6dd52fea10cbf5f17a213ef8726 Author: Nivesh Rajbhandari Date: Wed Feb 29 06:50:51 2012 -0800 SnapManager fixes for sag tags. Signed-off-by: Nivesh Rajbhandari commit 209e0781e926212bbaaad9e8ca4b61a0c389b30f Author: Nivesh Rajbhandari Date: Tue Feb 28 17:19:42 2012 -0800 We need to remove color buttons from the color model when updating the PI for selection change. Signed-off-by: Nivesh Rajbhandari commit b43efdcbfa671a46d1edaeb1555f508fe2ad0338 Merge: 16d6a90 f2ab699 Author: Pushkar Joshi Date: Tue Feb 28 14:55:08 2012 -0800 Merge branch 'pentool' into brushtool commit 16d6a90579cdafede931a9c818689fad2e622d8b Merge: 03ca7a5 63307c9 Author: Pushkar Joshi Date: Tue Feb 28 14:19:25 2012 -0800 Merge branch 'pentool' into brushtool commit 03ca7a5ed13c25faaa9100bb666e062fd15335e6 Merge: fcb12cc 053fc63 Author: Pushkar Joshi Date: Fri Feb 24 12:08:49 2012 -0800 Merge branch 'pentool' into brushtool Conflicts: imports/codemirror/mode/scheme/scheme.js js/tools/BrushTool.js commit fcb12cc09eb3cd3b42bd215877ba18f449275b75 Author: Pushkar Joshi Date: Fri Feb 10 14:16:56 2012 -0800 render the brush stroke as a sequence of rectangles, with each rectangle having its own linear gradient commit 6bb00e69713bd7131b2bc0a15e4e0cb6071d616c Merge: 5f42bd1 666ae3e Author: Pushkar Joshi Date: Thu Feb 9 13:42:59 2012 -0800 Merge branch 'master' into brushtool commit 5f42bd1f7723483d374cdd3fe51ef8298c86a1a2 Merge: abeb9f1 fba39db Author: Pushkar Joshi Date: Thu Feb 9 10:55:58 2012 -0800 Merge branch 'pentool' into brushtool commit abeb9f1e23679200bb2f4a3ccbcebfb37645975c Author: Pushkar Joshi Date: Thu Feb 9 10:45:50 2012 -0800 first phase of simple resampling to prevent tiny segments Signed-off-by: Jonathan Duran --- js/tools/BrushTool.js | 194 ++++++++++++++++++++++++---------------------- js/tools/SelectionTool.js | 16 +++- 2 files changed, 117 insertions(+), 93 deletions(-) mode change 100755 => 100644 js/tools/BrushTool.js (limited to 'js/tools') diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js old mode 100755 new mode 100644 index 4d44326f..fec89eb2 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js @@ -64,13 +64,40 @@ exports.BrushTool = Montage.create(ShapeTool, { //start a new brush stroke if (this._selectedBrushStroke === null){ this._selectedBrushStroke = new GLBrushStroke(); + if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ + this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); + } + //add this point to the brush stroke in case the user does a mouse up before doing a mouse move + var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); + this._selectedBrushStroke.addPoint(currMousePos); + + //TODO get these values from the options + this._selectedBrushStroke.setStrokeWidth(20); } - console.log("BrushTool Start"); NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove(); } //value: function (event) { }, //HandleLeftButtonDown + _getUnsnappedPosition: { + value: function(x,y){ + var elemSnap = snapManager.elementSnapEnabled(); + var gridSnap = snapManager.gridSnapEnabled(); + var alignSnap = snapManager.snapAlignEnabled(); + + snapManager.enableElementSnap(false); + snapManager.enableGridSnap(false); + snapManager.enableSnapAlign(false); + var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); + var unsnappedpos = DrawingToolBase.getHitRecPos(snapManager.snap(point.x, point.y, false)); + + snapManager.enableElementSnap(elemSnap); + snapManager.enableGridSnap(gridSnap); + snapManager.enableSnapAlign(alignSnap); + + return unsnappedpos; + } + }, //need to override this function because the ShapeTool's definition contains a clearDrawingCanvas call - Pushkar // might not need to override once we draw using OpenGL instead of SVG // Also took out all the snapping code for now...need to add that back @@ -84,20 +111,10 @@ exports.BrushTool = Montage.create(ShapeTool, { } if (this._isDrawing) { - snapManager.enableElementSnap(false); - snapManager.enableGridSnap(false); - snapManager.enableSnapAlign(false); - //this.doDraw(event); - //var currMousePos = this.getMouseUpPos(); - //instead of doDraw call own DrawingTool - var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); - var hitRecSnapPoint = DrawingToolBase.getUpdatedSnapPointNoAppLevelEnabling(point.x, point.y, true, this.mouseDownHitRec); - var currMousePos = DrawingToolBase.getHitRecPos(hitRecSnapPoint); - - if (this._selectedBrushStroke){ + var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); + if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()<100){ this._selectedBrushStroke.addPoint(currMousePos); } - this.ShowCurrentBrushStrokeOnStage(); } //if (this._isDrawing) { @@ -123,12 +140,8 @@ exports.BrushTool = Montage.create(ShapeTool, { this._isDrawing = false; this._hasDraw = false; - console.log("BrushTool Stop"); - //TODO get these values from the options - if (this._selectedBrushStroke){ - this._selectedBrushStroke.setStrokeWidth(20); - } + //display the previously drawn stroke in a separate canvas this.RenderCurrentBrushStroke(); @@ -143,7 +156,7 @@ exports.BrushTool = Montage.create(ShapeTool, { //clear the canvas before we draw anything else this.application.ninja.stage.clearDrawingCanvas(); if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()>0){ - this._selectedBrushStroke.computeMetaGeometry(); + //this._selectedBrushStroke.computeMetaGeometry(); var ctx = this.application.ninja.stage.drawingContext;//stageManagerModule.stageManager.drawingContext; if (ctx === null) throw ("null drawing context in Brushtool::ShowCurrentBrushStrokeOnStage"); @@ -192,92 +205,89 @@ exports.BrushTool = Montage.create(ShapeTool, { RenderShape: { - value: function (w, h, planeMat, midPt, canvas) { - if ((Math.floor(w) === 0) || (Math.floor(h) === 0)) { - return; - } + value: function (w, h, planeMat, midPt, canvas) { + if ((Math.floor(w) === 0) || (Math.floor(h) === 0)) { + return; + } - var left = Math.round(midPt[0] - 0.5 * w); - var top = Math.round(midPt[1] - 0.5 * h); + var left = Math.round(midPt[0] - 0.5 * w); + var top = Math.round(midPt[1] - 0.5 * h); - if (!canvas) { + if (!canvas) { var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas); - ElementMediator.addElement(newCanvas, elementModel.data, true); - - // create all the GL stuff - var world = this.getGLWorld(newCanvas, this._useWebGL); - //store a reference to this newly created canvas - this._brushStrokeCanvas = newCanvas; - - var brushStroke = this._selectedBrushStroke; - if (brushStroke){ - brushStroke.setWorld(world); - - brushStroke.setPlaneMatrix(planeMat); - var planeMatInv = glmat4.inverse( planeMat, [] ); - brushStroke.setPlaneMatrixInverse(planeMatInv); - brushStroke.setPlaneCenter(midPt); - - world.addObject(brushStroke); - world.render(); - //TODO this will not work if there are multiple shapes in the same canvas - newCanvas.elementModel.shapeModel.GLGeomObj = brushStroke; - } - } //if (!canvas) { - else { - - var world = null; - if (canvas.elementModel.shapeModel && canvas.elementModel.shapeModel.GLWorld) { - world = canvas.elementModel.shapeModel.GLWorld; - } else { - world = this.getGLWorld(canvas, this._useWebGL);//this.options.use3D);//this.CreateGLWorld(planeMat, midPt, canvas, this._useWebGL);//fillMaterial, strokeMaterial); - } + var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas); + ElementMediator.addElement(newCanvas, elementModel.data, true); + + // create all the GL stuff + var world = this.getGLWorld(newCanvas, this._useWebGL); + //store a reference to this newly created canvas + this._brushStrokeCanvas = newCanvas; + + var brushStroke = this._selectedBrushStroke; + if (brushStroke){ + brushStroke.setWorld(world); + + brushStroke.setPlaneMatrix(planeMat); + var planeMatInv = glmat4.inverse( planeMat, [] ); + brushStroke.setPlaneMatrixInverse(planeMatInv); + brushStroke.setPlaneCenter(midPt); + + world.addObject(brushStroke); + world.render(); + //TODO this will not work if there are multiple shapes in the same canvas + newCanvas.elementModel.shapeModel.GLGeomObj = brushStroke; + } + } //if (!canvas) { + else { + + var world = null; + if (canvas.elementModel.shapeModel && canvas.elementModel.shapeModel.GLWorld) { + world = canvas.elementModel.shapeModel.GLWorld; + } else { + world = this.getGLWorld(canvas, this._useWebGL); + } - if (this._entryEditMode !== this.ENTRY_SELECT_CANVAS){ - //update the left and top of the canvas element - var canvasArray=[canvas]; - ElementMediator.setProperty(canvasArray, "left", [parseInt(left)+"px"],"Changing", "brushTool"); - ElementMediator.setProperty(canvasArray, "top", [parseInt(top) + "px"],"Changing", "brushTool"); - canvas.width = w; - canvas.height = h; - //update the viewport and projection to reflect the new canvas width and height - world.setViewportFromCanvas(canvas); - if (this._useWebGL){ - var cam = world.renderer.cameraManager().getActiveCamera(); - cam.setPerspective(world.getFOV(), world.getAspect(), world.getZNear(), world.getZFar()); + if (this._entryEditMode !== this.ENTRY_SELECT_CANVAS){ + //update the left and top of the canvas element + var canvasArray=[canvas]; + ElementMediator.setProperty(canvasArray, "left", [parseInt(left)+"px"],"Changing", "brushTool"); + ElementMediator.setProperty(canvasArray, "top", [parseInt(top) + "px"],"Changing", "brushTool"); + canvas.width = w; + canvas.height = h; + //update the viewport and projection to reflect the new canvas width and height + world.setViewportFromCanvas(canvas); + if (this._useWebGL){ + var cam = world.renderer.cameraManager().getActiveCamera(); + cam.setPerspective(world.getFOV(), world.getAspect(), world.getZNear(), world.getZFar()); + } } - } - var brushStroke = this._selectedBrushStroke; + var brushStroke = this._selectedBrushStroke; - if (brushStroke){ - brushStroke.setDrawingTool(this); + if (brushStroke){ + brushStroke.setDrawingTool(this); - brushStroke.setPlaneMatrix(planeMat); - var planeMatInv = glmat4.inverse( planeMat, [] ); - brushStroke.setPlaneMatrixInverse(planeMatInv); - brushStroke.setPlaneCenter(midPt); + brushStroke.setPlaneMatrix(planeMat); + var planeMatInv = glmat4.inverse( planeMat, [] ); + brushStroke.setPlaneMatrixInverse(planeMatInv); + brushStroke.setPlaneCenter(midPt); - brushStroke.setWorld(world); - world.addIfNewObject(brushStroke); - //world.addObject(subpath); - world.render(); - //TODO this will not work if there are multiple shapes in the same canvas - canvas.elementModel.shapeModel.GLGeomObj = brushStroke; - } - } //else of if (!canvas) { - } //value: function (w, h, planeMat, midPt, canvas) { - }, //RenderShape: { + brushStroke.setWorld(world); + world.addIfNewObject(brushStroke); + //world.addObject(subpath); + world.render(); + //TODO this will not work if there are multiple shapes in the same canvas + canvas.elementModel.shapeModel.GLGeomObj = brushStroke; + } + } //else of if (!canvas) { + } //value: function (w, h, planeMat, midPt, canvas) { + }, //RenderShape: { + Configure: { value: function (wasSelected) { if (wasSelected) { - console.log("Picked BrushTool"); - //todo these calls have no effect because the drawing-tool-base (in getInitialSnapPoint) overrides them with what's set at the application level - snapManager.enableElementSnap(false); - snapManager.enableGridSnap(false); - snapManager.enableSnapAlign(false); + console.log("Entered BrushTool"); } else { console.log("Left BrushTool"); diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 83d52d52..caa9e8d6 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -312,12 +312,26 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { } if(addToUndoStack) { - ElementsMediator.setProperties(this.application.ninja.selectedElements, + // 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 } + ); + } } // Save previous value for undo/redo this._undoArray = []; -- cgit v1.2.3