diff options
Diffstat (limited to 'js/tools/drawing-tool-base.js')
-rwxr-xr-x | js/tools/drawing-tool-base.js | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 2283dfab..7d97f105 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,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; |
49 | var hitRec = snapManager.snap(x, y, true); | ||
44 | if (hitRec) { | 50 | if (hitRec) { |
45 | // set up the working plane and convert the hit record to be working plane relative | 51 | if (shapeCanvas) |
46 | var dragPlane = snapManager.setupDragPlanes( hitRec ); | 52 | { |
47 | var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); | 53 | this.dragPlane = viewUtils.getUnprojectedElementPlane( shapeCanvas ); |
54 | snapManager.setupDragPlaneFromPlane( this.dragPlane ); | ||
55 | } | ||
56 | else | ||
57 | { | ||
58 | this.dragPlane = snapManager.setupDragPlanes( hitRec, true ); | ||
59 | } | ||
60 | // console.log( "drag plane: " + this.dragPlane ); | ||
48 | 61 | ||
62 | var wpHitRec = hitRec.convertToWorkingPlane( this.dragPlane ); | ||
49 | var pt = hitRec.getScreenPoint(); | 63 | var pt = hitRec.getScreenPoint(); |
50 | 64 | ||
51 | return( [wpHitRec, pt[0], pt[1]] ); | 65 | return( [wpHitRec, pt[0], pt[1]] ); |
@@ -63,28 +77,32 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
63 | snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); | 77 | snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); |
64 | snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); | 78 | snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); |
65 | 79 | ||
66 | |||
67 | // do the first snap | ||
68 | var hitRec = snapManager.snap(x, y, snap3d ); | 80 | var hitRec = snapManager.snap(x, y, snap3d ); |
69 | if (hitRec) { | 81 | if (hitRec) { |
70 | if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { | 82 | // if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { |
71 | hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); | 83 | // hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); |
72 | } | 84 | // } |
73 | 85 | // | |
74 | if(downHitRec !== null) { | 86 | // if(downHitRec !== null) { |
75 | // 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 |
76 | var thePlane = workingPlane; | 88 | // var thePlane = workingPlane; |
77 | if (snapManager.hasDragPlane()) | 89 | // if (snapManager.hasDragPlane()) |
78 | { | 90 | // { |
79 | thePlane = snapManager.getDragPlane(); | 91 | // thePlane = snapManager.getDragPlane(); |
80 | } | 92 | // } |
81 | 93 | // | |
82 | // Return the up HitRec | 94 | // // Return the up HitRec |
83 | return hitRec; | 95 | // return hitRec; |
84 | } else { | 96 | // } else { |
85 | 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() ); | ||
86 | } | 103 | } |
87 | } | 104 | } |
105 | return hitRec; | ||
88 | } | 106 | } |
89 | }, | 107 | }, |
90 | 108 | ||