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/RotateObject3DTool.js | 1 | ||||
-rwxr-xr-x | js/tools/RotateStage3DTool.js | 5 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 61 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 5 | ||||
-rwxr-xr-x | js/tools/TagTool.js | 19 | ||||
-rwxr-xr-x | js/tools/Translate3DToolBase.js | 7 | ||||
-rwxr-xr-x | js/tools/TranslateObject3DTool.js | 12 | ||||
-rwxr-xr-x | js/tools/drawing-tool-base.js | 2 |
11 files changed, 69 insertions, 49 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 2171d2c6..d71cc743 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js | |||
@@ -305,7 +305,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
305 | 305 | ||
306 | if (!canvas) { | 306 | if (!canvas) { |
307 | var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 307 | var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); |
308 | var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas); | 308 | var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas, this._useWebGL); |
309 | ElementMediator.addElements(newCanvas, elementModel.data, false); | 309 | ElementMediator.addElements(newCanvas, elementModel.data, false); |
310 | 310 | ||
311 | // create all the GL stuff | 311 | // create all the GL stuff |
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index e6e05b04..de2eb21d 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js | |||
@@ -78,7 +78,7 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
78 | } | 78 | } |
79 | 79 | ||
80 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 80 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); |
81 | var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas); | 81 | var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas, this.options.use3D); |
82 | canvas.elementModel.isShape = true; | 82 | canvas.elementModel.isShape = true; |
83 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); | 83 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); |
84 | } else { | 84 | } else { |
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 4a16a491..aa14ea75 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.addElements(newCanvas, elementModel.data, false); | 588 | ElementMediator.addElements(newCanvas, elementModel.data, false); |
589 | 589 | ||
590 | // create all the GL stuff | 590 | // create all the GL stuff |
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, { | |||
51 | toolHandle._rotMat = Matrix.RotationZ( angle ); | 51 | toolHandle._rotMat = Matrix.RotationZ( angle ); |
52 | } | 52 | } |
53 | } | 53 | } |
54 | this._inLocalMode = (this.options.selectedMode === "rotateLocally"); | ||
54 | } | 55 | } |
55 | }, | 56 | }, |
56 | 57 | ||
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 74784485..94cc6b83 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js | |||
@@ -317,16 +317,27 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
317 | 317 | ||
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 | var prevX, | ||
321 | prevY, | ||
322 | prevW, | ||
323 | prevH, | ||
324 | _x, | ||
325 | _y, | ||
326 | _w, | ||
327 | _h, | ||
328 | previousMat, | ||
329 | previousStyleStr, | ||
330 | newStyleStr; | ||
331 | |||
320 | if(!this._use3DMode) { | 332 | if(!this._use3DMode) { |
321 | var previousMat = this._undoArray[i].mat.slice(0); | 333 | prevX = this._undoArray[i]._x; |
322 | var prevX = this._undoArray[i]._x; | 334 | prevY = this._undoArray[i]._y; |
323 | var prevY = this._undoArray[i]._y; | 335 | prevW = this._undoArray[i]._w; |
324 | var prevW = this._undoArray[i]._w; | 336 | prevH = this._undoArray[i]._h; |
325 | var prevH = this._undoArray[i]._h; | 337 | _x = parseInt(ElementsMediator.getProperty(elt, "left")); |
326 | var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; | 338 | _y = parseInt(ElementsMediator.getProperty(elt, "top")); |
327 | var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; | 339 | _w = parseInt(ElementsMediator.getProperty(elt, "width")); |
328 | var _w = parseInt(ElementsMediator.getProperty(elt, "width")); | 340 | _h = parseInt(ElementsMediator.getProperty(elt, "height")); |
329 | var _h = parseInt(ElementsMediator.getProperty(elt, "height")); | ||
330 | 341 | ||
331 | previousLeft.push(prevX + "px"); | 342 | previousLeft.push(prevX + "px"); |
332 | previousTop.push(prevY + "px"); | 343 | previousTop.push(prevY + "px"); |
@@ -336,25 +347,22 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
336 | newTop.push(_y + "px"); | 347 | newTop.push(_y + "px"); |
337 | newWidth.push(_w + "px"); | 348 | newWidth.push(_w + "px"); |
338 | newHeight.push(_h + "px"); | 349 | newHeight.push(_h + "px"); |
339 | 350 | } | |
340 | viewUtils.setMatrixForElement(elt, previousMat); | 351 | else |
341 | 352 | { | |
342 | this._targets[i].mat = previousMat; | 353 | previousMat = this._undoArray[i].mat.slice(0); |
343 | this._targets[i].matInv = glmat4.inverse(previousMat, []); | 354 | prevW = this._undoArray[i]._w; |
344 | } else { | 355 | prevH = this._undoArray[i]._h; |
345 | var previousMat = this._undoArray[i].mat.slice(0); | 356 | _w = parseInt(ElementsMediator.getProperty(elt, "width")); |
346 | var prevW = this._undoArray[i]._w; | 357 | _h = parseInt(ElementsMediator.getProperty(elt, "height")); |
347 | var prevH = this._undoArray[i]._h; | ||
348 | var _w = parseInt(ElementsMediator.getProperty(elt, "width")); | ||
349 | var _h = parseInt(ElementsMediator.getProperty(elt, "height")); | ||
350 | previousWidth.push(prevW + "px"); | 358 | previousWidth.push(prevW + "px"); |
351 | previousHeight.push(prevH + "px"); | 359 | previousHeight.push(prevH + "px"); |
352 | newWidth.push(_w + "px"); | 360 | newWidth.push(_w + "px"); |
353 | newHeight.push(_h + "px"); | 361 | newHeight.push(_h + "px"); |
354 | 362 | ||
355 | var previousStyleStr = {dist:this._undoArray[i].dist, | 363 | previousStyleStr = {dist:this._undoArray[i].dist, |
356 | mat:MathUtils.scientificToDecimal(previousMat, 5)}; | 364 | mat:MathUtils.scientificToDecimal(previousMat, 5)}; |
357 | var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), | 365 | newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), |
358 | mat:MathUtils.scientificToDecimal(curMat, 5)}; | 366 | mat:MathUtils.scientificToDecimal(curMat, 5)}; |
359 | previousStyles.push(previousStyleStr); | 367 | previousStyles.push(previousStyleStr); |
360 | newStyles.push(newStyleStr); | 368 | newStyles.push(newStyleStr); |
@@ -455,11 +463,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
455 | } | 463 | } |
456 | else | 464 | else |
457 | { | 465 | { |
458 | curMat = item.mat.slice(0); | 466 | var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + transMat[12]; |
459 | glmat4.multiply(curMat, qMat, curMat); | 467 | var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + transMat[13]; |
460 | var previousMat = this._undoArray[i].mat.slice(0); | ||
461 | var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; | ||
462 | var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; | ||
463 | 468 | ||
464 | newLeft.push(_x + "px"); | 469 | newLeft.push(_x + "px"); |
465 | newTop.push(_y + "px"); | 470 | newTop.push(_y + "px"); |
@@ -572,6 +577,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
572 | { | 577 | { |
573 | // form the translation vector and post translate the matrix by it. | 578 | // form the translation vector and post translate the matrix by it. |
574 | delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); | 579 | delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); |
580 | delta[0] = ~~delta[0]; | ||
581 | delta[1] = ~~delta[1]; | ||
575 | delta[2] = 0; | 582 | delta[2] = 0; |
576 | var transMat = Matrix.Translation( delta ); | 583 | var transMat = Matrix.Translation( delta ); |
577 | this._moveElements(transMat); | 584 | this._moveElements(transMat); |
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 4d8a318e..00d36528 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 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, | 10 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, |
13 | ShapeModel = require("js/models/shape-model").ShapeModel, | 11 | ShapeModel = require("js/models/shape-model").ShapeModel, |
@@ -67,7 +65,8 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
67 | var canvas; | 65 | var canvas; |
68 | if(!this._useExistingCanvas()) { | 66 | if(!this._useExistingCanvas()) { |
69 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 67 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); |
70 | var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, drawData.planeMat, drawData.midPt, canvas); | 68 | var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, |
69 | drawData.planeMat, drawData.midPt, canvas, this.options.use3D); | ||
71 | 70 | ||
72 | canvas.elementModel.isShape = true; | 71 | canvas.elementModel.isShape = true; |
73 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); | 72 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); |