aboutsummaryrefslogtreecommitdiff
path: root/js/tools/drawing-tool-base.js
diff options
context:
space:
mode:
authorKruti Shah2012-05-31 10:44:45 -0700
committerKruti Shah2012-05-31 10:44:45 -0700
commitc350cc1c060fdf17357ddadce024267943784593 (patch)
tree453f86e88f1ee1dfda6fb4b7cc7b17e306e39536 /js/tools/drawing-tool-base.js
parentfdc4f5c7f81ae3b9adeca2232e60268b4be594a2 (diff)
parent121d0e616f48aa7cd048763554089c20a1883d7a (diff)
downloadninja-c350cc1c060fdf17357ddadce024267943784593.tar.gz
Merge branch 'refs/heads/TimelineUberjd' into TimelineUber
Conflicts: js/panels/Timeline/Layer.reel/Layer.js Signed-off-by: Kruti Shah <kruti.shah@motorola.com>
Diffstat (limited to 'js/tools/drawing-tool-base.js')
-rwxr-xr-xjs/tools/drawing-tool-base.js39
1 files changed, 13 insertions, 26 deletions
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js
index 84641754..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;
12var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; 12var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
13var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; 13var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils;
14 14
15exports.DrawingToolBase = Montage.create(Montage, { 15exports.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.model.documentRoot);
168 var stageOffset = viewUtils.getElementOffset(stage); 158 viewUtils.setViewportObj(this.application.ninja.currentDocument.model.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.model.documentRoot);
198 var stageOffset = viewUtils.getElementOffset(stage); 187 viewUtils.setViewportObj(this.application.ninja.currentDocument.model.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.model.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.model.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