diff options
author | John Mayhew | 2012-05-07 16:30:19 -0700 |
---|---|---|
committer | John Mayhew | 2012-05-07 16:30:19 -0700 |
commit | db4ba95f50148198759dde503ec1c778184d9dbe (patch) | |
tree | 8b79ad58108af2f17d15abc8cdc33d35229ab20d /js/tools/drawing-tool-base.js | |
parent | 843d8ea8ee58a54bcb71d7b28dbf78fae153b491 (diff) | |
parent | 526e423e4a2734c2b139af23911e912452a4443f (diff) | |
download | ninja-db4ba95f50148198759dde503ec1c778184d9dbe.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts:
js/components/layout/tools-list.reel/tools-list.html
js/components/layout/tools-properties.reel/tools-properties.html
js/components/tools-properties/brush-properties.reel/brush-properties.html
js/components/tools-properties/fill-properties.reel/fill-properties.html
js/components/tools-properties/pen-properties.reel/pen-properties.html
js/components/tools-properties/pencil-properties.reel/pencil-properties.html
js/components/tools-properties/selection-properties.reel/selection-properties.html
js/components/tools-properties/shape-properties.reel/shape-properties.html
js/components/tools-properties/tag-properties.reel/tag-properties.html
js/components/tools-properties/text-properties.reel/text-properties.html
Diffstat (limited to 'js/tools/drawing-tool-base.js')
-rwxr-xr-x | js/tools/drawing-tool-base.js | 88 |
1 files changed, 36 insertions, 52 deletions
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 2e652d42..376b3a27 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,29 +36,30 @@ 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 | snapManager.clearDragPlane(); | ||
41 | |||
37 | // update the snap settings | 42 | // update the snap settings |
38 | snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); | 43 | snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); |
39 | snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); | 44 | snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); |
40 | snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); | 45 | snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); |
41 | 46 | ||
42 | // do the snap | 47 | // do the snap |
43 | var hitRec = snapManager.snap(x, y, true); | 48 | this.dragPlane = null; |
44 | var dragPlane; | 49 | var hitRec = snapManager.snap(x, y, true); |
45 | if (hitRec) { | 50 | if (hitRec) { |
46 | // set up the working plane and convert the hit record to be working plane relative | 51 | if (shapeCanvas) |
47 | if (hitRec.getElement() === snapManager.application.ninja.currentSelectedContainer) | ||
48 | { | 52 | { |
49 | dragPlane = viewUtils.getUnprojectedElementPlane( hitRec.getElement() ); | 53 | this.dragPlane = viewUtils.getUnprojectedElementPlane( shapeCanvas ); |
50 | snapManager.setupDragPlaneFromPlane( dragPlane ); | 54 | snapManager.setupDragPlaneFromPlane( this.dragPlane ); |
51 | } | 55 | } |
52 | else | 56 | else |
53 | { | 57 | { |
54 | dragPlane = snapManager.setupDragPlanes( hitRec ); | 58 | this.dragPlane = snapManager.setupDragPlanes( hitRec, true ); |
55 | } | 59 | } |
56 | console.log( "drag plane: " + dragPlane ); | 60 | // console.log( "drag plane: " + this.dragPlane ); |
57 | 61 | ||
58 | var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); | 62 | var wpHitRec = hitRec.convertToWorkingPlane( this.dragPlane ); |
59 | var pt = hitRec.getScreenPoint(); | 63 | var pt = hitRec.getScreenPoint(); |
60 | 64 | ||
61 | return( [wpHitRec, pt[0], pt[1]] ); | 65 | return( [wpHitRec, pt[0], pt[1]] ); |
@@ -73,28 +77,32 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
73 | snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); | 77 | snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); |
74 | snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); | 78 | snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); |
75 | 79 | ||
76 | |||
77 | // do the first snap | ||
78 | var hitRec = snapManager.snap(x, y, snap3d ); | 80 | var hitRec = snapManager.snap(x, y, snap3d ); |
79 | if (hitRec) { | 81 | if (hitRec) { |
80 | if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { | 82 | // if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { |
81 | hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); | 83 | // hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); |
82 | } | 84 | // } |
83 | 85 | // | |
84 | if(downHitRec !== null) { | 86 | // if(downHitRec !== null) { |
85 | // if we are working off-plane, do a snap to the projected locations of the geometry | 87 | // // if we are working off-plane, do a snap to the projected locations of the geometry |
86 | var thePlane = workingPlane; | 88 | // var thePlane = workingPlane; |
87 | if (snapManager.hasDragPlane()) | 89 | // if (snapManager.hasDragPlane()) |
88 | { | 90 | // { |
89 | thePlane = snapManager.getDragPlane(); | 91 | // thePlane = snapManager.getDragPlane(); |
90 | } | 92 | // } |
91 | 93 | // | |
92 | // Return the up HitRec | 94 | // // Return the up HitRec |
93 | return hitRec; | 95 | // return hitRec; |
94 | } else { | 96 | // } else { |
95 | return null; | 97 | // return null; |
98 | // } | ||
99 | if(downHitRec) { | ||
100 | hitRec = hitRec.convertToWorkingPlane(this.dragPlane); | ||
101 | } else if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { | ||
102 | hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); | ||
96 | } | 103 | } |
97 | } | 104 | } |
105 | return hitRec; | ||
98 | } | 106 | } |
99 | }, | 107 | }, |
100 | 108 | ||
@@ -438,30 +446,6 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
438 | }, | 446 | }, |
439 | 447 | ||
440 | /** | 448 | /** |
441 | * Get the matrix for the actual element being added to the user document. | ||
442 | */ | ||
443 | getElementMatrix: { | ||
444 | value: function(planeMat, midPt) { | ||
445 | var divMat, flatMat, flatMatSafe; | ||
446 | // calculate the matrix for the element. | ||
447 | // we should not need to worry about divide by zero below since we snapped to the point | ||
448 | divMat = planeMat.slice(0); | ||
449 | divMat[12] = 0.0; | ||
450 | divMat[13] = 0.0; | ||
451 | //divMat[14] = 0.0; | ||
452 | divMat[14] = midPt[2]; | ||
453 | |||
454 | // set the left and top of the element such that the center of the rectangle is at the mid point | ||
455 | viewUtils.setViewportObj(this.stage); | ||
456 | |||
457 | flatMat = divMat; | ||
458 | flatMatSafe = MathUtils.scientificToDecimal(flatMat, 10); | ||
459 | |||
460 | return "matrix3d(" + flatMatSafe + ")"; | ||
461 | } | ||
462 | }, | ||
463 | |||
464 | /** | ||
465 | * Draw Helper Functions | 449 | * Draw Helper Functions |
466 | */ | 450 | */ |
467 | 451 | ||