aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorEric Guzman2012-08-20 14:54:44 -0700
committerEric Guzman2012-08-20 14:54:44 -0700
commit1e9d019867ff90840735ec531af5ebec9c7962e6 (patch)
tree887d28987a3113e84c771e264767c9462e9a8844 /js/tools
parenta34663e154af834176b758b6da368f634cd2a6bd (diff)
parent36d692a9fb216f2785a570d13c1beb27360c7305 (diff)
downloadninja-1e9d019867ff90840735ec531af5ebec9c7962e6.tar.gz
Merge branch 'refs/heads/master' into minorFixes_7.1
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/LineTool.js56
-rwxr-xr-xjs/tools/Translate3DToolBase.js4
-rwxr-xr-xjs/tools/TranslateObject3DTool.js19
3 files changed, 40 insertions, 39 deletions
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index f0d96c3c..4ec327b5 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -97,34 +97,38 @@ exports.LineTool = Montage.create(ShapeTool, {
97 if(this.drawData) { 97 if(this.drawData) {
98 w = Math.floor(this.drawData.width); 98 w = Math.floor(this.drawData.width);
99 h = Math.floor(this.drawData.height); 99 h = Math.floor(this.drawData.height);
100 // set the dimensions
101 if(slope === "horizontal") {
102 h = Math.max(this._strokeSize, 1);
103 w = Math.max(w, 1);
104 } else if(slope === "vertical") {
105 w = Math.max(this._strokeSize, 1);
106 h = Math.max(h, 1);
107 } else {
108 // else make the line's stroke fit inside the canvas by growing the canvas
109 var theta = Math.atan(slope);
110 xAdj = Math.abs((this._strokeSize/2)*Math.sin(theta));
111 yAdj = Math.abs((this._strokeSize/2)*Math.cos(theta));
112
113 w += ~~(xAdj*2);
114 h += ~~(yAdj*2);
115 }
116
100 if(!this._useExistingCanvas()) { 117 if(!this._useExistingCanvas()) {
101 // set the dimensions 118
102 if(slope === "horizontal") { 119 canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument);
103 h = Math.max(this._strokeSize, 1); 120
104 w = Math.max(w, 1); 121 var styles = document.application.njUtils.stylesFromDraw(canvas, w, h, this.drawData);
105 } else if(slope === "vertical") { 122 this.application.ninja.elementMediator.addElements(canvas, styles);
106 w = Math.max(this._strokeSize, 1); 123 } else {
107 h = Math.max(h, 1); 124 canvas = this._targetedElement;
108 } else { 125 if (!canvas.getAttribute( "data-RDGE-id" ))
109 // else make the line's stroke fit inside the canvas by growing the canvas 126 canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() );
110 var theta = Math.atan(slope); 127 canvas.elementModel.controller = ShapesController;
111 xAdj = Math.abs((this._strokeSize/2)*Math.sin(theta)); 128 if(!canvas.elementModel.shapeModel) {
112 yAdj = Math.abs((this._strokeSize/2)*Math.cos(theta)); 129 canvas.elementModel.shapeModel = Montage.create(ShapeModel);
113
114 w += ~~(xAdj*2);
115 h += ~~(yAdj*2);
116 }
117
118 canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument);
119
120 var styles = document.application.njUtils.stylesFromDraw(canvas, w, h, this.drawData);
121 this.application.ninja.elementMediator.addElements(canvas, styles);
122 } else {
123 canvas = this._targetedElement;
124 canvas.elementModel.controller = ShapesController;
125 if(!canvas.elementModel.shapeModel) {
126 canvas.elementModel.shapeModel = Montage.create(ShapeModel);
127 } 130 }
131 this.RenderShape(w, h, this.drawData.planeMat, this.drawData.midPt, canvas, slope, xAdj, yAdj);
128 } 132 }
129 } 133 }
130 } 134 }
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index b5008666..fd275a8a 100755
--- a/js/tools/Translate3DToolBase.js
+++ b/js/tools/Translate3DToolBase.js
@@ -166,7 +166,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
166 166
167 var len = selectedElements.length, 167 var len = selectedElements.length,
168 self = this, 168 self = this,
169 target = selectedElements[0], 169 target = this.clickedObject,
170 curMat = viewUtils.getMatrixFromElement( target ), 170 curMat = viewUtils.getMatrixFromElement( target ),
171 matInv = glmat4.inverse(this._startMat, []), 171 matInv = glmat4.inverse(this._startMat, []),
172 nMat = glmat4.multiply(transMat, this._startMat, [] ); 172 nMat = glmat4.multiply(transMat, this._startMat, [] );
@@ -180,7 +180,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
180 180
181 var shouldUpdateStartMat = true; 181 var shouldUpdateStartMat = true;
182 182
183 if(this._clickedOnStage || ((this._handleMode === 2) && (len > 1))) 183 if(this._clickedOnStage || ((this._handleMode !== null) && (len > 1)))
184 { 184 {
185 shouldUpdateStartMat = false; 185 shouldUpdateStartMat = false;
186 } 186 }
diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js
index a3ece1f9..5dfd2029 100755
--- a/js/tools/TranslateObject3DTool.js
+++ b/js/tools/TranslateObject3DTool.js
@@ -77,15 +77,12 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, {
77 else 77 else
78 { 78 {
79 this._delta = null; 79 this._delta = null;
80 //if(this._handleMode === 2) { 80 this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target, this._handleMode, (this._inLocalMode && (this.application.ninja.selectedElements.length === 1)));
81 this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target, this._handleMode, this._inLocalMode); 81 snapManager.setupDragPlaneFromPlane(this._dragPlane);
82 //console.log( "dragPlane: " + this._dragPlane ); 82 do3DSnap = false;
83 snapManager.setupDragPlaneFromPlane(this._dragPlane); 83
84 do3DSnap = false; 84 snapManager.enableElementSnap ( false );
85 85 snapManager.enableGridSnap ( false );
86 snapManager.enableElementSnap ( false );
87 snapManager.enableGridSnap ( false );
88 //}
89 } 86 }
90 87
91 if(this.application.ninja.selectedElements.length) { 88 if(this.application.ninja.selectedElements.length) {
@@ -95,7 +92,7 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, {
95 // a snap on the mouse down 92 // a snap on the mouse down
96 var hitRec = snapManager.snap(point.x, point.y, do3DSnap); 93 var hitRec = snapManager.snap(point.x, point.y, do3DSnap);
97 94
98 if(this._handleMode === 2) 95 if(this._handleMode !== null)
99 { 96 {
100 // translate z doesn't snap to element so hitRec's element will always be different 97 // translate z doesn't snap to element so hitRec's element will always be different
101 // from what the browser says we clicked on. So, skip this check. 98 // from what the browser says we clicked on. So, skip this check.
@@ -135,7 +132,7 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, {
135 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); 132 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() );
136 } 133 }
137 134
138 if(this._handleMode === 2) 135 if(this._handleMode !== null)
139 this.clickedObject = this._target; 136 this.clickedObject = this._target;
140 137
141 // parameterize the snap point on the target 138 // parameterize the snap point on the target