diff options
author | Pushkar Joshi | 2012-04-04 15:55:48 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-04-04 15:55:48 -0700 |
commit | 0681b34b506767b6caf2816b9096bc1a57a17a2d (patch) | |
tree | 20f10c767efe8d9c5c38fbc2cdb713d093bb279d /js/tools | |
parent | f4eccf3e7cb76a14a3546a646575162dbd831538 (diff) | |
parent | 8482e23cd9b8c4700b5130f2588e5eb24d376536 (diff) | |
download | ninja-0681b34b506767b6caf2816b9096bc1a57a17a2d.tar.gz |
Merge branch 'master' into pentool
Conflicts:
js/tools/PenTool.js
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/BrushTool.js | 2 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 111 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 13 | ||||
-rwxr-xr-x | js/tools/Rotate3DToolBase.js | 4 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 34 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 37 | ||||
-rwxr-xr-x | js/tools/TagTool.js | 6 | ||||
-rwxr-xr-x | js/tools/TextTool.js | 4 | ||||
-rwxr-xr-x | js/tools/Translate3DToolBase.js | 2 | ||||
-rwxr-xr-x | js/tools/modifier-tool-base.js | 2 |
10 files changed, 111 insertions, 104 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 78d1e7e6..620376ab 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js | |||
@@ -305,7 +305,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
305 | if (!canvas) { | 305 | if (!canvas) { |
306 | var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 306 | var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); |
307 | var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas); | 307 | var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas); |
308 | ElementMediator.addElement(newCanvas, elementModel.data, true); | 308 | ElementMediator.addElements(newCanvas, elementModel.data, false); |
309 | 309 | ||
310 | // create all the GL stuff | 310 | // create all the GL stuff |
311 | var world = this.getGLWorld(newCanvas, this._useWebGL); | 311 | var world = this.getGLWorld(newCanvas, this._useWebGL); |
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index a61f8f79..455f519e 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js | |||
@@ -7,7 +7,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | ShapeTool = require("js/tools/ShapeTool").ShapeTool, | 8 | ShapeTool = require("js/tools/ShapeTool").ShapeTool, |
9 | DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase, | 9 | DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase, |
10 | ElementMediator = require("js/mediators/element-mediator").ElementMediator, | ||
11 | NJUtils = require("js/lib/NJUtils").NJUtils, | 10 | NJUtils = require("js/lib/NJUtils").NJUtils, |
12 | TagTool = require("js/tools/TagTool").TagTool, | 11 | TagTool = require("js/tools/TagTool").TagTool, |
13 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, | 12 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, |
@@ -53,59 +52,43 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
53 | } | 52 | } |
54 | }, | 53 | }, |
55 | 54 | ||
56 | HandleLeftButtonUp: | 55 | HandleLeftButtonUp: { |
57 | { | 56 | value: function (event) { |
58 | value: function (event) | 57 | var slope = this._getSlope(), drawData = this.getDrawingData(); |
59 | { | ||
60 | var slope = this._getSlope(), | ||
61 | drawData = this.getDrawingData(); | ||
62 | 58 | ||
63 | if(drawData) { | 59 | if(drawData) { |
64 | var canvas, | 60 | var canvas, xAdj = 0, yAdj = 0, w, h; |
65 | xAdj = 0, | 61 | if(!this._useExistingCanvas()) { |
66 | yAdj = 0, | 62 | if(drawData = this.getDrawingData()) { |
67 | w = ~~drawData.width, | 63 | // set the dimensions |
68 | h = ~~drawData.height; | 64 | w = ~~drawData.width; |
69 | if(!this._useExistingCanvas()) | 65 | h = ~~drawData.height; |
70 | { | 66 | if(slope === "horizontal") { |
71 | // set the dimensions | 67 | h = Math.max(this._strokeSize, 1); |
72 | if(slope === "horizontal") | 68 | } else if(slope === "vertical") { |
73 | { | 69 | w = Math.max(this._strokeSize, 1); |
74 | h = Math.max(this._strokeSize, 1); | 70 | } else { |
75 | } | 71 | // else make the line's stroke fit inside the canvas by growing the canvas |
76 | else if(slope === "vertical") | 72 | var theta = Math.atan(slope); |
77 | { | 73 | xAdj = Math.abs((this._strokeSize/2)*Math.sin(theta)); |
78 | w = Math.max(this._strokeSize, 1); | 74 | yAdj = Math.abs((this._strokeSize/2)*Math.cos(theta)); |
79 | } | 75 | |
80 | else | 76 | w += ~~(xAdj*2); |
81 | { | 77 | h += ~~(yAdj*2); |
82 | // else make the line's stroke fit inside the canvas by growing the canvas | 78 | } |
83 | var theta = Math.atan(slope); | 79 | |
84 | xAdj = Math.abs((this._strokeSize/2)*Math.sin(theta)); | 80 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); |
85 | yAdj = Math.abs((this._strokeSize/2)*Math.cos(theta)); | 81 | var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas); |
86 | 82 | canvas.elementModel.isShape = true; | |
87 | w += ~~(xAdj*2); | 83 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); |
88 | h += ~~(yAdj*2); | 84 | } else { |
89 | } | 85 | canvas = this._targetedElement; |
90 | 86 | canvas.elementModel.controller = ShapesController; | |
91 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 87 | if(!canvas.elementModel.shapeModel) { |
92 | var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas); | 88 | canvas.elementModel.shapeModel = Montage.create(ShapeModel); |
93 | 89 | } | |
94 | ElementMediator.addElement(canvas, elementModel.data, true); | ||
95 | canvas.elementModel.isShape = true; | ||
96 | } | ||
97 | else | ||
98 | { | ||
99 | canvas = this._targetedElement; | ||
100 | canvas.elementModel.controller = ShapesController; | ||
101 | if(!canvas.elementModel.shapeModel) | ||
102 | { | ||
103 | canvas.elementModel.shapeModel = Montage.create(ShapeModel); | ||
104 | } | 90 | } |
105 | } | 91 | } |
106 | this.RenderShape(w, h, drawData.planeMat, drawData.midPt, | ||
107 | canvas, slope, xAdj, yAdj); | ||
108 | NJevent("elementAdded", canvas); | ||
109 | } | 92 | } |
110 | 93 | ||
111 | this.endDraw(event); | 94 | this.endDraw(event); |
@@ -113,11 +96,37 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
113 | this._isDrawing = false; | 96 | this._isDrawing = false; |
114 | this._hasDraw=false; | 97 | this._hasDraw=false; |
115 | 98 | ||
116 | |||
117 | this.DrawHandles(); | 99 | this.DrawHandles(); |
118 | } | 100 | } |
119 | }, | 101 | }, |
120 | 102 | ||
103 | onAddElements: { | ||
104 | value: function(el) { | ||
105 | var drawData, xAdj = 0, yAdj = 0, w, h, slope = this._getSlope(); | ||
106 | |||
107 | if(drawData = this.getDrawingData()) { | ||
108 | // set the dimensions | ||
109 | w = ~~drawData.width; | ||
110 | h = ~~drawData.height; | ||
111 | if(slope === "horizontal") { | ||
112 | h = Math.max(this._strokeSize, 1); | ||
113 | } else if(slope === "vertical") { | ||
114 | w = Math.max(this._strokeSize, 1); | ||
115 | } else { | ||
116 | // else make the line's stroke fit inside the canvas by growing the canvas | ||
117 | var theta = Math.atan(slope); | ||
118 | xAdj = Math.abs((this._strokeSize/2)*Math.sin(theta)); | ||
119 | yAdj = Math.abs((this._strokeSize/2)*Math.cos(theta)); | ||
120 | |||
121 | w += ~~(xAdj*2); | ||
122 | h += ~~(yAdj*2); | ||
123 | } | ||
124 | |||
125 | this.RenderShape(w, h, drawData.planeMat, drawData.midPt, el, slope, xAdj, yAdj); | ||
126 | } | ||
127 | } | ||
128 | }, | ||
129 | |||
121 | _getSlope: { | 130 | _getSlope: { |
122 | value: function() { | 131 | value: function() { |
123 | var hitRec0 = this._mouseDownHitRec, | 132 | var hitRec0 = this._mouseDownHitRec, |
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index f1c79153..962f178d 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -447,7 +447,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
447 | var newCanvas = null; | 447 | var newCanvas = null; |
448 | newCanvas = NJUtils.makeNJElement("canvas", "Subpath", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 448 | newCanvas = NJUtils.makeNJElement("canvas", "Subpath", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); |
449 | var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas); | 449 | var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas); |
450 | ElementMediator.addElement(newCanvas, elementModel.data, true); | 450 | ElementMediator.addElements(newCanvas, elementModel.data, false); |
451 | 451 | ||
452 | // create all the GL stuff | 452 | // create all the GL stuff |
453 | var world = this.getGLWorld(newCanvas, this._useWebGL);//this.options.use3D);//this.CreateGLWorld(planeMat, midPt, newCanvas, this._useWebGL);//fillMaterial, strokeMaterial); | 453 | var world = this.getGLWorld(newCanvas, this._useWebGL);//this.options.use3D);//this.CreateGLWorld(planeMat, midPt, newCanvas, this._useWebGL);//fillMaterial, strokeMaterial); |
@@ -700,6 +700,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
700 | } | 700 | } |
701 | }, | 701 | }, |
702 | 702 | ||
703 | |||
703 | BuildSecondCtrlPoint:{ | 704 | BuildSecondCtrlPoint:{ |
704 | value: function(p0, p2, p3) { | 705 | value: function(p0, p2, p3) { |
705 | var baselineOrig = VecUtils.vecSubtract(3, p3, p0); | 706 | var baselineOrig = VecUtils.vecSubtract(3, p3, p0); |
@@ -1051,11 +1052,11 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
1051 | } | 1052 | } |
1052 | else{ | 1053 | else{ |
1053 | for (var i=0;i<this.application.ninja.selectedElements.length;i++){ | 1054 | for (var i=0;i<this.application.ninja.selectedElements.length;i++){ |
1054 | var element = this.application.ninja.selectedElements[i]._element; | 1055 | var element = this.application.ninja.selectedElements[i] |
1055 | console.log("Entered pen tool, had selected: " + element.elementModel.selection); | 1056 | console.log("Entered pen tool, had selected: " + element.elementModel.selection); |
1056 | if (element.elementModel.selection === 'Subpath'){ //TODO what to do if the canvas is drawn by tag tool? | 1057 | if (element.elementModel.selection === 'Subpath'){ //TODO what to do if the canvas is drawn by tag tool? |
1057 | //set the pen canvas to be the selected canvas | 1058 | //set the pen canvas to be the selected canvas |
1058 | this._penCanvas = this.application.ninja.selectedElements[i]._element; | 1059 | this._penCanvas = this.application.ninja.selectedElements[i]; |
1059 | 1060 | ||
1060 | // get the subpath for this world | 1061 | // get the subpath for this world |
1061 | this._selectedSubpath = null; | 1062 | this._selectedSubpath = null; |
@@ -1128,7 +1129,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
1128 | var els = []; | 1129 | var els = []; |
1129 | ElementController.removeElement(this._penCanvas); | 1130 | ElementController.removeElement(this._penCanvas); |
1130 | els.push(this._penCanvas); | 1131 | els.push(this._penCanvas); |
1131 | NJevent( "deleteSelection", els ); | 1132 | NJevent( "elementsRemoved", els ); |
1132 | this._penCanvas = null; | 1133 | this._penCanvas = null; |
1133 | } | 1134 | } |
1134 | } | 1135 | } |
@@ -1141,9 +1142,9 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
1141 | els.push(this.application.ninja.selectedElements[i]); | 1142 | els.push(this.application.ninja.selectedElements[i]); |
1142 | } | 1143 | } |
1143 | for(i=0; i<len; i++) { | 1144 | for(i=0; i<len; i++) { |
1144 | ElementController.removeElement(els[i]._element); | 1145 | ElementController.removeElement(els[i]); |
1145 | } | 1146 | } |
1146 | NJevent( "deleteSelection", els ); | 1147 | NJevent( "ele |