diff options
author | Ananya Sen | 2012-05-31 10:13:40 -0700 |
---|---|---|
committer | Ananya Sen | 2012-05-31 10:13:40 -0700 |
commit | 286457b4f23974277274ba388afd283e8aa085cb (patch) | |
tree | c21bf791e7c4f572d12f97987ea6b89e74da67fe /js/tools/drawing-tool-base.js | |
parent | 4d9b481c58090e8f1fc7b0e9d73a81b0f49cccc8 (diff) | |
parent | d49c909cff7f0c5e5d0b127ad84a2fefc6677dc6 (diff) | |
download | ninja-286457b4f23974277274ba388afd283e8aa085cb.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into cut-copy-paste
Conflicts:
js/controllers/styles-controller.js
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/tools/drawing-tool-base.js')
-rwxr-xr-x | js/tools/drawing-tool-base.js | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 376b3a27..3549de1c 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 |
@@ -36,9 +26,8 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
36 | * 2 - Y value converted to screen point | 26 | * 2 - Y value converted to screen point |
37 | */ | 27 | */ |
38 | getInitialSnapPoint: { | 28 | getInitialSnapPoint: { |
39 | value: function(x, y, shapeCanvas) { | 29 | value: function(x, y, shapeCanvas) |
40 | snapManager.clearDragPlane(); | 30 | { |
41 | |||
42 | // update the snap settings | 31 | // update the snap settings |
43 | snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); | 32 | snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); |
44 | snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); | 33 | snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); |
@@ -165,9 +154,8 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
165 | // get the hit rec. points in plane space | 154 | // get the hit rec. points in plane space |
166 | var psPos = hitRec.getLocalPoint(); | 155 | var psPos = hitRec.getLocalPoint(); |
167 | 156 | ||
168 | var stage = this.stage; | 157 | var stageOffset = viewUtils.getElementOffset(this.application.ninja.currentDocument.model.documentRoot); |
169 | var stageOffset = viewUtils.getElementOffset(stage); | 158 | viewUtils.setViewportObj(this.application.ninja.currentDocument.model.documentRoot); |
170 | viewUtils.setViewportObj(stage); | ||
171 | 159 | ||
172 | // get the matrix taking the local hit point in plane space | 160 | // get the matrix taking the local hit point in plane space |
173 | // to world space of whatever element it is in. | 161 | // to world space of whatever element it is in. |
@@ -195,9 +183,8 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
195 | var p0 = hitRec0.getLocalPoint(), | 183 | var p0 = hitRec0.getLocalPoint(), |
196 | p1 = hitRec1.getLocalPoint(); | 184 | p1 = hitRec1.getLocalPoint(); |
197 | 185 | ||
198 | var stage = this.stage; | 186 | var stageOffset = viewUtils.getElementOffset(this.application.ninja.currentDocument.model.documentRoot); |
199 | var stageOffset = viewUtils.getElementOffset(stage); | 187 | viewUtils.setViewportObj(this.application.ninja.currentDocument.model.documentRoot); |
200 | viewUtils.setViewportObj(stage); | ||
201 | 188 | ||
202 | // get the matrix taking the local hit point in plane space | 189 | // get the matrix taking the local hit point in plane space |
203 | // to world space of whatever element it is in. | 190 | // to world space of whatever element it is in. |
@@ -302,10 +289,10 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
302 | 289 | ||
303 | draw2DRectangle: { | 290 | draw2DRectangle: { |
304 | value: function(x0, y0, x1, y1) { | 291 | value: function(x0, y0, x1, y1) { |
305 | var drawingContext = this.stageComponent.drawingContext, | 292 | var drawingContext = this.application.ninja.stage.drawingContext, |
306 | drawingPrefs = this.stageComponent.drawingContextPreferences; | 293 | drawingPrefs = this.application.ninja.stage.drawingContextPreferences; |
307 | 294 | ||
308 | this.stageComponent.clearDrawingCanvas(); | 295 | this.application.ninja.stage.clearDrawingCanvas(); |
309 | //TODO Save and restore state | 296 | //TODO Save and restore state |
310 | drawingContext.strokeStyle = drawingPrefs.color; | 297 | drawingContext.strokeStyle = drawingPrefs.color; |
311 | drawingContext.lineWidth = drawingPrefs.thickness; | 298 | drawingContext.lineWidth = drawingPrefs.thickness; |
@@ -321,11 +308,10 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
321 | var p0 = hitRec0.getLocalPoint(), | 308 | var p0 = hitRec0.getLocalPoint(), |
322 | p1 = hitRec1.getLocalPoint(); | 309 | p1 = hitRec1.getLocalPoint(); |
323 | 310 | ||
324 | var stage = this.stage; | 311 | var stageMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.model.documentRoot); |
325 | var stageMat = viewUtils.getMatrixFromElement( stage ); | ||
326 | var elt = hitRec0.getElt(); | 312 | var elt = hitRec0.getElt(); |
327 | if (!elt) { elt = hitRec1.getElt(); } | 313 | if (!elt) { elt = hitRec1.getElt(); } |
328 | if (!elt) { elt = stage; } | 314 | if (!elt) { elt = this.application.ninja.currentDocument.model.documentRoot; } |
329 | if (elt) | 315 | if (elt) |
330 | { | 316 | { |
331 | viewUtils.pushViewportObj(elt); | 317 | viewUtils.pushViewportObj(elt); |
@@ -421,11 +407,11 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
421 | if ( isProjected) | 407 | if ( isProjected) |
422 | { | 408 | { |
423 | var unprojPtArr = [s0, s1, s2, s3]; | 409 | var unprojPtArr = [s0, s1, s2, s3]; |
424 | this.stageComponent.draw3DProjectedAndUnprojectedRectangles( unprojPtArr, projPtArr ); | 410 | this.application.ninja.stage.draw3DProjectedAndUnprojectedRectangles( unprojPtArr, projPtArr ); |
425 | } | 411 | } |
426 | else | 412 | else |
427 | { | 413 | { |
428 | this.stageComponent.draw3DSelectionRectangle(s0[0], s0[1], | 414 | this.application.ninja.stage.draw3DSelectionRectangle(s0[0], s0[1], |
429 | s1[0], s1[1], | 415 | s1[0], s1[1], |
430 | s2[0], s2[1], | 416 | s2[0], s2[1], |
431 | s3[0], s3[1], | 417 | s3[0], s3[1], |
@@ -441,7 +427,7 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
441 | value: function (hitRec0, hitRec1, strokeSize, strokeColor) { | 427 | value: function (hitRec0, hitRec1, strokeSize, strokeColor) { |
442 | var p0 = hitRec0.getScreenPoint(), | 428 | var p0 = hitRec0.getScreenPoint(), |
443 | p1 = hitRec1.getScreenPoint(); | 429 | p1 = hitRec1.getScreenPoint(); |
444 | 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); |
445 | } | 431 | } |
446 | }, | 432 | }, |
447 | 433 | ||