diff options
Diffstat (limited to 'js/tools')
-rwxr-xr-x | js/tools/ShapeTool.js | 2 | ||||
-rwxr-xr-x | js/tools/drawing-tool-base.js | 39 |
2 files changed, 14 insertions, 27 deletions
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 0562dbc2..367ab78d 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js | |||
@@ -72,7 +72,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
72 | if(!canvas.elementModel.shapeModel) { | 72 | if(!canvas.elementModel.shapeModel) { |
73 | canvas.elementModel.shapeModel = Montage.create(ShapeModel); | 73 | canvas.elementModel.shapeModel = Montage.create(ShapeModel); |
74 | } | 74 | } |
75 | this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data); | 75 | this.RenderShape(drawData.width, drawData.height, drawData.planeMat, drawData.midPt, canvas); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 84641754..0a3767b5 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js | |||
@@ -12,17 +12,7 @@ var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; | |||
12 | var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; | 12 | var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; |
13 | var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; | 13 | var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; |
14 | 14 | ||
15 | exports.DrawingToolBase = Montage.create(Montage, { | 15 | exports.DrawingToolBase = Montage.create(Component, { |
16 | |||
17 | //!!!! HACK | ||
18 | // TODO: Need to find a better way to address this | ||
19 | stage: { | ||
20 | value: null | ||
21 | }, | ||
22 | |||
23 | stageComponent: { | ||
24 | value: null | ||
25 | }, | ||
26 | 16 | ||
27 | dragPlane: { | 17 | dragPlane: { |
28 | value: null | 18 | value: null |
@@ -164,9 +154,8 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
164 | // get the hit rec. points in plane space | 154 | // get the hit rec. points in plane space |
165 | var psPos = hitRec.getLocalPoint(); | 155 | var psPos = hitRec.getLocalPoint(); |
166 | 156 | ||
167 | var stage = this.stage; | 157 | var stageOffset = viewUtils.getElementOffset(this.application.ninja.currentDocument.documentRoot); |
168 | var stageOffset = viewUtils.getElementOffset(stage); | 158 | viewUtils.setViewportObj(this.application.ninja.currentDocument.documentRoot); |
169 | viewUtils.setViewportObj(stage); | ||
170 | 159 | ||
171 | // get the matrix taking the local hit point in plane space | 160 | // get the matrix taking the local hit point in plane space |
172 | // to world space of whatever element it is in. | 161 | // to world space of whatever element it is in. |
@@ -194,9 +183,8 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
194 | var p0 = hitRec0.getLocalPoint(), | 183 | var p0 = hitRec0.getLocalPoint(), |
195 | p1 = hitRec1.getLocalPoint(); | 184 | p1 = hitRec1.getLocalPoint(); |
196 | 185 | ||
197 | var stage = this.stage; | 186 | var stageOffset = viewUtils.getElementOffset(this.application.ninja.currentDocument.documentRoot); |
198 | var stageOffset = viewUtils.getElementOffset(stage); | 187 | viewUtils.setViewportObj(this.application.ninja.currentDocument.documentRoot); |
199 | viewUtils.setViewportObj(stage); | ||
200 | 188 | ||
201 | // get the matrix taking the local hit point in plane space | 189 | // get the matrix taking the local hit point in plane space |
202 | // to world space of whatever element it is in. | 190 | // to world space of whatever element it is in. |
@@ -301,10 +289,10 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
301 | 289 | ||
302 | draw2DRectangle: { | 290 | draw2DRectangle: { |
303 | value: function(x0, y0, x1, y1) { | 291 | value: function(x0, y0, x1, y1) { |
304 | var drawingContext = this.stageComponent.drawingContext, | 292 | var drawingContext = this.application.ninja.stage.drawingContext, |
305 | drawingPrefs = this.stageComponent.drawingContextPreferences; | 293 | drawingPrefs = this.application.ninja.stage.drawingContextPreferences; |
306 | 294 | ||
307 | this.stageComponent.clearDrawingCanvas(); | 295 | this.application.ninja.stage.clearDrawingCanvas(); |
308 | //TODO Save and restore state | 296 | //TODO Save and restore state |
309 | drawingContext.strokeStyle = drawingPrefs.color; | 297 | drawingContext.strokeStyle = drawingPrefs.color; |
310 | drawingContext.lineWidth = drawingPrefs.thickness; | 298 | drawingContext.lineWidth = drawingPrefs.thickness; |
@@ -320,11 +308,10 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
320 | var p0 = hitRec0.getLocalPoint(), | 308 | var p0 = hitRec0.getLocalPoint(), |
321 | p1 = hitRec1.getLocalPoint(); | 309 | p1 = hitRec1.getLocalPoint(); |
322 | 310 | ||
323 | var stage = this.stage; | 311 | var stageMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.documentRoot); |
324 | var stageMat = viewUtils.getMatrixFromElement( stage ); | ||
325 | var elt = hitRec0.getElt(); | 312 | var elt = hitRec0.getElt(); |
326 | if (!elt) { elt = hitRec1.getElt(); } | 313 | if (!elt) { elt = hitRec1.getElt(); } |
327 | if (!elt) { elt = stage; } | 314 | if (!elt) { elt = this.application.ninja.currentDocument.documentRoot; } |
328 | if (elt) | 315 | if (elt) |
329 | { | 316 | { |
330 | viewUtils.pushViewportObj(elt); | 317 | viewUtils.pushViewportObj(elt); |
@@ -420,11 +407,11 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
420 | if ( isProjected) | 407 | if ( isProjected) |
421 | { | 408 | { |
422 | var unprojPtArr = [s0, s1, s2, s3]; | 409 | var unprojPtArr = [s0, s1, s2, s3]; |
423 | this.stageComponent.draw3DProjectedAndUnprojectedRectangles( unprojPtArr, projPtArr ); | 410 | this.application.ninja.stage.draw3DProjectedAndUnprojectedRectangles( unprojPtArr, projPtArr ); |
424 | } | 411 | } |
425 | else | 412 | else |
426 | { | 413 | { |
427 | this.stageComponent.draw3DSelectionRectangle(s0[0], s0[1], | 414 | this.application.ninja.stage.draw3DSelectionRectangle(s0[0], s0[1], |
428 | s1[0], s1[1], | 415 | s1[0], s1[1], |
429 | s2[0], s2[1], | 416 | s2[0], s2[1], |
430 | s3[0], s3[1], | 417 | s3[0], s3[1], |
@@ -440,7 +427,7 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
440 | value: function (hitRec0, hitRec1, strokeSize, strokeColor) { | 427 | value: function (hitRec0, hitRec1, strokeSize, strokeColor) { |
441 | var p0 = hitRec0.getScreenPoint(), | 428 | var p0 = hitRec0.getScreenPoint(), |
442 | p1 = hitRec1.getScreenPoint(); | 429 | p1 = hitRec1.getScreenPoint(); |
443 | this.stageComponent.drawLine(p0[0], p0[1], p1[0], p1[1], strokeSize, strokeColor); | 430 | this.application.ninja.stage.drawLine(p0[0], p0[1], p1[0], p1[1], strokeSize, strokeColor); |
444 | } | 431 | } |
445 | }, | 432 | }, |
446 | 433 | ||