From 3987b73569e58843f2a91c0c6c4e4132f51ac247 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 21 Mar 2012 17:13:56 -0700 Subject: Do not set webkit-transform styles on elements unless 3d is used on them. Signed-off-by: Nivesh Rajbhandari --- js/tools/SelectionTool.js | 47 ++++++++++++++++++++++++------------------- js/tools/TagTool.js | 15 +++++++------- js/tools/drawing-tool-base.js | 2 +- 3 files changed, 34 insertions(+), 30 deletions(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index f9411f48..e252e36b 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -318,18 +318,28 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { this._targets.push({elt:elt, mat:curMat, matInv:curMatInv}); if(addToUndoStack) { + var prevX, + prevY, + prevW, + prevH, + _x, + _y, + _w, + _h, + previousMat, + previousStyleStr, + newStyleStr; if(!this._use3DMode) { - var previousMat = this._undoArray[i].mat.slice(0); - var prevX = this._undoArray[i]._x; - var prevY = this._undoArray[i]._y; - var prevW = this._undoArray[i]._w; - var prevH = this._undoArray[i]._h; - var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; - var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; - var _w = parseInt(ElementsMediator.getProperty(elt, "width")); - var _h = parseInt(ElementsMediator.getProperty(elt, "height")); + prevX = this._undoArray[i]._x; + prevY = this._undoArray[i]._y; + prevW = this._undoArray[i]._w; + prevH = this._undoArray[i]._h; + _x = parseInt(ElementsMediator.getProperty(elt, "left")); + _y = parseInt(ElementsMediator.getProperty(elt, "top")); + _w = parseInt(ElementsMediator.getProperty(elt, "width")); + _h = parseInt(ElementsMediator.getProperty(elt, "height")); previousLeft.push(prevX + "px"); previousTop.push(prevY + "px"); @@ -339,27 +349,22 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { newTop.push(_y + "px"); newWidth.push(_w + "px"); newHeight.push(_h + "px"); - - viewUtils.setMatrixForElement(elt, previousMat); - - this._targets[i].mat = previousMat; - this._targets[i].matInv = glmat4.inverse(previousMat, []); } else { - var previousMat = this._undoArray[i].mat.slice(0); - var prevW = this._undoArray[i]._w; - var prevH = this._undoArray[i]._h; - var _w = parseInt(ElementsMediator.getProperty(elt, "width")); - var _h = parseInt(ElementsMediator.getProperty(elt, "height")); + previousMat = this._undoArray[i].mat.slice(0); + prevW = this._undoArray[i]._w; + prevH = this._undoArray[i]._h; + _w = parseInt(ElementsMediator.getProperty(elt, "width")); + _h = parseInt(ElementsMediator.getProperty(elt, "height")); previousWidth.push(prevW + "px"); previousHeight.push(prevH + "px"); newWidth.push(_w + "px"); newHeight.push(_h + "px"); - var previousStyleStr = {dist:this._undoArray[i].dist, + previousStyleStr = {dist:this._undoArray[i].dist, mat:MathUtils.scientificToDecimal(previousMat, 5)}; - var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), + newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), mat:MathUtils.scientificToDecimal(curMat, 5)}; previousStyles.push(previousStyleStr); newStyles.push(newStyleStr); diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index e3f49bbe..6df49a7b 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js @@ -222,21 +222,20 @@ exports.TagTool = Montage.create(DrawingTool, { makeElement: { value: function(w, h, planeMat, midPt,tag) { - var styles; - var left = Math.round(midPt[0] - 0.5 * w); var top = Math.round(midPt[1] - 0.5 * h); - var matStr = DrawingToolBase.getElementMatrix(planeMat, midPt); - - styles = { + var styles = { 'position': 'absolute', 'top' : top + 'px', - 'left' : left + 'px', - '-webkit-transform-style' : 'preserve-3d', - '-webkit-transform' : matStr + 'left' : left + 'px' }; + if(!MathUtils.isIdentityMatrix(planeMat)) { + styles['-webkit-transform-style'] = 'preserve-3d'; + styles['-webkit-transform'] = DrawingToolBase.getElementMatrix(planeMat, midPt); + } + // TODO - for canvas, set both as style and attribute. // Otherwise, we need to create a separate controller for canvas elements if(tag.tagName === "CANVAS") { diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 8d87605c..84602186 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -442,7 +442,7 @@ exports.DrawingToolBase = Montage.create(Montage, { flatMat = divMat; flatMatSafe = MathUtils.scientificToDecimal(flatMat, 10); - return "perspective(" + 1400 + ") matrix3d( " + flatMatSafe + ")"; + return "perspective(" + 1400 + ") matrix3d(" + flatMatSafe + ")"; } }, -- cgit v1.2.3 From 92854b266936f844370688da3b15d035a041e8c2 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 22 Mar 2012 11:10:29 -0700 Subject: Translation handles do not redraw at correct location when double-clicking to reset. Signed-off-by: Nivesh Rajbhandari --- js/tools/Translate3DToolBase.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index 07b6d04d..b7bce2be 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -126,8 +126,11 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, this.isDrawing = false; this.endDraw(event); -// this.UpdateSelection(true); - this.Configure(true); + + // Need to force stage to draw immediately so the new selection center is calculated + this.application.ninja.stage.draw(); + // And captureSelectionDrawn to draw the transform handles + this.captureSelectionDrawn(null); } }, -- cgit v1.2.3 From bead8ce9e292f030a4b2fba6ad7fd38fb4fe5199 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 22 Mar 2012 11:16:39 -0700 Subject: IKNINJA-758 - The rotation value of the stage is not updated in the properties panel. Signed-off-by: Nivesh Rajbhandari --- js/tools/RotateStage3DTool.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index 2b312e53..f5cc4040 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -76,7 +76,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { this._targets.push({elt:elt, mat:curMat, matInv:curMatInv, ctr:eltCtr}); - viewUtils.setMatrixForElement( elt, curMat, false ); + ElementsMediator.setMatrix(elt, curMat, false, "rotateStage3DTool"); } }, @@ -130,7 +130,8 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { // Reset stage to identity matrix var iMat = Matrix.I(4); - ElementsMediator.setMatrix(this.application.ninja.currentDocument.documentRoot, iMat, false); + ElementsMediator.setMatrix(this.application.ninja.currentDocument.documentRoot, + iMat, false, "rotateStage3DTool"); this.application.ninja.currentDocument.documentRoot.elementModel.props3D.m_transformCtr = null; // let the document and stage manager know about the zoom change -- cgit v1.2.3 From 6965b72f1f42f7280bc5e5e52d08b3d64d106831 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 22 Mar 2012 13:07:48 -0700 Subject: IKNinja-1368 - Moving multiple selection of 2d elements starts changing the objects' relative positions. Signed-off-by: Nivesh Rajbhandari --- js/tools/SelectionTool.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index e252e36b..aec5b6a3 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -465,11 +465,14 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { } else { - curMat = item.mat.slice(0); - glmat4.multiply(curMat, qMat, curMat); - var previousMat = this._undoArray[i].mat.slice(0); - var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; - var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; +// curMat = item.mat.slice(0); +// glmat4.multiply(curMat, qMat, curMat); +// var previousMat = this._undoArray[i].mat.slice(0); +// var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; +// var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; + + var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + transMat[12]; + var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + transMat[13]; newLeft.push(_x + "px"); newTop.push(_y + "px"); @@ -582,6 +585,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { { // form the translation vector and post translate the matrix by it. delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); + delta[0] = ~~delta[0]; + delta[1] = ~~delta[1]; delta[2] = 0; var transMat = Matrix.Translation( delta ); this._moveElements(transMat); -- cgit v1.2.3 From 636014cf5d824909993d7dc3510fbe6ce2fc72f1 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 22 Mar 2012 14:24:46 -0700 Subject: WebGL needs to have 3d styles to render. Signed-off-by: Nivesh Rajbhandari --- js/tools/BrushTool.js | 2 +- js/tools/LineTool.js | 2 +- js/tools/PenTool.js | 2 +- js/tools/ShapeTool.js | 4 +--- js/tools/TagTool.js | 4 +++- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'js/tools') diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 4ce9976a..ac29f2f2 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js @@ -252,7 +252,7 @@ exports.BrushTool = Montage.create(ShapeTool, { if (!canvas) { var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas); + var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas, this._useWebGL); ElementMediator.addElement(newCanvas, elementModel.data, true); // create all the GL stuff diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index a61f8f79..a1cf7eb0 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -89,7 +89,7 @@ exports.LineTool = Montage.create(ShapeTool, { } canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas); + var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas, this.options.use3D); ElementMediator.addElement(canvas, elementModel.data, true); canvas.elementModel.isShape = true; diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 60ef4f92..17756772 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -584,7 +584,7 @@ exports.PenTool = Montage.create(ShapeTool, { if (!canvas) { var newCanvas = null; newCanvas = NJUtils.makeNJElement("canvas", "Subpath", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas); + var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas, this._useWebGL); ElementMediator.addElement(newCanvas, elementModel.data, true); // create all the GL stuff diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index d3a36163..2124376d 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -6,8 +6,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, DrawingTool = require("js/tools/drawing-tool").DrawingTool, - viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, - drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, NJUtils = require("js/lib/NJUtils").NJUtils, ElementMediator = require("js/mediators/element-mediator").ElementMediator, ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, @@ -70,7 +68,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { { 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); + drawData.planeMat, drawData.midPt, canvas, this.options.use3D); ElementMediator.addElement(canvas, elementModel.data, true); canvas.elementModel.isShape = true; diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index 6df49a7b..2b6742e6 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js @@ -221,7 +221,7 @@ exports.TagTool = Montage.create(DrawingTool, { }, makeElement: { - value: function(w, h, planeMat, midPt,tag) { + value: function(w, h, planeMat, midPt,tag, isWebGl) { var left = Math.round(midPt[0] - 0.5 * w); var top = Math.round(midPt[1] - 0.5 * h); @@ -234,6 +234,8 @@ exports.TagTool = Montage.create(DrawingTool, { if(!MathUtils.isIdentityMatrix(planeMat)) { styles['-webkit-transform-style'] = 'preserve-3d'; styles['-webkit-transform'] = DrawingToolBase.getElementMatrix(planeMat, midPt); + } else if(isWebGl) { + styles['-webkit-transform-style'] = 'preserve-3d'; } // TODO - for canvas, set both as style and attribute. -- cgit v1.2.3 From 331ea08655245e3532e48bf160d5f68a04d8723f Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 27 Mar 2012 16:38:52 -0700 Subject: IKNINJA-764 - The Local/Global options are not in synced with both 3D object rotate tool and 3D object translate tool. Signed-off-by: Nivesh Rajbhandari --- js/tools/RotateObject3DTool.js | 1 + js/tools/TranslateObject3DTool.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/RotateObject3DTool.js b/js/tools/RotateObject3DTool.js index 72af6eff..27352231 100755 --- a/js/tools/RotateObject3DTool.js +++ b/js/tools/RotateObject3DTool.js @@ -51,6 +51,7 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, { toolHandle._rotMat = Matrix.RotationZ( angle ); } } + this._inLocalMode = (this.options.selectedMode === "rotateLocally"); } }, diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index 60633e74..4fac8187 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js @@ -4,15 +4,22 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, +var Montage = require("montage/core/core").Montage, + Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; -exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { +exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { _toolID: { value: "translateObject3DTool" }, _canOperateOnStage: { value: true }, + _initializeToolHandles: { + value: function() { + this._inLocalMode = (this.options.selectedMode === "rotateLocally"); + } + }, + initializeSnapping : { value : function(event) { -- cgit v1.2.3 From 6b61de58f0733b40f64ed996933ac89927e922a1 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 29 Mar 2012 12:01:21 -0700 Subject: We shouldn't set z to 0 for translate tool snapping because user may want to snap in 3d. Signed-off-by: Nivesh Rajbhandari --- js/tools/Translate3DToolBase.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index 07b6d04d..005b9749 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -66,10 +66,6 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, delta[0] = 0; delta[1] = 0; } - else - { - delta[2] = 0; - } this._delta = delta.slice(0); } -- cgit v1.2.3 From 5b4f6b1618cf571a6bce5a631f976a008e04a64e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 29 Mar 2012 15:52:08 -0700 Subject: Updated shapes to always check for its stroke and fill colors and materials instead of relying on the shapeModel cache because it can get out of sync. Signed-off-by: Nivesh Rajbhandari --- js/tools/LineTool.js | 7 ------- js/tools/OvalTool.js | 13 ------------- js/tools/RectTool.js | 13 ------------- 3 files changed, 33 deletions(-) (limited to 'js/tools') diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index a61f8f79..dd5a7c72 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -234,13 +234,6 @@ exports.LineTool = Montage.create(ShapeTool, { canvas.elementModel.selection = "Line"; canvas.elementModel.pi = "LinePi"; canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; - canvas.elementModel.shapeModel.stroke = strokeColor; - if(strokeColor) - { - canvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke; - } - - canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial; canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; canvas.elementModel.shapeModel.strokeStyle = strokeStyle; diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index a10e0bb5..0ad74aa4 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js @@ -78,22 +78,9 @@ exports.OvalTool = Montage.create(ShapeTool, { canvas.elementModel.selection = "Oval"; canvas.elementModel.pi = "OvalPi"; canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; - canvas.elementModel.shapeModel.stroke = strokeColor; - canvas.elementModel.shapeModel.fill = fillColor; - if(strokeColor) - { - canvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke; - } - if(fillColor) - { - canvas.elementModel.shapeModel.background = this.application.ninja.colorController.colorToolbar.fill; - } canvas.elementModel.shapeModel.innerRadius = this.options.innerRadius.value + " " + this.options.innerRadius.units; - canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial; - canvas.elementModel.shapeModel.fillMaterial = fillMaterial; - canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; canvas.elementModel.shapeModel.strokeStyle = strokeStyle; diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js index 957afea9..c56e4424 100755 --- a/js/tools/RectTool.js +++ b/js/tools/RectTool.js @@ -98,25 +98,12 @@ exports.RectTool = Montage.create(ShapeTool, { canvas.elementModel.selection = "Rectangle"; canvas.elementModel.pi = "RectanglePi"; canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; - canvas.elementModel.shapeModel.stroke = strokeColor; - canvas.elementModel.shapeModel.fill = fillColor; - if(strokeColor) - { - canvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke; - } - if(fillColor) - { - canvas.elementModel.shapeModel.background = this.application.ninja.colorController.colorToolbar.fill; - } canvas.elementModel.shapeModel.tlRadius = this.options.TLRadiusControl.value + " " + this.options.TLRadiusControl.units; canvas.elementModel.shapeModel.trRadius = this.options.TRRadiusControl.value + " " + this.options.TRRadiusControl.units; canvas.elementModel.shapeModel.blRadius = this.options.BLRadiusControl.value + " " + this.options.BLRadiusControl.units; canvas.elementModel.shapeModel.brRadius = this.options.BRRadiusControl.value + " " + this.options.BRRadiusControl.units; - canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial; - canvas.elementModel.shapeModel.fillMaterial = fillMaterial; - canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; canvas.elementModel.shapeModel.strokeStyle = strokeStyle; -- cgit v1.2.3 From eae317815e15a7ffc2dd1bd1e39b208eaa02fd2b Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 30 Mar 2012 13:53:47 -0700 Subject: Update PI and Color Panel to reflect default LinearGradient and RadialGradient materials' colors. Signed-off-by: Nivesh Rajbhandari --- js/tools/LineTool.js | 1 + js/tools/OvalTool.js | 2 ++ js/tools/RectTool.js | 2 ++ js/tools/ShapeTool.js | 25 +++++++++++++++++++++++++ 4 files changed, 30 insertions(+) (limited to 'js/tools') diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index dd5a7c72..499a6b9d 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -216,6 +216,7 @@ exports.LineTool = Montage.create(ShapeTool, { { strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); } + strokeColor = this._getMaterialColor(strokeM) || strokeColor; } var world = this.getGLWorld(canvas, this.options.use3D); diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index 0ad74aa4..c09c9bc7 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js @@ -53,12 +53,14 @@ exports.OvalTool = Montage.create(ShapeTool, { { strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); } + strokeColor = this._getMaterialColor(strokeM) || strokeColor; var fillM = this.options.fillMaterial; if(fillM) { fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); } + fillColor = this._getMaterialColor(fillM) || fillColor; } var world = this.getGLWorld(canvas, this.options.use3D); diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js index c56e4424..d69aa933 100755 --- a/js/tools/RectTool.js +++ b/js/tools/RectTool.js @@ -72,12 +72,14 @@ exports.RectTool = Montage.create(ShapeTool, { { strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); } + strokeColor = this._getMaterialColor(strokeM) || strokeColor; var fillM = this.options.fillMaterial; if(fillM) { fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); } + fillColor = this._getMaterialColor(fillM) || fillColor; } var world = this.getGLWorld(canvas, this.options.use3D); diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index d3a36163..1a12401f 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -206,7 +206,32 @@ exports.ShapeTool = Montage.create(DrawingTool, { } }, + _getMaterialColor: { + value: function(m) + { + var css, + colorObj; + if(m === "LinearGradientMaterial") + { + css = "-webkit-gradient(linear, left top, right top, from(rgb(255, 0, 0)), color-stop(0.3, rgb(0, 255, 0)), color-stop(0.6, rgb(0, 0, 255)), to(rgb(0, 255, 255)))"; + } + else if(m === "RadialGradientMaterial") + { + css = "-webkit-radial-gradient(50% 50%, ellipse cover, rgb(255, 0, 0) 0%, rgb(0, 255, 0) 30%, rgb(0, 0, 255) 60%, rgb(0, 255, 255) 100%)"; + } + + if(css) + { + colorObj = this.application.ninja.colorController.getColorObjFromCss(css); + if(colorObj) + { + return {gradientMode:colorObj.color.gradientMode, color:colorObj.color.stops}; + } + } + return null; + } + }, // We can draw on an existing canvas unless it has only a single shape object _useExistingCanvas: { -- cgit v1.2.3 From 5377e963c4413640cd3c04e0406384df04144568 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 2 Apr 2012 14:52:14 -0700 Subject: Switching to Linear/RadialGradient materials will set the corresponding color. Also, dispatching an addElement event when toggling shape from WebGL/canvas2d so timeline can draw correctly. Signed-off-by: Nivesh Rajbhandari --- js/tools/LineTool.js | 2 +- js/tools/OvalTool.js | 4 ++-- js/tools/RectTool.js | 4 ++-- js/tools/ShapeTool.js | 27 --------------------------- 4 files changed, 5 insertions(+), 32 deletions(-) (limited to 'js/tools') diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 499a6b9d..9b22c629 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -216,7 +216,7 @@ exports.LineTool = Montage.create(ShapeTool, { { strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); } - strokeColor = this._getMaterialColor(strokeM) || strokeColor; + strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor; } var world = this.getGLWorld(canvas, this.options.use3D); diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index c09c9bc7..e8e88d1d 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js @@ -53,14 +53,14 @@ exports.OvalTool = Montage.create(ShapeTool, { { strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); } - strokeColor = this._getMaterialColor(strokeM) || strokeColor; + strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor; var fillM = this.options.fillMaterial; if(fillM) { fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); } - fillColor = this._getMaterialColor(fillM) || fillColor; + fillColor = ShapesController.getMaterialColor(fillM) || fillColor; } var world = this.getGLWorld(canvas, this.options.use3D); diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js index d69aa933..0c14a559 100755 --- a/js/tools/RectTool.js +++ b/js/tools/RectTool.js @@ -72,14 +72,14 @@ exports.RectTool = Montage.create(ShapeTool, { { strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); } - strokeColor = this._getMaterialColor(strokeM) || strokeColor; + strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor; var fillM = this.options.fillMaterial; if(fillM) { fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); } - fillColor = this._getMaterialColor(fillM) || fillColor; + fillColor = ShapesController.getMaterialColor(fillM) || fillColor; } var world = this.getGLWorld(canvas, this.options.use3D); diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 1a12401f..85009bc2 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -206,33 +206,6 @@ exports.ShapeTool = Montage.create(DrawingTool, { } }, - _getMaterialColor: { - value: function(m) - { - var css, - colorObj; - if(m === "LinearGradientMaterial") - { - css = "-webkit-gradient(linear, left top, right top, from(rgb(255, 0, 0)), color-stop(0.3, rgb(0, 255, 0)), color-stop(0.6, rgb(0, 0, 255)), to(rgb(0, 255, 255)))"; - } - else if(m === "RadialGradientMaterial") - { - css = "-webkit-radial-gradient(50% 50%, ellipse cover, rgb(255, 0, 0) 0%, rgb(0, 255, 0) 30%, rgb(0, 0, 255) 60%, rgb(0, 255, 255) 100%)"; - } - - if(css) - { - colorObj = this.application.ninja.colorController.getColorObjFromCss(css); - if(colorObj) - { - return {gradientMode:colorObj.color.gradientMode, color:colorObj.color.stops}; - } - } - - return null; - } - }, - // We can draw on an existing canvas unless it has only a single shape object _useExistingCanvas: { value: function() -- cgit v1.2.3 From dc9650af5760b1f93d6e93a383eabceacfdc0ad8 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 2 Apr 2012 15:40:25 -0700 Subject: Snapping fixes. --- js/tools/Translate3DToolBase.js | 25 +++++++++++++++++++------ js/tools/TranslateObject3DTool.js | 21 ++++++++++----------- js/tools/modifier-tool-base.js | 14 ++++++++++++-- 3 files changed, 41 insertions(+), 19 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index 07b6d04d..18e2b610 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -29,6 +29,8 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, modifyElements : { value : function(data, event) { + //console.log( "modifyElements, data: " + data.pt0 + " => " + data.pt1 ); + // form the translation vector and post translate the matrix by it. var delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); if(this._handleMode !== null) @@ -66,15 +68,12 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, delta[0] = 0; delta[1] = 0; } - else - { - delta[2] = 0; - } this._delta = delta.slice(0); } var transMat = Matrix.Translation( delta ); + //console.log( "Translate: " + delta ); if(this._inLocalMode && (this._targets.length === 1) ) { this._translateLocally(transMat); @@ -134,6 +133,9 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, // We will only translate single elements locally _translateLocally: { value: function (transMat) { + //console.log( "_translateLocally, startMat: " + this._startMat ); + //console.log( "_translateLocally, transMat: " + transMat ); + //console.log( "_translateLocally, startMat: " + this._startMat + ", transMat: " + transMat ); var mat = glmat4.multiply(this._startMat, transMat, []); viewUtils.setMatrixForElement( this._target, mat, true ); if(this._mode !== 1) @@ -145,14 +147,22 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, _translateGlobally: { value: function (transMat) { + //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat ); + //console.log( "_translateGlobally, transMat: " + transMat ); var len = this._targets.length, i = 0, item, elt, - curMat, + curMat = viewUtils.getMatrixFromElement( this._target ), matInv = glmat4.inverse(this._startMat, []), nMat = glmat4.multiply(transMat, this._startMat, [] ), qMat = glmat4.multiply(matInv, nMat, []); + + if (this._mode === 1) + { + var curInv = glmat4.inverse( curMat, [] ); + transMat = glmat4.multiply( nMat, curInv, [] ); + } var shouldUpdateStartMat = true; @@ -181,6 +191,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, if(shouldUpdateStartMat) { + //console.log( "\t\tshouldUpdateStartMat" ); this._targets[i].mat = curMat; } } @@ -188,7 +199,9 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, }, _updateTargets: { - value: function(addToUndoStack) { + value: function(addToUndoStack) + { + console.log( "_updateTargets" ); var newStyles = [], previousStyles = [], len = this.application.ninja.selectedElements.length; diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index 60633e74..7163f005 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js @@ -16,6 +16,8 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { initializeSnapping : { value : function(event) { + console.log( "initializeSnapping" ); + this._mouseDownHitRec = null; this._mouseUpHitRec = null; @@ -37,8 +39,6 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { if(this._handleMode === null) { -// this.doSelection(event); - snapManager.enableElementSnap ( true ); snapManager.enableGridSnap ( true ); } @@ -107,16 +107,10 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { } if(this._handleMode === 2) - { - // TODO - not sure how to parameterize point in z-translate mode this.clickedObject = this._target; - this._snapParam = [0, 0, 0]; - } - else - { - // parameterize the snap point on the target - this._snapParam = this.parameterizeSnap( hitRec ); - } + + // parameterize the snap point on the target + this._snapParam = this.parameterizeSnap( hitRec ); if(!this._dragPlane) { @@ -132,6 +126,11 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { } + // only do quadrant snapping if the 4 corners of the element are in the drag plane + + var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); + this._shouldUseQuadPt = (sign == 0); + var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); this._mouseDownHitRec = wpHitRec; this._mouseUpHitRec = null; diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 94b806fd..07b28747 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -25,6 +25,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { _snapParam: { value: null }, _snapIndex: { value: -1 }, _useQuadPt: { value: false }, + _shouldUseQuadPt: { value: false }, // we set snapping capabilities depending on the tool. // The following variables are set in a tool's initializeSnapping method called on mouse down. @@ -175,6 +176,10 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { // } } + // only do quadrant snapping if the 4 corners of the element are in the drag plane + var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); + this._shouldUseQuadPt = (sign == 0) + var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); this._mouseDownHitRec = wpHitRec; this._mouseUpHitRec = null; @@ -236,6 +241,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { } } + //console.log( "ParameterizeSnap: " + paramPt ); return paramPt; } }, @@ -284,14 +290,16 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { y = x0 + ty*dy, z = 0.0; var localPt = [x,y,z]; + globalPt = viewUtils.localToGlobal( localPt, elt ); // add in the delta var hitPt = this.GetObjectHitPoint(); var scrPt = viewUtils.localToGlobal( hitPt, this._clickedObject ); - var delta = [xEvent-scrPt[0], yEvent-scrPt[1]]; + var delta = [xEvent-scrPt[0], yEvent-scrPt[1], 0-scrPt[2]]; globalPt[0] += delta[0]; globalPt[1] += delta[1]; + globalPt[2] += delta[2]; } return globalPt; @@ -517,7 +525,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { // do the snap var quadPt; - if (mouseIsDown) + if (mouseIsDown && !do3DSnap && this._shouldUseQuadPt && (this._handleMode === null) && (this._mode === 0)) quadPt = this.GetQuadrantSnapPoint(x,y); var hitRec = snapManager.snap(x, y, do3DSnap, quadPt ); @@ -806,6 +814,8 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { HandleLeftButtonDown: { value: function(event) { + console.log( "modifier-tool-base.HandleLeftButtonDown" ); + var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); this.downPoint.x = point.x; this.downPoint.y = point.y; -- cgit v1.2.3 From bf815cbda0f7a4f2b8ca9532745fa525ed60c8d3 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 2 Apr 2012 16:58:54 -0700 Subject: IKNinja-1376 - 3D values reverted when using Selection tool to move the object. (Only happen when 3D values set in PI) We need to update the undo array for the tool if values are changed outside the active tool. I think this was the same bug causing IKNinja-1411. Signed-off-by: Nivesh Rajbhandari --- js/tools/SelectionTool.js | 1 + js/tools/modifier-tool-base.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index f9411f48..c00a2929 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -60,6 +60,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { else { this._canSnap = true; + this._updateTargets(); } this.isDrawing = true; diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 94b806fd..f58ecb53 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -448,6 +448,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { { this.isDrawing = true; this.application.ninja.stage.showSelectionBounds = false; + this._updateTargets(); if(this._canSnap) { @@ -785,7 +786,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { { this.target = this.application.ninja.currentDocument.documentRoot; } - this._updateTargets(); +// this._updateTargets(); } else { -- cgit v1.2.3 From 4d132fcbde4540c2cac6c0df613940353e2690f6 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 3 Apr 2012 12:03:16 -0700 Subject: Give user feedback about which element the Fill/InkBottle tools will act on. Signed-off-by: Nivesh Rajbhandari --- js/tools/FillTool.js | 20 +++++++++++++++++++- js/tools/InkBottleTool.js | 21 ++++++++++++++++++++- js/tools/ShapeTool.js | 11 +++++------ js/tools/modifier-tool-base.js | 5 +++++ 4 files changed, 49 insertions(+), 8 deletions(-) (limited to 'js/tools') diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js index 4b07ae83..746f20cf 100755 --- a/js/tools/FillTool.js +++ b/js/tools/FillTool.js @@ -17,11 +17,12 @@ var Montage = require("montage/core/core").Montage, exports.FillTool = Montage.create(ModifierToolBase, { _canSnap: { value: false }, _canColor: { value: true }, + _targetedElement: { value: null }, HandleMouseMove: { value : function (event) { - var obj = this.application.ninja.stage.GetElement(event); + var obj = this.application.ninja.stage.GetSelectableElement(event); var cursor = "url('images/cursors/fill.png') 14 14, default"; var canColor = true; if (obj) @@ -31,6 +32,23 @@ exports.FillTool = Montage.create(ModifierToolBase, { { cursor = "url('images/cursors/nofill.png') 14 14, default"; canColor = false; + if(this._targetedElement) + { + this._targetedElement.classList.remove("active-element-outline"); + this._targetedElement = null; + } + } + else + { + if (obj !== this._targetedElement) + { + if(this._targetedElement) + { + this._targetedElement.classList.remove("active-element-outline"); + } + } + this._targetedElement = obj; + this._targetedElement.classList.add("active-element-outline"); } } this.application.ninja.stage.drawingCanvas.style.cursor = cursor; diff --git a/js/tools/InkBottleTool.js b/js/tools/InkBottleTool.js index 8340ef50..95c2e71d 100755 --- a/js/tools/InkBottleTool.js +++ b/js/tools/InkBottleTool.js @@ -11,11 +11,12 @@ var Montage = require("montage/core/core").Montage, exports.InkBottleTool = Montage.create(ModifierToolBase, { _canSnap: { value: false }, _canColor: { value: true }, + _targetedElement: { value: null }, HandleMouseMove: { value : function (event) { - var obj = this.application.ninja.stage.GetElement(event); + var obj = this.application.ninja.stage.GetSelectableElement(event); var cursor = "url('images/cursors/ink.png') 6 11, default"; var canColor = true; if (obj) @@ -25,7 +26,25 @@ exports.InkBottleTool = Montage.create(ModifierToolBase, { { cursor = "url('images/cursors/ink_no.png') 6 11, default"; canColor = false; + if(this._targetedElement) + { + this._targetedElement.classList.remove("active-element-outline"); + this._targetedElement = null; + } } + else + { + if (obj !== this._targetedElement) + { + if(this._targetedElement) + { + this._targetedElement.classList.remove("active-element-outline"); + } + } + this._targetedElement = obj; + this._targetedElement.classList.add("active-element-outline"); + } + } this.application.ninja.stage.drawingCanvas.style.cursor = cursor; this._canColor = canColor; diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 85009bc2..92284d78 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -119,7 +119,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { RemoveCustomFeedback: { value: function (event) { if (this._targetedElement) { - this._targetedElement.classList.remove("elem-red-outline"); + this._targetedElement.classList.remove("active-element-outline"); this._targetedElement = null; } @@ -136,23 +136,22 @@ exports.ShapeTool = Montage.create(DrawingTool, { _showFeedbackOnMouseMove: { value: function (event) { // TODO - This call is causing the canvas to redraw 3 times per mouse move - var targetedObject = this.application.ninja.stage.GetElement(event); + var targetedObject = this.application.ninja.stage.GetSelectableElement(event); if (targetedObject) { - // TODO - Clean this up if((targetedObject.nodeName === "CANVAS") && !ShapesController.isElementAShape(targetedObject)) { if (targetedObject !== this._targetedElement) { if(this._targetedElement) { - this._targetedElement.classList.remove("elem-red-outline"); + this._targetedElement.classList.remove("active-element-outline"); } this._targetedElement = targetedObject; - this._targetedElement.classList.add("elem-red-outline"); + this._targetedElement.classList.add("active-element-outline"); } } else if (this._targetedElement) { - this._targetedElement.classList.remove("elem-red-outline"); + this._targetedElement.classList.remove("active-element-outline"); this._targetedElement = null; } } diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index f58ecb53..a1812650 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -758,6 +758,11 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); this.eventManager.removeEventListener( "toolOptionsChange", this, false); this.eventManager.removeEventListener( "toolDoubleClick", this, false); + + if (this._targetedElement) { + this._targetedElement.classList.remove("active-element-outline"); + this._targetedElement = null; + } } } }, -- cgit v1.2.3 From df0389e6a191ebbff4e4b5d6625007873c0737bd Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 4 Apr 2012 10:21:20 -0700 Subject: Adjusting line's width and height when changing stroke size. Signed-off-by: Nivesh Rajbhandari --- js/tools/LineTool.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/tools') diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 9b22c629..a43d4fb6 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -241,6 +241,7 @@ exports.LineTool = Montage.create(ShapeTool, { canvas.elementModel.shapeModel.GLGeomObj = line; canvas.elementModel.shapeModel.useWebGl = this.options.use3D; + canvas.elementModel.shapeModel.slope = slope; } else { -- cgit v1.2.3 From 8b60a68f0152c609ad94a931472680f313678d8d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 4 Apr 2012 11:17:50 -0700 Subject: We should require VecUtils instead of referring to the global reference since we will eventually remove that from the window object. Signed-off-by: Nivesh Rajbhandari --- js/tools/TranslateObject3DTool.js | 6 +++--- js/tools/modifier-tool-base.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'js/tools') diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index 7163f005..9fa49229 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js @@ -5,7 +5,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot */ var Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, - drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, + vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; @@ -16,7 +16,7 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { initializeSnapping : { value : function(event) { - console.log( "initializeSnapping" ); +// console.log( "initializeSnapping" ); this._mouseDownHitRec = null; this._mouseUpHitRec = null; @@ -128,7 +128,7 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { // only do quadrant snapping if the 4 corners of the element are in the drag plane - var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); + var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); this._shouldUseQuadPt = (sign == 0); var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 5f2d29be..064f8b4b 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -9,8 +9,8 @@ var Montage = require("montage/core/core").Montage, snapManager = require("js/helper-classes/3D/snap-manager").SnapManager, viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, - drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, - Properties3D = ("js/models/properties-3d").Properties3D; + drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; +// Properties3D = ("js/models/properties-3d").Properties3D; exports.ModifierToolBase = Montage.create(DrawingTool, { @@ -177,7 +177,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { } // only do quadrant snapping if the 4 corners of the element are in the drag plane - var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); + var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); this._shouldUseQuadPt = (sign == 0) var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); -- cgit v1.2.3 From 65e91e6b6544a34e1831c975a24b63eeba372b7b Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 5 Apr 2012 10:30:26 -0700 Subject: Commenting out console logs. Signed-off-by: Nivesh Rajbhandari --- js/tools/Translate3DToolBase.js | 5 ++--- js/tools/modifier-tool-base.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index 3976c5b9..948383a3 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -202,9 +202,8 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, }, _updateTargets: { - value: function(addToUndoStack) - { - console.log( "_updateTargets" ); + value: function(addToUndoStack) { +// console.log( "_updateTargets" ); var newStyles = [], previousStyles = [], len = this.application.ninja.selectedElements.length; diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index a86ac407..de73c861 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -820,7 +820,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { HandleLeftButtonDown: { value: function(event) { - console.log( "modifier-tool-base.HandleLeftButtonDown" ); +// console.log( "modifier-tool-base.HandleLeftButtonDown" ); var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); this.downPoint.x = point.x; -- cgit v1.2.3 From 1e2e0a8d04e55c0ecfb0b1b674792b69fb091415 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 5 Apr 2012 12:01:38 -0700 Subject: Fixing 3d tool reset to redraw handles. Signed-off-by: Nivesh Rajbhandari --- js/tools/Rotate3DToolBase.js | 15 ++++++++------- js/tools/Translate3DToolBase.js | 9 ++++----- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js index eb2cdba4..696408bf 100755 --- a/js/tools/Rotate3DToolBase.js +++ b/js/tools/Rotate3DToolBase.js @@ -438,24 +438,23 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { value : function() { var item, - elt, mat, dist, newStyles = [], previousStyles = [], - len = this._targets.length, + len = this.application.ninja.selectedElements.length, iMat; for(var i = 0; i < len; i++) { // Reset to the identity matrix - item = this._targets[i]; + item = this.application.ninja.selectedElements[i]; iMat = Matrix.I(4); - mat = item.mat; + mat = ElementsMediator.getMatrix(item); // iMat[12] = mat[12]; // iMat[13] = mat[13]; // iMat[14] = mat[14]; - dist = this._undoArray[i].dist; + dist = ElementsMediator.getPerspectiveDist(item); var previousStyleStr = {dist:dist, mat:mat}; @@ -476,8 +475,10 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { this.isDrawing = false; this.endDraw(event); -// this.UpdateSelection(true); - this.Configure(true); + // Need to force stage to draw immediately so the new selection center is calculated + this.application.ninja.stage.draw(); + // And captureSelectionDrawn to draw the transform handles + this.captureSelectionDrawn(null); } }, diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index 948383a3..e4f1fb99 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -90,22 +90,21 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, value : function() { var item, - elt, mat, dist, newStyles = [], previousStyles = [], - len = this._targets.length; + len = this.application.ninja.selectedElements.length; for(var i = 0; i < len; i++) { // Reset to the identity matrix but retain the rotation values - item = this._targets[i]; - mat = item.mat.slice(0); + item = this.application.ninja.selectedElements[i]; + mat = ElementsMediator.getMatrix(item); mat[12] = 0; mat[13] = 0; mat[14] = 0; - dist = this._undoArray[i].dist; + dist = ElementsMediator.getPerspectiveDist(item); var previousStyleStr = {dist:dist, mat:item.mat}; -- cgit v1.2.3 From 4dc89306c43e86cdac254c81fb9bb3a92eb4a8b9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 5 Apr 2012 12:12:36 -0700 Subject: Removing fill, stroke, fillMaterial and strokeMaterial from the shapeModel cache because they can easily get out of sync with the actual colors and materials. Instead, we will always query the object for these values. Signed-off-by: Nivesh Rajbhandari --- js/tools/BrushTool.js | 6 ------ js/tools/PenTool.js | 6 ------ 2 files changed, 12 deletions(-) (limited to 'js/tools') diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index d71cc743..1365896a 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js @@ -334,12 +334,6 @@ exports.BrushTool = Montage.create(ShapeTool, { newCanvas.elementModel.selection = "BrushStroke"; newCanvas.elementModel.pi = "BrushStrokePi"; newCanvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; - var strokeColor = this._selectedBrushStroke.getStrokeColor(); - newCanvas.elementModel.shapeModel.stroke = strokeColor; - if(strokeColor) { - newCanvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke; - } - newCanvas.elementModel.shapeModel.strokeMaterial = this._selectedBrushStroke.getStrokeMaterial(); newCanvas.elementModel.shapeModel.GLGeomObj = brushStroke; newCanvas.elementModel.shapeModel.useWebGl = this.options.use3D; diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index aa14ea75..7f6f190a 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -610,12 +610,6 @@ exports.PenTool = Montage.create(ShapeTool, { newCanvas.elementModel.selection = "Subpath"; newCanvas.elementModel.pi = "SubpathPi"; newCanvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; - var strokeColor = subpath.getStrokeColor(); - newCanvas.elementModel.shapeModel.stroke = strokeColor; - if(strokeColor) { - newCanvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke; - } - newCanvas.elementModel.shapeModel.strokeMaterial = subpath.getStrokeMaterial(); newCanvas.elementModel.shapeModel.GLGeomObj = subpath; newCanvas.elementModel.shapeModel.useWebGl = this.options.use3D; -- cgit v1.2.3 From d42af4f0f5e893ab0e1f74f50055e0be3bd9e78e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 5 Apr 2012 16:43:25 -0700 Subject: -webkit-transform-style needs to be set to preserve-3d for shapes regardless of whether they are 2d shapes or WebGL shapes. Signed-off-by: Nivesh Rajbhandari --- js/tools/BrushTool.js | 2 +- js/tools/LineTool.js | 2 +- js/tools/PenTool.js | 2 +- js/tools/ShapeTool.js | 2 +- js/tools/TagTool.js | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'js/tools') diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 1365896a..4347658a 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js @@ -305,7 +305,7 @@ exports.BrushTool = Montage.create(ShapeTool, { if (!canvas) { var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas, this._useWebGL); + var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas, true); ElementMediator.addElements(newCanvas, elementModel.data, false); // create all the GL stuff diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index de2eb21d..3e9167fd 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -78,7 +78,7 @@ exports.LineTool = Montage.create(ShapeTool, { } canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas, this.options.use3D); + var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas, true); canvas.elementModel.isShape = true; this.application.ninja.elementMediator.addElements(canvas, elementModel.data); } else { diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 7f6f190a..7fc8dd95 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -584,7 +584,7 @@ exports.PenTool = Montage.create(ShapeTool, { if (!canvas) { var newCanvas = null; newCanvas = NJUtils.makeNJElement("canvas", "Subpath", "shape", {"data-RDGE-id": NJUtils.generate