diff options
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/BrushTool.js | 6 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 7 | ||||
-rwxr-xr-x | js/tools/OvalTool.js | 9 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 25 | ||||
-rwxr-xr-x | js/tools/RectTool.js | 9 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 4 | ||||
-rwxr-xr-x | js/tools/drawing-tool-base.js | 18 |
7 files changed, 47 insertions, 31 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 8b0f60bb..dd201f33 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js | |||
@@ -14,6 +14,8 @@ var ElementMediator = require("js/mediators/element-mediator").ElementMediator; | |||
14 | var TagTool = require("js/tools/TagTool").TagTool; | 14 | var TagTool = require("js/tools/TagTool").TagTool; |
15 | var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; | 15 | var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; |
16 | 16 | ||
17 | var BrushStroke = require("js/lib/geom/brush-stroke").BrushStroke; | ||
18 | |||
17 | exports.BrushTool = Montage.create(ShapeTool, { | 19 | exports.BrushTool = Montage.create(ShapeTool, { |
18 | hasReel: { value: false }, | 20 | hasReel: { value: false }, |
19 | _toolID: { value: "brushTool" }, | 21 | _toolID: { value: "brushTool" }, |
@@ -64,7 +66,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
64 | } | 66 | } |
65 | //start a new brush stroke | 67 | //start a new brush stroke |
66 | if (this._selectedBrushStroke === null){ | 68 | if (this._selectedBrushStroke === null){ |
67 | this._selectedBrushStroke = new GLBrushStroke(); | 69 | this._selectedBrushStroke = new BrushStroke(); |
68 | if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ | 70 | if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ |
69 | this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); | 71 | this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); |
70 | } | 72 | } |
@@ -205,7 +207,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
205 | var bboxMax = this._selectedBrushStroke.getBBoxMax(); | 207 | var bboxMax = this._selectedBrushStroke.getBBoxMax(); |
206 | var bboxWidth = bboxMax[0] - bboxMin[0]; | 208 | var bboxWidth = bboxMax[0] - bboxMin[0]; |
207 | var bboxHeight = bboxMax[1] - bboxMin[1]; | 209 | var bboxHeight = bboxMax[1] - bboxMin[1]; |
208 | var bboxMid = Vector.create([0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])]); | 210 | var bboxMid = [0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])]; |
209 | 211 | ||
210 | this._selectedBrushStroke.setCanvasX(bboxMid[0]); | 212 | this._selectedBrushStroke.setCanvasX(bboxMid[0]); |
211 | this._selectedBrushStroke.setCanvasY(bboxMid[1]); | 213 | this._selectedBrushStroke.setCanvasY(bboxMid[1]); |
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 32572af1..a61f8f79 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js | |||
@@ -13,6 +13,9 @@ var Montage = require("montage/core/core").Montage, | |||
13 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, | 13 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, |
14 | ShapeModel = require("js/models/shape-model").ShapeModel; | 14 | ShapeModel = require("js/models/shape-model").ShapeModel; |
15 | 15 | ||
16 | var Line = require("js/lib/geom/line").Line; | ||
17 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; | ||
18 | |||
16 | exports.LineTool = Montage.create(ShapeTool, { | 19 | exports.LineTool = Montage.create(ShapeTool, { |
17 | _toolID: { value: "lineTool" }, | 20 | _toolID: { value: "lineTool" }, |
18 | _imageID: { value: "lineToolImg" }, | 21 | _imageID: { value: "lineToolImg" }, |
@@ -211,7 +214,7 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
211 | var strokeM = this.options.strokeMaterial; | 214 | var strokeM = this.options.strokeMaterial; |
212 | if(strokeM) | 215 | if(strokeM) |
213 | { | 216 | { |
214 | strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); | 217 | strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); |
215 | } | 218 | } |
216 | } | 219 | } |
217 | 220 | ||
@@ -220,7 +223,7 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
220 | var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); | 223 | var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); |
221 | var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); | 224 | var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); |
222 | 225 | ||
223 | var line = new GLLine(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); | 226 | var line = new Line(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); |
224 | 227 | ||
225 | world.addObject(line); | 228 | world.addObject(line); |
226 | world.render(); | 229 | world.render(); |
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index 911059a7..a10e0bb5 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js | |||
@@ -8,6 +8,9 @@ var Montage = require("montage/core/core").Montage, | |||
8 | ShapeTool = require("js/tools/ShapeTool").ShapeTool, | 8 | ShapeTool = require("js/tools/ShapeTool").ShapeTool, |
9 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController; | 9 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController; |
10 | 10 | ||
11 | var Circle = require("js/lib/geom/circle").Circle; | ||
12 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; | ||
13 | |||
11 | exports.OvalTool = Montage.create(ShapeTool, { | 14 | exports.OvalTool = Montage.create(ShapeTool, { |
12 | 15 | ||
13 | _toolID: { value: "ovalTool" }, | 16 | _toolID: { value: "ovalTool" }, |
@@ -48,13 +51,13 @@ exports.OvalTool = Montage.create(ShapeTool, { | |||
48 | var strokeM = this.options.strokeMaterial; | 51 | var strokeM = this.options.strokeMaterial; |
49 | if(strokeM) | 52 | if(strokeM) |
50 | { | 53 | { |
51 | strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); | 54 | strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); |
52 | } | 55 | } |
53 | 56 | ||
54 | var fillM = this.options.fillMaterial; | 57 | var fillM = this.options.fillMaterial; |
55 | if(fillM) | 58 | if(fillM) |
56 | { | 59 | { |
57 | fillMaterial = Object.create(MaterialsLibrary.getMaterial(fillM)); | 60 | fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); |
58 | } | 61 | } |
59 | } | 62 | } |
60 | 63 | ||
@@ -63,7 +66,7 @@ exports.OvalTool = Montage.create(ShapeTool, { | |||
63 | var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); | 66 | var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); |
64 | var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); | 67 | var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); |
65 | 68 | ||
66 | var oval = new GLCircle(); | 69 | var oval = new Circle(); //GLCircle(); |
67 | oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); | 70 | oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); |
68 | 71 | ||
69 | world.addObject(oval); | 72 | world.addObject(oval); |
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 02367328..6897c003 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -15,6 +15,9 @@ var TagTool = require("js/tools/TagTool").TagTool; | |||
15 | var ElementController = require("js/controllers/elements/element-controller").ElementController; | 15 | var ElementController = require("js/controllers/elements/element-controller").ElementController; |
16 | var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; | 16 | var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; |
17 | 17 | ||
18 | var AnchorPoint = require("js/lib/geom/anchor-point").AnchorPoint; | ||
19 | var SubPath = require("js/lib/geom/sub-path").SubPath; | ||
20 | |||
18 | //todo remove this global var | 21 | //todo remove this global var |
19 | var g_DoPenToolMouseMove = true; | 22 | var g_DoPenToolMouseMove = true; |
20 | 23 | ||
@@ -146,7 +149,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
146 | if (mouseDownPos) { | 149 | if (mouseDownPos) { |
147 | //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath | 150 | //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath |
148 | if (this._selectedSubpath === null) { | 151 | if (this._selectedSubpath === null) { |
149 | this._selectedSubpath = new GLSubpath(); | 152 | this._selectedSubpath = new SubPath(); |
150 | this._isNewPath = true; | 153 | this._isNewPath = true; |
151 | if (this._entryEditMode === this.ENTRY_SELECT_PATH){ | 154 | if (this._entryEditMode === this.ENTRY_SELECT_PATH){ |
152 | //this should not happen, as ENTRY_SELECT_PATH implies there was a selected subpath | 155 | //this should not happen, as ENTRY_SELECT_PATH implies there was a selected subpath |
@@ -212,13 +215,13 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
212 | this._penCanvas = null; | 215 | this._penCanvas = null; |
213 | this._penPlaneMat = null; | 216 | this._penPlaneMat = null; |
214 | this._snapTarget = null; | 217 | this._snapTarget = null; |
215 | this._selectedSubpath = new GLSubpath(); | 218 | this._selectedSubpath = new SubPath(); |
216 | this._isNewPath = true; | 219 | this._isNewPath = true; |
217 | } | 220 | } |
218 | 221 | ||
219 | //add an anchor point to end of the subpath, and make it the selected anchor point | 222 | //add an anchor point to end of the subpath, and make it the selected anchor point |
220 | if (!this._selectedSubpath.getIsClosed() || this._makeMultipleSubpaths) { | 223 | if (!this._selectedSubpath.getIsClosed() || this._makeMultipleSubpaths) { |
221 | this._selectedSubpath.addAnchor(new GLAnchorPoint()); | 224 | this._selectedSubpath.addAnchor(new AnchorPoint()); |
222 | var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); | 225 | var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); |
223 | newAnchor.setPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); | 226 | newAnchor.setPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); |
224 | newAnchor.setPrevPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); | 227 | newAnchor.setPrevPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); |
@@ -231,7 +234,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
231 | if (this._isPickedEndPointInSelectPathMode){ | 234 | if (this._isPickedEndPointInSelectPathMode){ |
232 | //TODO clean up this code...very similar to the code block above | 235 | //TODO clean up this code...very similar to the code block above |
233 | if (!this._selectedSubpath.getIsClosed()) { | 236 | if (!this._selectedSubpath.getIsClosed()) { |
234 | this._selectedSubpath.addAnchor(new GLAnchorPoint()); | 237 | this._selectedSubpath.addAnchor(new AnchorPoint()); |
235 | var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); | 238 | var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); |
236 | newAnchor.setPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); | 239 | newAnchor.setPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); |
237 | newAnchor.setPrevPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); | 240 | newAnchor.setPrevPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); |
@@ -399,7 +402,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
399 | var bboxMax = this._selectedSubpath.getBBoxMax(); | 402 | var bboxMax = this._selectedSubpath.getBBoxMax(); |
400 | var bboxWidth = bboxMax[0] - bboxMin[0]; | 403 | var bboxWidth = bboxMax[0] - bboxMin[0]; |
401 | var bboxHeight = bboxMax[1] - bboxMin[1]; | 404 | var bboxHeight = bboxMax[1] - bboxMin[1]; |
402 | var bboxMid = Vector.create([0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])]); | 405 | var bboxMid = [0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])]; |
403 | 406 | ||
404 | this._selectedSubpath.setCanvasX(bboxMid[0]); | 407 | this._selectedSubpath.setCanvasX(bboxMid[0]); |
405 | this._selectedSubpath.setCanvasY(bboxMid[1]); | 408 | this._selectedSubpath.setCanvasY(bboxMid[1]); |
@@ -648,7 +651,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
648 | var baseline = VecUtils.vecNormalize(3, baselineOrig); | 651 | var baseline = VecUtils.vecNormalize(3, baselineOrig); |
649 | var delta = VecUtils.vecSubtract(3, p2, p3); | 652 | var delta = VecUtils.vecSubtract(3, p2, p3); |
650 | //component of the delta along baseline | 653 | //component of the delta along baseline |
651 | var deltaB = Vector.create(baseline); | 654 | var deltaB = baseline; |
652 | VecUtils.vecScale(3, deltaB, VecUtils.vecDot(3, baseline, delta)); | 655 | VecUtils.vecScale(3, deltaB, VecUtils.vecDot(3, baseline, delta)); |
653 | //component of the delta orthogonal to baseline | 656 | //component of the delta orthogonal to baseline |
654 | var deltaO = VecUtils.vecSubtract(3, delta, deltaB); | 657 | var deltaO = VecUtils.vecSubtract(3, delta, deltaB); |
@@ -665,7 +668,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
665 | //if there is a selected anchor point | 668 | //if there is a selected anchor point |
666 | if (this._selectedSubpath && this._selectedSubpath.getSelectedAnchorIndex() !== -1) { | 669 | if (this._selectedSubpath && this._selectedSubpath.getSelectedAnchorIndex() !== -1) { |
667 | var selAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); | 670 | var selAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); |
668 | var pos = Vector.create([selAnchor.getPosX(), selAnchor.getPosY(), selAnchor.getPosZ()]); | 671 | var pos = [selAnchor.getPosX(), selAnchor.getPosY(), selAnchor.getPosZ()]; |
669 | var distToPrev = selAnchor.getPrevDistanceSq(pos[0], pos[1], pos[2]); | 672 | var distToPrev = selAnchor.getPrevDistanceSq(pos[0], pos[1], pos[2]); |
670 | var distToNext = selAnchor.getNextDistanceSq(pos[0], pos[1], pos[2]); | 673 | var distToNext = selAnchor.getNextDistanceSq(pos[0], pos[1], pos[2]); |
671 | var threshSq = 0; // 4 * this._PICK_POINT_RADIUS * this._PICK_POINT_RADIUS; | 674 | var threshSq = 0; // 4 * this._PICK_POINT_RADIUS * this._PICK_POINT_RADIUS; |
@@ -681,8 +684,8 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
681 | nextAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()+1); | 684 | nextAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()+1); |
682 | else | 685 | else |
683 | nextAnchor = this._selectedSubpath.getAnchor(0); | 686 | nextAnchor = this._selectedSubpath.getAnchor(0); |
684 | var nextAnchorPrev = Vector.create([nextAnchor.getPrevX(), nextAnchor.getPrevY(), nextAnchor.getPrevZ()]); | 687 |