diff options
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/BrushTool.js | 2 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 2 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 2 | ||||
-rwxr-xr-x | js/tools/RotateStage3DTool.js | 5 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 62 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 4 | ||||
-rwxr-xr-x | js/tools/TagTool.js | 19 | ||||
-rwxr-xr-x | js/tools/Translate3DToolBase.js | 7 | ||||
-rwxr-xr-x | js/tools/drawing-tool-base.js | 2 |
9 files changed, 59 insertions, 46 deletions
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, { | |||
252 | 252 | ||
253 | if (!canvas) { | 253 | if (!canvas) { |
254 | var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 254 | var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); |
255 | var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas); | 255 | var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas, this._useWebGL); |
256 | ElementMediator.addElement(newCanvas, elementModel.data, true); | 256 | ElementMediator.addElement(newCanvas, elementModel.data, true); |
257 | 257 | ||
258 | // create all the GL stuff | 258 | // 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, { | |||
89 | } | 89 | } |
90 | 90 | ||
91 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 91 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); |
92 | var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas); | 92 | var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas, this.options.use3D); |
93 | 93 | ||
94 | ElementMediator.addElement(canvas, elementModel.data, true); | 94 | ElementMediator.addElement(canvas, elementModel.data, true); |
95 | canvas.elementModel.isShape = true; | 95 | 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, { | |||
584 | if (!canvas) { | 584 | if (!canvas) { |
585 | var newCanvas = null; | 585 | var newCanvas = null; |
586 | newCanvas = NJUtils.makeNJElement("canvas", "Subpath", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 586 | newCanvas = NJUtils.makeNJElement("canvas", "Subpath", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); |
587 | var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas); | 587 | var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas, this._useWebGL); |
588 | ElementMediator.addElement(newCanvas, elementModel.data, true); | 588 | ElementMediator.addElement(newCanvas, elementModel.data, true); |
589 | 589 | ||
590 | // create all the GL stuff | 590 | // create all the GL stuff |
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, { | |||
76 | 76 | ||
77 | this._targets.push({elt:elt, mat:curMat, matInv:curMatInv, ctr:eltCtr}); | 77 | this._targets.push({elt:elt, mat:curMat, matInv:curMatInv, ctr:eltCtr}); |
78 | 78 | ||
79 | viewUtils.setMatrixForElement( elt, curMat, false ); | 79 | ElementsMediator.setMatrix(elt, curMat, false, "rotateStage3DTool"); |
80 | } | 80 | } |
81 | }, | 81 | }, |
82 | 82 | ||
@@ -130,7 +130,8 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { | |||
130 | // Reset stage to identity matrix | 130 | // Reset stage to identity matrix |
131 | var iMat = Matrix.I(4); | 131 | var iMat = Matrix.I(4); |
132 | 132 | ||
133 | ElementsMediator.setMatrix(this.application.ninja.currentDocument.documentRoot, iMat, false); | 133 | ElementsMediator.setMatrix(this.application.ninja.currentDocument.documentRoot, |
134 | iMat, false, "rotateStage3DTool"); | ||
134 | this.application.ninja.currentDocument.documentRoot.elementModel.props3D.m_transformCtr = null; | 135 | this.application.ninja.currentDocument.documentRoot.elementModel.props3D.m_transformCtr = null; |
135 | 136 | ||
136 | // let the document and stage manager know about the zoom change | 137 | // let the document and stage manager know about the zoom change |
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index f9411f48..aec5b6a3 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js | |||
@@ -318,18 +318,28 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
318 | this._targets.push({elt:elt, mat:curMat, matInv:curMatInv}); | 318 | this._targets.push({elt:elt, mat:curMat, matInv:curMatInv}); |
319 | if(addToUndoStack) | 319 | if(addToUndoStack) |
320 | { | 320 | { |
321 | var prevX, | ||
322 | prevY, | ||
323 | prevW, | ||
324 | prevH, | ||
325 | _x, | ||
326 | _y, | ||
327 | _w, | ||
328 | _h, | ||
329 | previousMat, | ||
330 | previousStyleStr, | ||
331 | newStyleStr; | ||
321 | 332 | ||
322 | if(!this._use3DMode) | 333 | if(!this._use3DMode) |
323 | { | 334 | { |
324 | var previousMat = this._undoArray[i].mat.slice(0); | 335 | prevX = this._undoArray[i]._x; |
325 | var prevX = this._undoArray[i]._x; | 336 | prevY = this._undoArray[i]._y; |
326 | var prevY = this._undoArray[i]._y; | 337 | prevW = this._undoArray[i]._w; |
327 | var prevW = this._undoArray[i]._w; | 338 | prevH = this._undoArray[i]._h; |
328 | var prevH = this._undoArray[i]._h; | 339 | _x = parseInt(ElementsMediator.getProperty(elt, "left")); |
329 | var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; | 340 | _y = parseInt(ElementsMediator.getProperty(elt, "top")); |
330 | var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; | 341 | _w = parseInt(ElementsMediator.getProperty(elt, "width")); |
331 | var _w = parseInt(ElementsMediator.getProperty(elt, "width")); | 342 | _h = parseInt(ElementsMediator.getProperty(elt, "height")); |
332 | var _h = parseInt(ElementsMediator.getProperty(elt, "height")); | ||
333 | 343 | ||
334 | previousLeft.push(prevX + "px"); | 344 | previousLeft.push(prevX + "px"); |
335 | previousTop.push(prevY + "px"); | 345 | previousTop.push(prevY + "px"); |
@@ -339,27 +349,22 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
339 | newTop.push(_y + "px"); | 349 | newTop.push(_y + "px"); |
340 | newWidth.push(_w + "px"); | 350 | newWidth.push(_w + "px"); |
341 | newHeight.push(_h + "px"); | 351 | newHeight.push(_h + "px"); |
342 | |||
343 | viewUtils.setMatrixForElement(elt, previousMat); | ||
344 | |||
345 | this._targets[i].mat = previousMat; | ||
346 | this._targets[i].matInv = glmat4.inverse(previousMat, []); | ||
347 | } | 352 | } |
348 | else | 353 | else |
349 | { | 354 | { |
350 | var previousMat = this._undoArray[i].mat.slice(0); | 355 | previousMat = this._undoArray[i].mat.slice(0); |
351 | var prevW = this._undoArray[i]._w; | 356 | prevW = this._undoArray[i]._w; |
352 | var prevH = this._undoArray[i]._h; | 357 | prevH = this._undoArray[i]._h; |
353 | var _w = parseInt(ElementsMediator.getProperty(elt, "width")); | 358 | _w = parseInt(ElementsMediator.getProperty(elt, "width")); |
354 | var _h = parseInt(ElementsMediator.getProperty(elt, "height")); | 359 | _h = parseInt(ElementsMediator.getProperty(elt, "height")); |
355 | previousWidth.push(prevW + "px"); | 360 | previousWidth.push(prevW + "px"); |
356 | previousHeight.push(prevH + "px"); | 361 | previousHeight.push(prevH + "px"); |
357 | newWidth.push(_w + "px"); | 362 | newWidth.push(_w + "px"); |
358 | newHeight.push(_h + "px"); | 363 | newHeight.push(_h + "px"); |
359 | 364 | ||
360 | var previousStyleStr = {dist:this._undoArray[i].dist, | 365 | previousStyleStr = {dist:this._undoArray[i].dist, |
361 | mat:MathUtils.scientificToDecimal(previousMat, 5)}; | 366 | mat:MathUtils.scientificToDecimal(previousMat, 5)}; |
362 | var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), | 367 | newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), |
363 | mat:MathUtils.scientificToDecimal(curMat, 5)}; | 368 | mat:MathUtils.scientificToDecimal(curMat, 5)}; |
364 | previousStyles.push(previousStyleStr); | 369 | previousStyles.push(previousStyleStr); |
365 | newStyles.push(newStyleStr); | 370 | newStyles.push(newStyleStr); |
@@ -460,11 +465,14 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
460 | } | 465 | } |
461 | else | 466 | else |
462 | { | 467 | { |
463 | curMat = item.mat.slice(0); | 468 | // curMat = item.mat.slice(0); |
464 | glmat4.multiply(curMat, qMat, curMat); | 469 | // glmat4.multiply(curMat, qMat, curMat); |
465 | var previousMat = this._undoArray[i].mat.slice(0); | 470 | // var previousMat = this._undoArray[i].mat.slice(0); |
466 | var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; | 471 | // var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; |
467 | var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; | 472 | // var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; |
473 | |||
474 | var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + transMat[12]; | ||
475 | var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + transMat[13]; | ||
468 | 476 | ||
469 | newLeft.push(_x + "px"); | 477 | newLeft.push(_x + "px"); |
470 | newTop.push(_y + "px"); | 478 | newTop.push(_y + "px"); |
@@ -577,6 +585,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
577 | { | 585 | { |
578 | // form the translation vector and post translate the matrix by it. | 586 | // form the translation vector and post translate the matrix by it. |
579 | delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); | 587 | delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); |
588 | delta[0] = ~~delta[0]; | ||
589 | delta[1] = ~~delta[1]; | ||
580 | delta[2] = 0; | 590 | delta[2] = 0; |
581 | var transMat = Matrix.Translation( delta ); | 591 | var transMat = Matrix.Translation( delta ); |
582 | this._moveElements(transMat); | 592 | this._moveElements(transMat); |
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 | |||
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | DrawingTool = require("js/tools/drawing-tool").DrawingTool, | 8 | DrawingTool = require("js/tools/drawing-tool").DrawingTool, |
9 | viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, | ||
10 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, | ||
11 | NJUtils = require("js/lib/NJUtils").NJUtils, | 9 | NJUtils = require("js/lib/NJUtils").NJUtils, |
12 | ElementMediator = require("js/mediators/element-mediator").ElementMediator, | 10 | ElementMediator = require("js/mediators/element-mediator").ElementMediator, |
13 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, | 11 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, |
@@ -70,7 +68,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
70 | { | 68 | { |
71 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 69 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); |
72 | var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, | 70 | var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, |
73 | drawData.planeMat, drawData.midPt, canvas); | 71 | drawData.planeMat, drawData.midPt, canvas, this.options.use3D); |
74 | 72 | ||
75 | ElementMediator.addElement(canvas, elementModel.data, true); | 73 | ElementMediator.addElement(canvas, elementModel.data, true); |
76 | canvas.elementModel.isShape = true; | 74 | canvas.elementModel.isShape = true; |
diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index e3f49bbe..2b6742e6 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js | |||
@@ -221,22 +221,23 @@ exports.TagTool = Montage.create(DrawingTool, { | |||
221 | }, | 221 | }, |
222 | 222 | ||
223 | makeElement: { | 223 | makeEle |