aboutsummaryrefslogtreecommitdiff
path: root/js/tools/drawing-tool-base.js
diff options
context:
space:
mode:
authorJon Reid2012-05-15 11:24:53 -0700
committerJon Reid2012-05-15 11:24:53 -0700
commit3e02135df2ee028ae43d0e2456c04e24ecee0e86 (patch)
treed6dcab6756e3da0038a39527cfe0f9ca89e92310 /js/tools/drawing-tool-base.js
parent53a604d0ccb1315576b94406cf3b0b958162307b (diff)
parente33a4e58c271a9507082694a5268b840fdd05968 (diff)
downloadninja-3e02135df2ee028ae43d0e2456c04e24ecee0e86.tar.gz
Merge branch 'timeline-local' into timeline-multiselect
Conflicts: js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js resolved using theirs. (selectLayers)
Diffstat (limited to 'js/tools/drawing-tool-base.js')
-rwxr-xr-xjs/tools/drawing-tool-base.js87
1 files changed, 40 insertions, 47 deletions
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js
index 2283dfab..84641754 100755
--- a/js/tools/drawing-tool-base.js
+++ b/js/tools/drawing-tool-base.js
@@ -24,6 +24,9 @@ exports.DrawingToolBase = Montage.create(Montage, {
24 value: null 24 value: null
25 }, 25 },
26 26
27 dragPlane: {
28 value: null
29 },
27 /** 30 /**
28 * Used on the initial MouseDown for Drawing Tools 31 * Used on the initial MouseDown for Drawing Tools
29 * 32 *
@@ -33,19 +36,29 @@ exports.DrawingToolBase = Montage.create(Montage, {
33 * 2 - Y value converted to screen point 36 * 2 - Y value converted to screen point
34 */ 37 */
35 getInitialSnapPoint: { 38 getInitialSnapPoint: {
36 value: function(x,y) { 39 value: function(x, y, shapeCanvas)
40 {
37 // update the snap settings 41 // update the snap settings
38 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); 42 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() );
39 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); 43 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() );
40 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); 44 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() );
41 45
42 // do the snap 46 // do the snap
43 var hitRec = snapManager.snap(x, y, true); 47 this.dragPlane = null;
48 var hitRec = snapManager.snap(x, y, true);
44 if (hitRec) { 49 if (hitRec) {
45 // set up the working plane and convert the hit record to be working plane relative 50 if (shapeCanvas)
46 var dragPlane = snapManager.setupDragPlanes( hitRec ); 51 {
47 var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); 52 this.dragPlane = viewUtils.getUnprojectedElementPlane( shapeCanvas );
53 snapManager.setupDragPlaneFromPlane( this.dragPlane );
54 }
55 else
56 {
57 this.dragPlane = snapManager.setupDragPlanes( hitRec, true );
58 }
59// console.log( "drag plane: " + this.dragPlane );
48 60
61 var wpHitRec = hitRec.convertToWorkingPlane( this.dragPlane );
49 var pt = hitRec.getScreenPoint(); 62 var pt = hitRec.getScreenPoint();
50 63
51 return( [wpHitRec, pt[0], pt[1]] ); 64 return( [wpHitRec, pt[0], pt[1]] );
@@ -63,28 +76,32 @@ exports.DrawingToolBase = Montage.create(Montage, {
63 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); 76 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() );
64 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); 77 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() );
65 78
66
67 // do the first snap
68 var hitRec = snapManager.snap(x, y, snap3d ); 79 var hitRec = snapManager.snap(x, y, snap3d );
69 if (hitRec) { 80 if (hitRec) {
70 if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { 81// if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) {
71 hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); 82// hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() );
72 } 83// }
73 84//
74 if(downHitRec !== null) { 85// if(downHitRec !== null) {
75 // if we are working off-plane, do a snap to the projected locations of the geometry 86// // if we are working off-plane, do a snap to the projected locations of the geometry
76 var thePlane = workingPlane; 87// var thePlane = workingPlane;
77 if (snapManager.hasDragPlane()) 88// if (snapManager.hasDragPlane())
78 { 89// {
79 thePlane = snapManager.getDragPlane(); 90// thePlane = snapManager.getDragPlane();
80 } 91// }
81 92//
82 // Return the up HitRec 93// // Return the up HitRec
83 return hitRec; 94// return hitRec;
84 } else { 95// } else {
85 return null; 96// return null;
97// }
98 if(downHitRec) {
99 hitRec = hitRec.convertToWorkingPlane(this.dragPlane);
100 } else if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) {
101 hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() );
86 } 102 }
87 } 103 }
104 return hitRec;
88 } 105 }
89 }, 106 },
90 107
@@ -428,30 +445,6 @@ exports.DrawingToolBase = Montage.create(Montage, {
428 }, 445 },
429 446
430 /** 447 /**
431 * Get the matrix for the actual element being added to the user document.
432 */
433 getElementMatrix: {
434 value: function(planeMat, midPt) {
435 var divMat, flatMat, flatMatSafe;
436 // calculate the matrix for the element.
437 // we should not need to worry about divide by zero below since we snapped to the point
438 divMat = planeMat.slice(0);
439 divMat[12] = 0.0;
440 divMat[13] = 0.0;
441 //divMat[14] = 0.0;
442 divMat[14] = midPt[2];
443
444 // set the left and top of the element such that the center of the rectangle is at the mid point
445 viewUtils.setViewportObj(this.stage);
446
447 flatMat = divMat;
448 flatMatSafe = MathUtils.scientificToDecimal(flatMat, 10);
449
450 return "matrix3d(" + flatMatSafe + ")";
451 }
452 },
453
454 /**
455 * Draw Helper Functions 448 * Draw Helper Functions
456 */ 449 */
457 450