aboutsummaryrefslogtreecommitdiff
path: root/js/tools/drawing-tool-base.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/drawing-tool-base.js')
-rwxr-xr-xjs/tools/drawing-tool-base.js879
1 files changed, 440 insertions, 439 deletions
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js
index b2c8e6b4..92646894 100755
--- a/js/tools/drawing-tool-base.js
+++ b/js/tools/drawing-tool-base.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, are permitted provided that the following conditions are met:
8 7
9 - Redistributions of source code must retain the above copyright notice, 8* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 9 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 10
12 notice, this list of conditions and the following disclaimer in the 11* Redistributions in binary form must reproduce the above copyright notice,
13 documentation and/or other materials provided with the distribution. 12 this list of conditions and the following disclaimer in the documentation
14 - Neither the name of Motorola Mobility nor the names of its contributors 13 and/or other materials provided with the distribution.
15 may be used to endorse or promote products derived from this software 14
16 without specific prior written permission. 15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
17 18
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -50,7 +51,7 @@ exports.DrawingToolBase = Montage.create(Component, {
50 51
51 /** 52 /**
52 * Used on the initial MouseDown for Drawing Tools 53 * Used on the initial MouseDown for Drawing Tools
53 * 54 *
54 * Returns: An array containing: 55 * Returns: An array containing:
55 * 0 - HitRec point 56 * 0 - HitRec point
56 * 1 - X value converted to screen point 57 * 1 - X value converted to screen point
@@ -58,32 +59,32 @@ exports.DrawingToolBase = Montage.create(Component, {
58 */ 59 */
59 getInitialSnapPoint: { 60 getInitialSnapPoint: {
60 value: function(x, y, shapeCanvas) 61 value: function(x, y, shapeCanvas)
61 { 62 {
62 // update the snap settings 63 // update the snap settings
63 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); 64 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() );
64 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); 65 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() );
65 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); 66 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() );
66 67
67 // do the snap 68 // do the snap
68 this.dragPlane = null; 69 this.dragPlane = null;
69 var hitRec = snapManager.snap(x, y, true); 70 var hitRec = snapManager.snap(x, y, true);
70 if (hitRec) { 71 if (hitRec) {
71 if (shapeCanvas) 72 if (shapeCanvas)
72 { 73 {
73 this.dragPlane = viewUtils.getUnprojectedElementPlane( shapeCanvas ); 74 this.dragPlane = viewUtils.getUnprojectedElementPlane( shapeCanvas );
74 snapManager.setupDragPlaneFromPlane( this.dragPlane ); 75 snapManager.setupDragPlaneFromPlane( this.dragPlane );
75 } 76 }
76 else 77 else
77 { 78 {
78 this.dragPlane = snapManager.setupDragPlanes( hitRec, true ); 79 this.dragPlane = snapManager.setupDragPlanes( hitRec, true );
79 } 80 }
80// console.log( "drag plane: " + this.dragPlane ); 81// console.log( "drag plane: " + this.dragPlane );
81 82
82 var wpHitRec = hitRec.convertToWorkingPlane( this.dragPlane ); 83 var wpHitRec = hitRec.convertToWorkingPlane( this.dragPlane );
83 var pt = hitRec.getScreenPoint(); 84 var pt = hitRec.getScreenPoint();
84 85
85 return( [wpHitRec, pt[0], pt[1]] ); 86 return( [wpHitRec, pt[0], pt[1]] );
86 } 87 }
87 } 88 }
88 }, 89 },
89 90
@@ -93,27 +94,27 @@ exports.DrawingToolBase = Montage.create(Component, {
93 getUpdatedSnapPoint: { 94 getUpdatedSnapPoint: {
94 value: function(x,y, snap3d, downHitRec) { 95 value: function(x,y, snap3d, downHitRec) {
95 // update the snap settings 96 // update the snap settings
96 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); 97 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() );
97 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); 98 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() );
98 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); 99 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() );
99 100
100 var hitRec = snapManager.snap(x, y, snap3d ); 101 var hitRec = snapManager.snap(x, y, snap3d );
101 if (hitRec) { 102 if (hitRec) {
102// if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { 103// if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) {
103// hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); 104// hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() );
104// } 105// }
105// 106//
106// if(downHitRec !== null) { 107// if(downHitRec !== null) {
107// // if we are working off-plane, do a snap to the projected locations of the geometry 108// // if we are working off-plane, do a snap to the projected locations of the geometry
108// var thePlane = workingPlane; 109// var thePlane = workingPlane;
109// if (snapManager.hasDragPlane()) 110// if (snapManager.hasDragPlane())
110// { 111// {
111// thePlane = snapManager.getDragPlane(); 112// thePlane = snapManager.getDragPlane();
112// } 113// }
113// 114//
114// // Return the up HitRec 115// // Return the up HitRec
115// return hitRec; 116// return hitRec;
116// } else { 117// } else {
117// return null; 118// return null;
118// } 119// }
119 if(downHitRec) { 120 if(downHitRec) {
@@ -130,24 +131,24 @@ exports.DrawingToolBase = Montage.create(Component, {
130 value: function(x,y, snap3d, downHitRec) { 131 value: function(x,y, snap3d, downHitRec) {
131 132
132 133
133 // do the first snap 134 // do the first snap
134 var hitRec = snapManager.snap(x, y, snap3d ); 135 var hitRec = snapManager.snap(x, y, snap3d );
135 if (hitRec) { 136 if (hitRec) {
136 if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { 137 if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) {
137 hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); 138 hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() );
138 } 139 }
139 140
140 if(downHitRec !== null) { 141 if(downHitRec !== null) {
141 // if we are working off-plane, do a snap to the projected locations of the geometry 142 // if we are working off-plane, do a snap to the projected locations of the geometry
142 var thePlane = workingPlane; 143 var thePlane = workingPlane;
143 if (snapManager.hasDragPlane()) 144 if (snapManager.hasDragPlane())
144 { 145 {
145 thePlane = snapManager.getDragPlane(); 146 thePlane = snapManager.getDragPlane();
146 } 147 }
147 148
148 // Return the up HitRec 149 // Return the up HitRec
149 return hitRec; 150 return hitRec;
150 } else { 151 } else {
151 return null; 152 return null;
152 } 153 }
153 } 154 }
@@ -156,20 +157,20 @@ exports.DrawingToolBase = Montage.create(Component, {
156 157
157 158
158 setDownHitRec: { 159 setDownHitRec: {
159 value: function (x, y, do3DSnap) { 160 value: function (x, y, do3DSnap) {
160 var hitRec = snapManager.snap(x, y, do3DSnap ); 161 var hitRec = snapManager.snap(x, y, do3DSnap );
161 if (hitRec) { 162 if (hitRec) {
162 if ((hitRec.getType() != hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { 163 if ((hitRec.getType() != hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) {
163 //hitRec = hitRec.convertToWorkingPlane( workingPlane ); 164 //hitRec = hitRec.convertToWorkingPlane( workingPlane );
164 snapManager.setupDragPlanes(hitRec); 165 snapManager.setupDragPlanes(hitRec);
165 hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); 166 hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() );
166 } 167 }
167 168
168 return hitRec; 169 return hitRec;
169 170
170 } 171 }
171 } 172 }
172 }, 173 },
173 174
174 drawSnapLastHit: { 175 drawSnapLastHit: {
175 value: function() { 176 value: function() {
@@ -208,97 +209,97 @@ exports.DrawingToolBase = Montage.create(Component, {
208 209
209 getCompletePoints: { 210 getCompletePoints: {
210 value: function(hitRec0, hitRec1) { 211 value: function(hitRec0, hitRec1) {
211 if (hitRec0 && hitRec1) { 212 if (hitRec0 && hitRec1) {
212 213
213